Im using ATTINY861 ADC with a potentiometer, there is a trigger source of ADC with a watchdog timer.
How does this implement, is it using ISR from watchdog timer ? Can show some light with pseudo code example ?
Thank you so much
Im using ATTINY861 ADC with a potentiometer, there is a trigger source of ADC with a watchdog timer.
How does this implement, is it using ISR from watchdog timer ? Can show some light with pseudo code example ?
Thank you so much
This is extracted from the datasheet.
Why would you use the watchdog timer to trigger the ADC?
This is something like event system in the new series. I wonder how this is done in the old avr.
Set the adc up for auto mode and select the trigger source. Set the watchdog up to interrupt at the required rate but don’t enable the interrupt. No isr needed.
As to why you’d use the watchdog rather than just a normal timer. But then again, do you need precise adc sampling?
You might be making a rod for your own back.
Set the adc up for auto mode and select the trigger source. Set the watchdog up to interrupt at the required rate but don’t enable the interrupt. No isr needed.
So the watchdog is so special in those ways? It knows to interrupt and not invoke the vector? And it knows to clear WDIF "by itself" to allow a succeeding trigger?
Or maybe when the WD is used for ADATE then it won't interrupt? But then what if you want interrupt and auto-trigger?
CV's Wizard doesn't handle the WD case. I wonder what OP needs -- some kind of periodic sampling, fairly widely spaced, and modest regularity requirements?
Ya. I prefer periodic sampling rather than put on the loop. I do not require precise ADC sampling.
. I prefer periodic sampling rather than put on the loop. I do not require precise ADC sampling.
Assuming you only need to ADC sample one channel of data, then I think I would set up the ADC in free running mode, and the WDT in periodic interrupt mode, and in the ISR() for the wd, read and save the current ADC value along with a flag to say new data is available.
That would keep your ISR() short and simple, then you can read the saved value atomically as needed in main().
Jim