NEW: Learning electronics? Ask your questions on the new Electronics Questions & Answers site hosted by CircuitLab.
Microcontroller Programming » MicroView and ADC conversion
June 14, 2017 by scootergarrett |
So I'm using the MicroView that I bootloaded discussed here, everything seemed to be working correctly but now I'm am trying to use the analog to digital converter. When I load the program on a simple DIP 328p it works as expected (numbers print to my computer screen change with voltage). But when I load the exact same program on the MicroView the analog to digital converter only outputs 1023 no matter the voltage. Dose anyone have experience with boot loading an Arduino and needing to do something special to get the ADC working? Code:
|
---|---|
June 14, 2017 by scootergarrett |
Solved my own problem but am unsure of the reason. From this post I found this line:
When added to the adc_init() function it works as expected. I'm not sure what the initial difference was between the MCU where they were defaulting to different states. |
June 19, 2017 by BobaMosfet |
ADMUX contains which of N channels of the ADC you're using. Set it to 1 (or whichever channel you want to use: ADMUX = 1 If you OR it, you're turning on more than one channel. Don't OR it. Do a warm-up conversion every time you change the channel. BM |
Please log in to post a reply.
Did you know that binary numbers use base 2 to represent numbers, and these are important for understanding microcontroller registers? Learn more...
|