Comments on: Using ADC of PIC Microcontroller – MPLAB XC8 https://electrosome.com/adc-pic-microcontroller-mplab-xc8/ You Inspire.....We Create..... Tue, 15 Sep 2020 02:46:27 +0000 hourly 1 https://wordpress.org/?v=6.1.1 By: Ligo George https://electrosome.com/adc-pic-microcontroller-mplab-xc8/#comments/9741 Tue, 15 Sep 2020 02:46:27 +0000 https://electrosome.com/?p=11418#comment-9741 In reply to Girish Ganesan R.

1. ADC_Read() function is a general function. This just an example program. You may use other ADC channels if required. Other channels are not used in this program.
2. This is done just to make ADC_Read() a general function.
3. It is not for changing justification. One register in this microcontroller holds only 8bits. I guess this MCU is having 10bit ADC. So it just combines ADC result registers to a single value.

]]>
By: Girish Ganesan R https://electrosome.com/adc-pic-microcontroller-mplab-xc8/#comments/9736 Mon, 14 Sep 2020 02:49:33 +0000 https://electrosome.com/?p=11418#comment-9736 I have a few queries.
1. channel is always going to be 0. Therefore what is the necessity to check if channel >7 in the ADC_read() ?
2. Subsequently, what is the function of resetting the channel bits and setting them again in the next two lines. Can we not configure this permanently in the ADCON1 and ADCON0 registers?
3. Also, is my understanding accurate as regarding to the 8 right shifts you do when returning the result of ADC_read() is to change justification of the ADC result? Can this not be achieved by setting ADFM ( ADCON1.7) =1 [which means right justified]

Thank you for the wonderful content. This is Very helpful.

]]>
By: Percy https://electrosome.com/adc-pic-microcontroller-mplab-xc8/#comments/9694 Mon, 06 Jul 2020 04:08:13 +0000 https://electrosome.com/?p=11418#comment-9694 In reply to Gabriele Devita.

Check the datasheet sir.

]]>
By: Ligo George https://electrosome.com/adc-pic-microcontroller-mplab-xc8/#comments/9564 Wed, 25 Mar 2020 04:46:32 +0000 https://electrosome.com/?p=11418#comment-9564 In reply to S S RANA.

Thanks for your feedback.

]]>
By: S S RANA https://electrosome.com/adc-pic-microcontroller-mplab-xc8/#comments/9563 Tue, 24 Mar 2020 14:28:08 +0000 https://electrosome.com/?p=11418#comment-9563 Thanks a lot respected Mr George for well commented program. It is very useful.
With Regards,
S S RANA

]]>
By: Jayakar Manoharan https://electrosome.com/adc-pic-microcontroller-mplab-xc8/#comments/7459 Mon, 15 Jul 2019 08:01:54 +0000 https://electrosome.com/?p=11418#comment-7459 In reply to Prakash.

ADCON0 &= 0xC5; is equivalent to
ADCON0 = ADCON0 & 0xC5; (ADCON0 & 1011 0101)=>( 1000 0001 & 1011 0101)

ADCON0 |= channel<<3; is equivalent to
ADCON0= ADCON0 | (channel< ADCON0 | (0000 0000< (1000 0001 | 0000 0000)
{i.e if channel is 1 then => ADCON0 | {0000 0001< (1000 0001 | 0000 1000) }
Hope it helps

]]>
By: Arturo Miranda https://electrosome.com/adc-pic-microcontroller-mplab-xc8/#comments/7086 Sat, 05 May 2018 21:15:34 +0000 https://electrosome.com/?p=11418#comment-7086 Where can i find the ?

]]>
By: JUAN ANTONIO HERNÁNDEZ MERALES https://electrosome.com/adc-pic-microcontroller-mplab-xc8/#comments/6812 Wed, 05 Jul 2017 04:10:00 +0000 https://electrosome.com/?p=11418#comment-6812 Hi! I have a little problem. I write a loop to read the ADC channel 0 every 500ms, but the ADC change the result sometimes. I put the AN0 input on 0V and the ADC continue doing this. The great problem is the result, it’s many bits of error. Could you help me to know what happen?

]]>
By: Gabriele Devita https://electrosome.com/adc-pic-microcontroller-mplab-xc8/#comments/6769 Mon, 01 May 2017 17:26:00 +0000 https://electrosome.com/?p=11418#comment-6769 what’s different between this pic (16f877) and 18f45k22? I traied to use your code with some little changes for my pic but it doesn’t work…Could you help me?

]]>
By: Brandon Chin https://electrosome.com/adc-pic-microcontroller-mplab-xc8/#comments/6739 Mon, 10 Apr 2017 04:09:00 +0000 https://electrosome.com/?p=11418#comment-6739 For anyone wondering why their code only showing zeroes for the lower 6 bits, it’s because you are copy and pasting the code on this page which is left justified. Simply change ADCON1 to 0x80 to fix this.

]]>