PIC16F877 ADC stalled?

Status
Not open for further replies.
currently, my code seem to do the endless loop and the while(GO) loop correctly.... however, the output seem to stay constant regardless of what the input is....

 
Is your PIC really running at 20Mhz? Because the diagram of the dev board shows a 4Mhz crystal. If it's at 4Mhz, you should change your #pragma CLOCK_FREQ and adcon0 setups to reflect this. Shouldn't stop the ADC from working though it'll be slower.
I am supplying the input through a power supply unit where i can adjust the voltage...
It's hard to see on the diagram exactly where AN0 (Pin2) of the PIC goes to on the DEV board. I assume the input to the pin never went above 5V. If your power supply surged or supplied a voltage higher than 5V, then the AN0 input is fried if you didn't use a series resistor (4K7 is a good value). If so, try a different input pin.
 
Thank you for your help... I finally got it working... I copied a piece of coding from an ADC sample.... now my ADC is working correctly... don't know why it is working though.... I had my TA's check it out and they have no idea why it is working either as the sample code that i copied should do what i had written anyway..... so while it is now working, i am still puzzled by why it is working...
 
Could be some weird compiler bug. I guess you could look at the disassembly listing and try to figure it out. It's good you got it going; happy programming!
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…