timer0 ARM M3 do not count properly

Hello everyone,
I'm experiencing a strange behavior with the timer0 on my board, a landtiger with a lpc1768.

The issue is the number MR0 of the counter in order to get a fixed amount of delay and get an interrupt.

My configuration is as follow:
-) master clock source of 12Mhz (the crystal installed on the board) and with the 'clock generation schematic' in debug i see the clock is correctly chosen, the cclk is 100 Mhz and so the PCLK/1=100, PCLK/2 50 etc.
-)On my 'clock dividers window' the timer0 selection is on CCLK/4 and 25.0000 MHz.
-)the prescaler found in 'timer0' window is PR=0
-)my MR0 is 0x17D7840 (25*10e6) - it is found by multiplying 1s*25*10e6 1/s= 25*10e6 tick to count 1s.

When i debug the application inserting one breakpoint to the timer activation (LPC_TIM0->TCR = 1) and one on the first instruction of the IRQ_timer0Handler, the time shown the bottom right corner of keil, is 10s.

But if i have selected a 25Mhz clock, no presclarer, why 10s?
More strange is that, when i debug in simulation, the timer count 1s. But i cannot figure out what is going wrong with the board.
Can you please give me some advice about it? What am i missing?
Thank you

Parents
  • Hello.

    For the "Clock Generation Schematic" view, the "Xtal (MHz)" value on the "Options for Target ... -> Target" tab needs to be correct. So, if you have a 12MHz crystal on your board, enter "12" there.

    For the timing in the debugger, set the correct "Core Clock" in the "Settings for your debug driver -> Trace". So, if you have configured this to 100MHz, enter "100" there.

    With this, the "Stop Watch" times should match the actual values.

Reply
  • Hello.

    For the "Clock Generation Schematic" view, the "Xtal (MHz)" value on the "Options for Target ... -> Target" tab needs to be correct. So, if you have a 12MHz crystal on your board, enter "12" there.

    For the timing in the debugger, set the correct "Core Clock" in the "Settings for your debug driver -> Trace". So, if you have configured this to 100MHz, enter "100" there.

    With this, the "Stop Watch" times should match the actual values.

Children
No data
More questions in this forum