MCF5211 output compare double pulse with shift.

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

MCF5211 output compare double pulse with shift.

826 Views
ITABE
Contributor I

Hi all,

 

 I need to generate one negative pulse of 10us and repeated (period) in 600us and another equal but with 30us of delay from the 1st.

I try with PWM without sucess because the shift is more then 0xff.

The idea is to use output compare and interrupt to toggle the state in the two different counter, one for the duty and one for the period. Really I'm lost in the register of MCF_GPT.

Did some have how to initialize GPT port to generate a pulse and control it under interrupt ?

 

Thank you in advance.

// Andrea

Labels (1)
0 Kudos
Reply
1 Reply

652 Views
TomE
Specialist II

Tricky. See a recent post mentioning "CFInit". it may help you find what the timers are capable of and should help you with the initialisation.

 

I was hoping these timers could generate a single-clock output pulse on output compare, but they can only set, clear or toggle. If they could generate a pulse you could have fed a 100kHz signal through to PACLK and run the timers from there.

 

Don't ignore the PIT for generating interrupts and the DMA Timers for generating signals and interrupts either.

 

The general approach for "make a timer do something and then change it with interrupts" would work with the GPT as long as you can guarantee that nothing will delay interrupts for longer than your required minimum pulse time. Luckily the Coldfire has multi-level interrupts, so you could put the timer service on Level 6 or even on level 7 to give it priority over other interrupts.

 

Basically you need to set two GPT timers up to toggle the pins and then program one's output comparatorvto "current counter plus a bit" and the other one to "the same value plus 30us worth of counts". Then, for each timer have the interrupt service routines alternate between adding "10us" worth or count to the comparison register and adding 590us worth of counts. That's all you need.

 

Except the DMA Timers might be better. They have prescalers so you might be able to program them to 100kHz. They can generate a "single pulse" on the output, AND they can restart when they reach their count. So you can set up two of them running a 600us cycle with a 10us output pulse. Just start one of them 30us after you start the other one - you can read the current count of one to know when to start the other.

 

If you're running at 80MHz, set the /16 prescaler to get 5MHz, divide that by 50 in the prescaler to get a 100kHz clock and run two DMA Timers off that. If you're running at 66.6MHz you can't get a 10us pulse, but you might get close enough for what you need.

 

Tom

 

0 Kudos
Reply