Asynchronous timer wont stop in Studio

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

I have a problem with that my asynchronous timer will continue counting even if I pause the emulator in AVR Studio. It makes single stepping complicated becasue the timer interrupt always triggers and stepping will not correspond with real time. This is on a ATmega168. Am I doing something wrong or is this normal behavior?

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

From the dialog accessed by the bottom entry of the Debug menu in Studio I think there's an option there to enable/disable timers while the code is halted.

EDIT: from the JTAGICEmkII help file (Dragon help is the same):

Quote:
Run timers in stopped mode
Run timers in stopped mode. This option allows the target device's timers to continue running at their normal speed when single stepping through the code. When this box is not checked, timers will run cycle-correctly but synchronized to the stepping through the code.

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

Yes, there is such an option in platform options but that option is turned off. This chip is runned through debugWire so I hope it has nothing to do with that. For example if timer on/off can only be controlled in SPI mode. (debugWire off).

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

I have now looked into this problem again and I just can't understand it. I think this have something to do with the chip because I have never seen this problem before. In this design I use a low power type, the ATmega168PA. The oscillator on these device are much more sensible so maybe the oscillator can't be turned on and off as it should.

(If you want to know more about oscillators for low power devices search for ESR and crystal. The problem is the ESR value and you have to use low capacitor crystal types to make them running).

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

Never tried that.

I do not have a DebugWire dongle and I do not know what is supported with it, but AVRs OCD supported by JTAG ICE Mk1 (m16,m162,..,m128 etc) cannot stop asynchronous peripherals (except the watchdog clock). Even some synchronous (like UART) cannot be stopped.

If that is the case with asynchronous clock and you would like to freeze the time, run timer into synchronous mode during debugging. Of course there can be problems with OCRx value and it can be less accurate if clocked with RC, but that is usually not the problem during debugging. The time will not match anyway as you are stopping the time form time to time.

Just define two configurations in AS - name one a "Release" and the other a "Debug". Add -DNDEBUG to "Release" (I suppose ICC has it similar) and #ifdef NDEBUG appropriate version.

No RSTDISBL, no fun!