andrea benelli

MCF5211 problem with PWM on pin 43 (PWM7)

Discussion created by andrea benelli on Jun 10, 2011
Latest reply on Jun 13, 2011 by Mark Butcher

Dear all,

 

 In the company where I work we use the we use that microcontroller for more than one circuit. Now we need to generate a pulse and we decided to work with PWM.

I looked to the AN3511 doc and I seen the source related.

I changed many times the sources, I can see the modulation in the pins 40, 41  (PWM1, PWM3) but nothing in the pin 43 (PWM7). Really I'm worried that I'll never see the pulse out of that pin...

 

Follow the source:

 

in mainfunction:

..

    /* configure PWM */
    PWMInit(SCALEDCLOCK,208);
    /* show the output for selected channel */

    /* all PWM channels are @ 30 Hz */
    /* even channels through LEDs in EVB */            /* duty cycle */

    PWMStart(3,200,100,LOWPOL,LEFTALIGNED);        /* 50 %   */           
    PWMStart(7,200,100,LOWPOL,LEFTALIGNED);        /* 50 %   */           

..

   
/**********************************FUNCTIONS**********************************/

/*****************************************************************************
 * PWMInit: Set channels ready to show a PWM output in pins                     *
 *                                                                           *
 * Parameters: u8Clock:       clock or sclaled clock source                     *
 *               u8ScaledValue: scaled value to use                             *
 *                                                                           *
 * Return : none.                                                            *
 *****************************************************************************/
void PWMInit(uint8 u8Clock, uint8 u8ScaledValue)
{
#ifdef MAI

// comment parts

    /* associate odd PWM channels to a pin */
    MCF_GPIO_PTDPAR = 0
                    | MCF_GPIO_PTDPAR_PTDPAR0    /* PWM channel 1 */
                    | MCF_GPIO_PTDPAR_PTDPAR1    /* PWM channel 3 */
                    | MCF_GPIO_PTDPAR_PTDPAR2    /* PWM channel 5 */
                    | MCF_GPIO_PTDPAR_PTDPAR3;    /* PWM channel 7 */
   
    /* associate even PWM channels to a pin */
    MCF_GPIO_PTCPAR = 0
                    | MCF_GPIO_PTCPAR_TIN0_PWM0    /* PWM channel 0 */
                    | MCF_GPIO_PTCPAR_TIN1_PWM2 /* PWM channel 2 */
                    | MCF_GPIO_PTCPAR_TIN2_PWM4 /* PWM channel 4 */
                    | MCF_GPIO_PTCPAR_TIN3_PWM6;/* PWM channel 6 */
   
#endif

    /* associate even PWM channels to a pin */
    // Configure pins for PWM use
    MCF_GPIO_PTAPAR = 0
        | MCF_GPIO_PTAPAR_PTAPAR0(3) // PWM1 this work fine
        | MCF_GPIO_PTAPAR_PTAPAR1(3)
        | MCF_GPIO_PTAPAR_PTAPAR2(0)
        | MCF_GPIO_PTAPAR_PTAPAR3(3);   // PWM7 this is my pin


    /* associate every channel with a source clock */
    /* A, or B, SA or SB depending the channel */
    MCF_PWM_PWMCLK  = u8Clock;   
    /* change the prescaler of the clock source for every channel */   
    MCF_PWM_PWMPRCLK = 0
                     | MCF_PWM_PWMPRCLK_PCKA(BUSCLK_16)
                     | MCF_PWM_PWMPRCLK_PCKB(BUSCLK_16);
    /* set scaled value for scaled clock, if are activated */
    MCF_PWM_PWMSCLA = u8ScaledValue;
    MCF_PWM_PWMSCLB = u8ScaledValue;
   

    MCF_PWM_PWMCTL = 0;

    return;   
}

/*****************************************************************************
 * PWMStart: Start selected PWM channel pin with selected duty and polarity  *
 *                                                                           *
 * Parameters: u8Channel:  PWM channel to start                                 *
 *               u8Period:   PWM channel period                                 *
 *             u8Duty:        PWM channel duty cycle                             *
 *             u8Polarity: PWM channel polarity                                 *
 *               u8Alignment:smileytongue:WM channel alignment                             *
 *                                                                           *
 * Return : none.                                                            *
 *****************************************************************************/
void PWMStart(uint8 u8Channel, uint8 u8Period, uint8 u8Duty,
              uint8 u8Polarity, uint8 u8Alignment)
{   
    // MCF_PWM_PWME &= ~(1<<u8Channel);    really is need ?


    MCF_PWM_PWMPER(u8Channel) = u8Period;            /* set PWM period */
    MCF_PWM_PWMDTY(u8Channel) = u8Duty;                /* set PWM duty cycle */
    MCF_PWM_PWMPOL |= (u8Polarity<<u8Channel);         /* set PWM polarity */
    MCF_PWM_PWMCAE |= (u8Alignment<<u8Channel);     /* set PWM alignment */
    /* show the PWM channel in its respective pin*/
    MCF_PWM_PWME |= (1<<u8Channel);
   
    return;
}


thank you in advance.


// Andrea.

Outcomes