Hello there,
As a beginner, I am quite confused with the programming of HCS12X (MC9S12XDP512)MCU.
Can anyone help me write a simple timer program ? also please give the basic difference between a Periodic Timer interrupt and Enhanced Capture Timer, when are they used....
Solved! Go to Solution.
This webpage has lots of starter code for the C32 and DP512: http://users.ece.utexas.edu/~valvano/Starterfiles/
You'll probably be interested in OC_DP512.zip but searching the page for "output compare" will help you find other timer-related code.
The ECT contains a set of 8 timers that trigger when TCNT (the main counter/timer) is equal to a certain number. For example, output compare 7 interrupt triggers when TC7 is equal to TCNT. TC7 and TCNT are 16-bit registers. If you want an output compare 7 interrupt 500 TCNT ticks from now, set TC7 = TCNT + 500. The output compare interrupts can also be set to automatically toggle a pin. The ECT also can change output compare interrupts into input capture interrupts, where interrupts are triggered on edges on pins.
The periodic timers are 4 timers that trigger once every 1 bus cycle to 2**24 bus cycles. The timing of the interrupts is less flexible.
You'll probably want to read chapter 7 and chapter 13 of the XDP512 datasheet.
This webpage has lots of starter code for the C32 and DP512: http://users.ece.utexas.edu/~valvano/Starterfiles/
You'll probably be interested in OC_DP512.zip but searching the page for "output compare" will help you find other timer-related code.
The ECT contains a set of 8 timers that trigger when TCNT (the main counter/timer) is equal to a certain number. For example, output compare 7 interrupt triggers when TC7 is equal to TCNT. TC7 and TCNT are 16-bit registers. If you want an output compare 7 interrupt 500 TCNT ticks from now, set TC7 = TCNT + 500. The output compare interrupts can also be set to automatically toggle a pin. The ECT also can change output compare interrupts into input capture interrupts, where interrupts are triggered on edges on pins.
The periodic timers are 4 timers that trigger once every 1 bus cycle to 2**24 bus cycles. The timing of the interrupts is less flexible.
You'll probably want to read chapter 7 and chapter 13 of the XDP512 datasheet.
Well thank you,
I will see to it again