AnsweredAssumed Answered

Center Aligned Output PWM MPC5606B

Question asked by duanemattern on Sep 22, 2016
Latest reply on Sep 25, 2016 by Petr Stancik

I'm trying to use the Center Alignement Output PWM (OPWMCB) mode on the MPC5606B using the TRK-MPC4606B board.  I'm using Codewarrior for MCU (V10.6) and I've already got the edge aligned PWM working for two channels.  Now I'm trying to figure out the center align mode.  I followed the guidelines in the MPC5606BRM.pdf  document (27.4.4.1.1.10) and I'm using the CounterBus_A (emios_ch23) in up/down mode.  But I'm not getting any toggle on the pins, so I'm trying to troubleshoot the setup.  Here's the bulk of the setup that I'm using (which changed from the edlge-aligned).  Any help would be appreciated.   I started with some of the kit demo code and the board is running with CAN and RS232, GPIO, and the pushbuttons, LEDs, potentiometer, and photosensor on the board.  It's just the center aligned PWM that I'm having difficulties setting up.  Goal is a 100kHz signal with a 50% duty cycle based on a 16MHz clock., which I had working in the edge align version of the PWM (OPWMB).

 

/*    EMIOS Module Configuration Register (EMIOS_MCR)            */
EMIOS_0.MCR.R = 0x00000000;   //disable

 

    /*    Unified Channel 23 Register                               */
    EMIOS_0.CH[23].CCR.R = 0x00000000;    //reset
    
    // MCB = Modulus Counter Buffered time base for the OPWMCB
    EMIOS_0.CH[23].CCR.B.UCPEN = 0;        // 2. Disable Channel Prescaler;
        EMIOS_0.CH[23].CCNTR.R = 1;        // 3. Write 0x1 at internal counter;
        EMIOS_0.CH[23].CADR.R = 81;        // 4. Set A register, period=2*(A-1)=160counts on 16MHz clock for 10us
        EMIOS_0.CH[23].CCR.B.MODE  = 0x54; // 5. Set ch to MCB Up mode, 0x101-0100, internal clock, B1 not used
        EMIOS_0.CH[23].CCR.B.UCPRE = 0;    // 6. Set prescaler ratio to "1".
    EMIOS_0.CH[23].CCR.B.UCPEN = 1;        // 7. Enable Channel Prescaler
    
    /*    Unified Channel 24 Register                               */
    // OPWMCB [channel 1] output PWM center-aligned, buffered
    EMIOS_0.CH[24].CCR.B.UCPEN = 0;        // 8. Disable Channel Prescaler;
        EMIOS_0.CH[24].CADR.R = 41;        // 9. Set A register; (162-(162*%/100) )/2
        EMIOS_0.CH[24].CBDR.R = 0;         // 10 Set B register, deadtime = 0
        EMIOS_0.CH[24].CCR.B.BSL = 0;      // 11 Select time base (MCB modulus counter bus) = ALL channels,

                                          //   emios_0.ch[23]
        EMIOS_0.CH[24].CCR.B.EDPOL = 1;    // sets output with "A" match
        EMIOS_0.CH[24].CCR.B.MODE = 0x5C;  // 12 Enter OPWMCB mode, center aligned,

                                           // output PWM, modulation buffered, trailing edge deadtime (not used)
        EMIOS_0.CH[24].CCR.B.UCPRE = 0;    // 13 Set prescaler ratio = 1
    EMIOS_0.CH[24].CCR.B.UCPEN = 1;        // 14 Enable Channel Prescaler;
    
 EMIOS_0.MCR.R = 0x14000000;    // enable, start All channels at once   

Outcomes