Output Compare

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

Output Compare

5,204 Views
ernestsnaith
Contributor I
Please could someone explain how the output compare is used on S12XDT512, im told it can be used to create a pulse of a certain duration with no program interaction, after it has been executed.
 
Do you simply load a value into the compare register and when the timer hits this value it toggles, sets, clears the relevant pin? What are the mask and data registers, how do you use this to create a pulse?
 
Many Thanks
 
Erny
Labels (1)
0 Kudos
Reply
5 Replies

729 Views
ernestsnaith
Contributor I
I am asking specific questions about the registers which i dont understand after reading the datasheet, the mask register and the data registers. Pages 457-8.

Message Edited by ernestsnaith on 2006-06-28 03:06 PM

Message Edited by ernestsnaith on 2006-06-28 03:06 PM

0 Kudos
Reply

730 Views
ernestsnaith
Contributor I

Cheers, sounds simple enough.

For example OC7M (mask) and OC7D (data) regsiters. What are they and why 8 bit?

0 Kudos
Reply

730 Views
imajeff
Contributor III
OK, here are some specific answers, I'm not trying to be sarcastic--I do hope these answers help...

ernestsnaith wrote:

Cheers, sounds simple enough.

For example OC7M (mask) and OC7D (data) regsiters. What are they and why 8 bit?


One thing to note about Output Compare 7 is that it has a special purpose and it is easier to ignore it until the other output compares are figured out. OC7D can be used to simultaneously update all the other output compares (a timed parallel output). You would not normally use this except on multiple OC channels that are not being used otherwise. The mask tells it only those channels you intend to control with OC7.

They are 8 bit because they did not want to waste bus width in the architecture by limiting them to 5 bit.
0 Kudos
Reply

730 Views
imajeff
Contributor III
Erny,

Are you reading in the data sheet? That might help. You could ask specific questions about certain registers by name if you don't understand what it means.

http://www.freescale.com/files/microcontrollers/doc/data_sheet/MC9S12XDP512V2.pdf
Chapter 10
0 Kudos
Reply

730 Views
rhinoceroshead
Contributor I
Yes, that's pretty much how you do it.  Of course there is a bit of initialization/configuration that you have to do before it works - is that what you're asking about?
 
Generally, you have to enable the timer, set the clock dividers to a suitable range for your application, set it to output compare mode on the timer channel/pin of your choice, configure to set, clear, or toggle and write the appropriate value into the compare register for that channel/pin.  Then when the counter rolls around to that value, it sets or clears or toggles that pin.  If you want only one pulse, then you might want to enable an interrupt on that channel so you can disable the timer - otherwise it will keep setting or clearing or toggling every time the counter rolls around.
 
I'm not sure what you mean by 'mask and data registers'...
0 Kudos
Reply