Triggering 861 ADC with watchdog timer

Go To Last Post
8 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

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

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

 

This is extracted from the datasheet. 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Why would you use the watchdog timer to trigger the ADC?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

 

This is something like event system in the new series. I wonder how this is done in the old avr.

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

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.

Last Edited: Tue. Nov 24, 2020 - 12:20 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Kartman wrote:
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?

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

Last Edited: Tue. Nov 24, 2020 - 03:39 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Ya. I prefer periodic sampling rather than put on the loop. I do not require precise ADC sampling. 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

hamisu wrote:
. 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

 

(Possum Lodge oath) Quando omni flunkus, moritati.

"I thought growing old would take longer"