AnsweredAssumed Answered

BF506F how to syncronize Timer to generate PWM

Question asked by marco55 on Feb 21, 2014
Latest reply on Mar 24, 2014 by Suraj

Hello,

I have a problem with timers on BF506F.

I acquire a square wave using a general purpose input (PG13) for rising egde interrupt and TACI2 for falling edge interrupt.

The acquired waveform has a frequency between 30 and 60 KHz.

I want to generate a PWM signal with period equal to half period of the acquired square wave, and programmable width.

For this purpose I'm tryng to use TIMER3 configured in PWM_OUT, PULSE_HI and PERIOD_CNT.

I enable TIMER3 at the rising edge interrupt.

 

I have two other timers to toggle the state of a GP-OUT to generate a sqauare wave delayed from the acquired one. I use TIMER0 and TIMER1 in single pulse generation for this purpose: timer0 enabled in rise edge interrupt and timer1 enabled in falling edge interrupt.

 

How can I syncronize the PWM generated atTMR3 pin with the rising edge of the acquired square wave?

I am tring to disable TIMER3 at TIMER1 interrupt (that always happens in the second half-period of the acquired square wave), but sometimes I notice that in this way the TMR3 level is lowered even if the pulse of PWM is not completed, while I read in the manual that it should complete the current waveform.

 

these are my interrupts:

 

////IVG07 - PortG Interrupt A

EX_INTERRUPT_HANDLER(RiseCaptureEntry)

{

    *pTIMER_ENABLE = TIMEN0 | TIMEN3;

    //Interrupt Assertion

    *pPORTGIO_CLEAR = SE2000_DSP2_REFERENCE_IN;

}

 

////IVG09 - TIMER2 Interrupt

EX_INTERRUPT_HANDLER(FallCaptureEntry)

{

    *pTIMER_ENABLE = TIMEN1;

   //Interrupt Assertion

    *pTIMER_STATUS = TIMIL2;

}

 

////IVG11 - TIMER0 Interrupt

EX_REENTRANT_HANDLER(RiseDelayEntry)

{

    *pPORTGIO_SET = SE2000_DSP2_DELAYED_OUT;

    *pTIMER0_WIDTH = DelayTab[DelayID];

    //Interrupt Assertion

    *pTIMER_STATUS = TIMIL0;

}

 

////IVG12 - TIMER1 Interrupt

EX_REENTRANT_HANDLER(FallDelayEntry)

{

    *pPORTGIO_CLEAR = SE2000_DSP2_DELAYED_OUT;

    *pTIMER1_WIDTH = DelayTab[DelayID];

    //Interrupt Assertion

    *pTIMER_STATUS |= TIMIL1;

 

    *pTIMER_DISABLE = TIMDIS3;

}

 

Any suggestion?

Thanks

Marco

Outcomes