Timer

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Timer

3,867 Views
ernestsnaith
Contributor I
Just playing with timers and they seem increment every two clock cylces, is this right, i thought it was every 4 or maybe 1.
Labels (1)
0 Kudos
3 Replies

380 Views
ernestsnaith
Contributor I

Sorry, its a 9s12xdt512, using low power pierce oscillator at 4MHz. I have set the prescaler to the 128 max and set an LED to flash when the timer is over 0xF000. I was curious to see if i understood the timer so i timed how long the LED cycle took, it turned out to be 4.2 seconds. I thought it should be 1/ 4,000,000(clock) / 65536 (max timer value) all * 128 = 2.1 second

register wise i set TSCR2 to 0x07 and TSCR1 to 0x80

Message Edited by ernestsnaith on 05-02-200603:10 PM

0 Kudos

380 Views
Steve
NXP Employee
NXP Employee

If you have a 4MHz crystal the bus speed (and source of the timer clock) is 2MHz so your maths is correct. If you need the S12X to go faster you should enable the PLL.
You can have a larger prescaler on the timer by using the precision mode (see this thread: http://forums.freescale.com/freescale/board/message?board.id=16BITCOMM&message.id=861)

(Alban created link)

Message Edited by Alban on 05-03-2006 11:10 AM

0 Kudos

380 Views
imajeff
Contributor III
Perhaps you could be more specific if you want to know why. There are registers which control how many bus cycles per increment of TCNT. You could also specify what MCU
0 Kudos