Center Aligned Output PWM MPC5606B

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

Center Aligned Output PWM MPC5606B

1,405 Views
duanemattern
Contributor III

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   

Labels (1)
2 Replies

961 Views
PetrS
NXP TechSupport
NXP TechSupport

Hi,

The configuration looks correct, but on wrong channel. There is no OPWMCB mode on channel 24.

See Figure 24-7 of the MPC5606BRM , which shows the channel configuration of the eMIOS blocks.

Try the same on channels 1 to 7.

BR, Petr

961 Views
duanemattern
Contributor III

I forgot to mention I have the emois [24] on PortE11 setup for alternate function 1 for this output, which is what it was set to for the edge aligned PWM which worked properly.  

0 Kudos