Timer interrupt issue: reality or simulator broken?

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

So I am having a small problem, and I believe it is no problem at all, just BASCOM`s simulator acting funny. I have two timers, T1 and T2, that are configured to output an interrupt at 1hz and 14.4KHz respectively. In simulation, if I stop one or the other timer, everything is peachy, each running timer behaves perfectly fine. However, if I enable both timers at the same time, I still get the 14.4KHz interrupt, but the 1Hz one stops firing completely. Both ISRs are very short.

I believe this is just an artefact of the simulator's limited timers support, but just to confirm there is no limitation pertaining with using interrupts from both Timer1 and Timer2 right? I mean, the worse that could happen is one or the other interrupt might get delayed for the length of one ISR, yes?

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

Quote:

I mean, the worse that could happen is one or the other interrupt might get delayed for the length of one ISR, yes?

Yes - unless you actually do something in one or other interrupt that affects the operation of the other timer of course.

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

Are you really using two AVR timers, or two channels on the same AVR timer?

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.

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

If the ISR for T1 does not mess with the settings for T2 nor T2 ISR mess with T1, then the worst should be a delay equal to the execution time of the ISR.

Depending on the device and the timer(s), TIMSK and TIFR manages interrupt status for two timers. It would be easy to mess with the other timer if you don't manage the bits correctly.

Jim

Jim Wagner Oregon Research Electronics, Consulting Div. Tangent, OR, USA http://www.orelectronics.net

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

It is two different timers. They do share the same prescaler (physical; each can have a different setting) according to the datasheet but I couldn't see that as being the issue. I'll write it off as simulator madness until i get a real board to test.

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

Can you not simulate it with AVR Studio then? (even if that means simulating a source-less .hex)

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

I can actually stick my .obj into AVR Studio 4 SP3 just fine, and see my BASIC source, toggle breakpoints and everything, I just am a total noob with Studio's simulator. If anyone would care to do a sanity check for me later tonight I'll upload my object file.

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

Note that .obj is either going to be in ELF or COFF format. That does not embed the source - simply a path to where the source files are on your HDD and the relevant line numbers. So while it may work for source level debugging for you it's not going to for anyone else.