Timer Delay program

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

Timer Delay program

Jump to solution
1,685 Views
admin
Specialist II

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.... 

Labels (1)
Tags (1)
0 Kudos
1 Solution
446 Views
isionous
Contributor III

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.

View solution in original post

0 Kudos
2 Replies
447 Views
isionous
Contributor III

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.

0 Kudos
446 Views
admin
Specialist II

Well thank you,

I will see to it again

0 Kudos