Can i use watchdog to trigger command

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

I am making a program that will have to send out a command approximately every 3 minutes, but I have already used timer1 and timer0 on the tiny 45, is it possible to use the watchdog timer to trigger this event without reseting the chip?

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

So why not have the "tick" on timer 0 or timer 1 just increment a counter (amongst everything else it already does). Say it is ticking once every 10ms then you just have to wait until the counter reaches 18,000 and then perform the "3 minute" event.

PS I just downloaded the Tiny45 datasheet - it says the WDT can be configured simply to generate an interrupt rather than reset the chip (page 42) so that *would* be an alternative approach.

Cliff

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

timer1 and timer0 are being used to send and receive commands and aren't always running

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

So why not let one of them run all the time instead?

Cliff

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

Would this throw off the timing of the bits i am reading in? When i see a rising edge, i reset the timer/counter and then start counting ticks to see how long the wave is. Each of these waves is in microseconds also, not sure if that would matter other than having a large number of ticks to 3 mins

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

There are at least two problems with using the watchdog timer: it's impossible to calibrate it, and the selection of overflow intervals is limited.

So the timing cannot be particularly precise, and if you build two identical boards, you'll see that they will likely generate these commands at different intervals despite running the same code.

But if precision and timing repeatability are not of critical importance for this application, then it should be perfectly possible to use the watchdog.

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

ok thanks, the timing doesn't have to be exact, anywhere between 3 and 3.5 minutes is where the command needs to be sent.

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

Hi,

Quote:
Would this throw off the timing of the bits i am reading in? When i see a rising edge, i reset the timer/counter and then start counting ticks to see how long the wave is. Each of these waves is in microseconds also, not sure if that would matter other than having a large number of ticks to 3 mins

This is what the "ICP = Input capture hardware" does.

In my opinion it is more reliable to work with the capture hardware.
To measure wavelength:
Let Timer1 run allways
On the first rising edge just save the value of the capture register
on the second rising edge save the value of the capture register.
If you subtract the first from the second value you have the wavelength.

Klaus
********************************
Look at: www.megausb.de (German)
********************************

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

MegaUSBFreak wrote:
This is what the "ICP = Input capture hardware" does.

But the OP seems to be committed to the ATtiny45, and it doesn't have any input capture function.

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

Quote:
ATtiny45, and it doesn't have any input capture function.

Sorry, didn´t know that...

Klaus
********************************
Look at: www.megausb.de (German)
********************************