Write an embedded C function to perform an ADC conversion. The function should accept one parameter ‘channel’ which specifies which ADC pin should be sampled. (e.g. if channel is 2 then sample A2, if channel is 4 then sample A4)
Select the appropriate channel
Start the ADC Conversion
Poll until the conversion is complete
Return the conversion value as the return value of the function.
Please explain the step properly
Please find below the embedded C function to perform an ADC conversion.
Since the code is written in reference to PIC18F8722 using MPLAB XC8 complier, the bit structure for the ADC registers used in the C function is also given below.
Get Answers For Free
Most questions answered within 1 hours.