-
Notifications
You must be signed in to change notification settings - Fork 317
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
System Clock change from 1MHz to higher internal clock creates skewed ADC results- Prescaler? #858
Comments
You may want to post code, showing how you set reference, read the ADC etc. Best is a minimal sketch, but just enough to demonstrate your issue. |
I"ve done some more testing and have some results to share. First, here is the relevant code. Project is a sensor tester with an ssd1306 display and battery monitor. #define rxPin 7 SoftwareSerial mySerial(rxPin, txPin); int battVoltPin = A3; void setup() At 1 Mhz clock, voltage measured at pin = 1.077 volts to keep at 1023 ADC |
I tried slightly different and kept the voltage at the same value just under the reference voltage. I also get different values at different clock speeds, Sketch
Result
No explanation yet. I am curious if it will give different result when using the ADC directly instead of the analogRead() function. |
Using the ADC directly gives still a difference in measurement with different clock-speeds.
|
And also with prescaling the ADC clock to be always 125KHz I get the same differences in ADC value with different clock speeds. I am out of clues now.
Output
Let me post this sketch on the Arduino forum. That has quite a big audience and maybe someone picks it up. |
Appreciate you looking into this! Much of this is over my head, but I'm surprised no one else has noticed this. |
https://forum.arduino.cc/t/different-adc-results-with-different-cpu-clockspeeds-attiny84a/1263347 Question posted. Who knows we can both learn something. |
Hello, I'm having an issue with ADC results when changing to a higher internal clock on an ATiny84a. I'm using the internal 1.1v reference, and a resistor divider to an analog input pin to monitor 9v battery voltage. All works perfectly with a 1MHz system clock. My project is requiring a faster clock, and trying 4 and 8 MHZ skews the ADC results. Instead of 1.1v = 1023, it now goes down to approx .98v = 1023 @ 8MHz. Am I missing something obvious here? I'm really more of a hardware guy, not code. Do I need to manually set the ADC prescale? Using ATtiny84a, Arduino Uno as ISP, Release core, no bootloader(burning bootloader at clock changes). Appreciate any insight!
The text was updated successfully, but these errors were encountered: