ADC First Conversion Timing – Atmega8
Quote from KerimF on August 25, 2024, 7:05 amHello,
Since my lap OS (Windows 7 Home Basic) is very old, I had to use the old last stable version for it (SimulIDE-R1689_Win32) to debug new codes written for ATmega8 (in assembly language).
So perhaps the following minor timing bug has been fixed already since long.
From ATmega8 datasheet:
ADCSRA, Bit 6 – ADSC: ADC Start Conversion
... The first conversion after ADSC has been written after the ADC has been enabled, or if ADSC is written at the same time as the ADC is enabled, will take 25 ADC clock cycles instead of the normal 13. This first conversion performs initialization of the ADC.
In that very old version, this first conversion also takes 13 ADC clock cycles instead of 25.
Regards,
Kerim
Hello,
Since my lap OS (Windows 7 Home Basic) is very old, I had to use the old last stable version for it (SimulIDE-R1689_Win32) to debug new codes written for ATmega8 (in assembly language).
So perhaps the following minor timing bug has been fixed already since long.
From ATmega8 datasheet:
ADCSRA, Bit 6 – ADSC: ADC Start Conversion
... The first conversion after ADSC has been written after the ADC has been enabled, or if ADSC is written at the same time as the ADC is enabled, will take 25 ADC clock cycles instead of the normal 13. This first conversion performs initialization of the ADC.
In that very old version, this first conversion also takes 13 ADC clock cycles instead of 25.
Regards,
Kerim
Quote from KerimF on August 26, 2024, 6:29 amHello Arcachofo
Just in case you prefer having an example, I attached ‘Balancer_01_1T-ADC.zip’.
The two breakpoints of the first ADC conversion are at lines 457 and 466 respectively.
Regards,
Kerim
Hello Arcachofo
Just in case you prefer having an example, I attached ‘Balancer_01_1T-ADC.zip’.
The two breakpoints of the first ADC conversion are at lines 457 and 466 respectively.
Regards,
Kerim
Uploaded files:Quote from arcachofo on August 26, 2024, 9:50 amThank you, I will have a look.
I remember something about this was solved some time ago, but not sure if it was the same issue.
Thank you, I will have a look.
I remember something about this was solved some time ago, but not sure if it was the same issue.
Quote from arcachofo on August 26, 2024, 11:06 amIndeed the first conversion time was not solved.
There is some code to account for the extra time, but it was not really used, so it was an easy fix.Now in your code I get these timings:
451 ; init ADC for 12V : 200.5 us
485 ; re-read 12V : 104.5 us
512 ; init ADC for 24V : 104.5 us
543 ; init ADC for cpV : 104.5 usI guess what I remember about AVR ADC timing is this (not related to first conversion):
https://simulide.forumotion.com/t1553-avr8-adc-conversion-timeSoon I will upload new tester builds:
https://simulide.com/p/testers/
Indeed the first conversion time was not solved.
There is some code to account for the extra time, but it was not really used, so it was an easy fix.
Now in your code I get these timings:
451 ; init ADC for 12V : 200.5 us
485 ; re-read 12V : 104.5 us
512 ; init ADC for 24V : 104.5 us
543 ; init ADC for cpV : 104.5 us
I guess what I remember about AVR ADC timing is this (not related to first conversion):
https://simulide.forumotion.com/t1553-avr8-adc-conversion-time
Soon I will upload new tester builds:
https://simulide.com/p/testers/