Atmega162: to check the Timer0 ticking

Hello, All!

When I initialize Timer0/1, how can I check amount of time spent by timer ticking, for example, if timer is configured for 10ms, how can I verify that

10ms really have gone. I suppose, I can attach probe of oscilloscope to pin1 of ATmega162 (according to datasheet it's OC0), but I don't see anything. Here is my code:

...

// ISR for Timer0 SIGNAL(SIG_OUTPUT_COMPARE0) { LED0_blink(); //my function

/* Timer/Counter0 initialization CLock source: system clock Prescaler value: 8 Clock value: Mode: increment CTC top=OCR0 Interrupt: enable

*/ void Timer0_Init(void) { TCCR0 = 0x00; //stop timer TCNT0 = 0x00; TCCR0 = _BV(CS01) | _BV(WGM01); OCR0 = 0xFF; TIMSK = _BV(OCIE0); }

int main(void) { Timer0_Init(); sei();

while (1) { ......... }

return 1; }

With best regards, Roman Mashak. E-mail: snipped-for-privacy@tusur.ru

Reply to
Roman Mashak
Loading thread data ...

I'd use the simulator. The CPU has a stopwatch option.

Leon

Reply to
Leon Heller

I'm using AVR Studio 4.10.

In Debug mode, select the I/O Workspace tab and open Processor. You should see a Stop Watch at the bottom. Right click on it and you will find lots of options. I run to a breakpoint, reset it, then run again to the breakpoint, or a second breakpoint, to get accurate timings. You need to set the correct clock rate for the simulator, of course. It should do what you want. You could use a 'scope as well, just to make sure.

Leon

--
Leon Heller, G1HSM
http://www.geocities.com/leon_heller
 Click to see the full signature
Reply to
Leon Heller

Hello, Leon! You wrote on Tue, 7 Dec 2004 16:39:28 -0000:

LH> I'm using AVR Studio 4.10. i'm using 4.8 build 310 LH> In Debug mode, select the I/O Workspace tab and open Processor. You LH> should see a Stop Watch at the bottom. Right click on it and you will LH> find lots of options. I run to a breakpoint, reset it, then run again LH> to the breakpoint, or a second breakpoint, to get accurate timings. You LH> need to set the correct clock rate for the simulator, of course. It LH> should do what you want. You could use a 'scope as well, just to make LH> sure. I've done everything you said, and got the following effect: after I reached the breakpoint 'stopwatch' value is changed and quickly resets to 0, so I have no time to see the value.

And I didn't find where to change simulator frequency, though I see its value in Processor window. LH> Leon

With best regards, Roman Mashak. E-mail: snipped-for-privacy@tusur.ru

Reply to
Roman Mashak

Hello, Leon! You wrote on Tue, 7 Dec 2004 16:39:28 -0000:

LH> In Debug mode, select the I/O Workspace tab and open Processor. You LH> should see a Stop Watch at the bottom. Right click on it and you will LH> find lots of options. I run to a breakpoint, reset it, then run again LH> to the breakpoint, or a second breakpoint, to get accurate timings. You LH> need to set the correct clock rate for the simulator, of course. It LH> should do what you want. You could use a 'scope as well, just to make LH> sure. OK, I set up frequency in simulator correctly and run the code, but I get some strange values in 'stop watch' field,, they are not what I expect. I'm doing the following steps:

1) set breakpoint 2) run (F5) 2) upon reaching breakpoint I zero'd the 'stop-watch' value (right click and choose reset) 3) press F5 again 4) see 'stop watch' value

With best regards, Roman Mashak. E-mail: snipped-for-privacy@tusur.ru

Reply to
Roman Mashak

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.