Analog to Digital Conversion: How to disable digital input buffer? #92
-
Using DxCore with AVR128DA28 no-bootloader, Arduino IDE. I am having a devil of a time with stability on my ADC. Running a simple case with no digital pins changing states all is well. However, when running my for-real application the voltage at analog inputs drops inexplicably when certain digital ports change state. All port configuration is done once up-front before any ADC action is taken. I have carefully searched my code and I am not using analog pins in any digital operations including read. The hardware checks out: No loose connections. Two questions:
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
It's done via PORTx.PINnCTRL register. - but the point of doing that is to reduce unnecessary power consumption on pins doing analog stuff or which are not in use and are floating (floating pins drain a huge amount of power in sleep mode on the modern AVRs. I swear it was never this bad on the classic AVRs. - but if you're trying to save power you do what you gotta do.) To write registers.... you just write to them, like they were a variable:
Pins have ports (x) and bits (n) for Pxn, Analog channels have numbers. Microchip did not make any attempt at making thus make any sense beyond "pin D1 is connected to analog channel 1" I took one look at the mess, and looked back at what it turned into on classic AVR cores and made the same decision I did for megaTinyCore: analogRead() expects Arduino pin numbers, and I asked the pinout chart maker (@freemovers on megaTinyCore and @MCUdude here and on ATTinyCore) to not list the analog channel numbers at all, and we can then end one of the most common In megaTinyCore and DxCore, (and after ATTinyCore 2.0.0 ios out, on there too) you should be using the Arduino pin numbers or (preferably) rhe PIN_Pxn notation),. The core is very capable of looking up analog channels as needed. |
Beta Was this translation helpful? Give feedback.
-
Thanks for your explanation of how to reference the pin registers. Regarding the problem I was seeing, you were right. Nothing to do with hardware, all supply voltages and connections good. I am using a PCB. I was not reading EEPROM correctly and depending on what buttons were pushed a different calibration value was read. All OK now. Thanks for your help and have a good day! |
Beta Was this translation helpful? Give feedback.
It's done via PORTx.PINnCTRL register. - but the point of doing that is to reduce unnecessary power consumption on pins doing analog stuff or which are not in use and are floating (floating pins drain a huge amount of power in sleep mode on the modern AVRs. I swear it was never this bad on the classic AVRs. - but if you're trying to save power you do what you gotta do.)
To write registers.... you just write to them, like they were a variable: