Timer2 and update bysy flags

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

Using the Timer 2 as an asynchronous timer with an external crystal for timing can be a pain. Today I solved a problem because of this. I failed to check the TNCT2 register update busy flag after updating it to the time-out value resulting in failed update. So the counter was just continuing from there it was and in turn resulted in a triggered watchdog.

Well, I also found that waiting for the TCNT2 register when you don't have to (sort of) could result in the counter counting 5 steps before going on. Very strange but I just removed the line and forgot about that.

So, if you are using the timer in asynchronous mode make sure to check all the busy bits after each write or a lot of unpredicted things may happen.

My favorites:
1. My oscilloscope, Yokogawa DLM2024.
2. My soldering iron, Weller WD2M, WMRP+WMRT.
3. JTAGICE3 debugger.

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

Was that a long winded way of saying you need to read datasheets very carefully and in the words of a beloved former president "trust, but verify".

We never have time to do it right,
but we always have time to do it over

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

Sort of. I thought it worth writing something about it because I couldn't find a word about update registers on the forum. That might just be me lacking the right search strings though.
Maybe someone having problem with asynchronous timer will benefit from it, isn't that the idea of this forum?

My favorites:
1. My oscilloscope, Yokogawa DLM2024.
2. My soldering iron, Weller WD2M, WMRP+WMRT.
3. JTAGICE3 debugger.

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

bengtr wrote:
Sort of. I thought it worth writing something about it because I couldn't find a word about update registers on the forum. That might just be me lacking the right search strings though.
Maybe someone having problem with asynchronous timer will benefit from it, isn't that the idea of this forum?

OK. So is it your contention that the published information is incorrect or incomplete? It seems like you had some expectations that were contradicted by the behavior of the actual part.

We never have time to do it right,
but we always have time to do it over

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

This post obviously isn't of interest for you so why do you not just stop reading it?

/edit
Now I realize I totally misunderstood your previous post. Now I really is feeling ashamed because I hate people yelling at each other in forums. I am truthfully sorry.

Now to your question:
Now it is some time ago but I do not think the data sheet is wrong but if you do not follow it exactly, very unpredictable things may happen. On the other hand, doing something wrong and not according to the data sheet by default means unpredictable result.

But the behavior of checking the update register when you don't have to (I don't remember the exact procedure I did) is very strange. The program locks up for a long time. 8 MHz system clock and the Timer 2 running on 32 kHz means that the program stopped for about 500 clock cycles doing what???

I can just say that take care when using the timer in this mode. I have done it many times but this is the first time I have seen this problem. I think one reason that I haven't seen the problem before is that my previous programs wasn't so sensitive for a missed counter restart. This is the first time I use it together with a watch dog so now a single miss was fatal.

My favorites:
1. My oscilloscope, Yokogawa DLM2024.
2. My soldering iron, Weller WD2M, WMRP+WMRT.
3. JTAGICE3 debugger.

Last Edited: Fri. Aug 12, 2011 - 09:11 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I want you to clarify your position for the benefit all. You don't get to choose what I do and don't read, and you certainly have no control over my posts.

That said you're the one made the original post. If you don't want people to try and understand what you are doing and claiming they why post in the first place?

We never have time to do it right,
but we always have time to do it over