This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

How to generate two synchronous/reverse phase PWM signals for CC254X?

I tried to generate two PWM signals to control the buzzer, but got the same waveforms:

 

My source code is:

#include "hal_mcu.h"
#include "buzzer.h"


/** \brief	Initialize buzzer
*
* This will initialize the buzzer
*
*/
void buzzerInit(void)
{
#if defined ( CC2540_MINIDK )
    // Buzzer connected at P1_6
    // We will use Timer 3 Channel 0 at alternate location 2
    // Channel 0 will toggle on compare with 0 and counter will
    // count in up/down mode to T3CC0.
  
    P1DIR |= 0x40;              // P1_6 = output
    P1SEL &= ~0x40;
    P1_6 = 0;
    P1DIR |= 0x80;              // P1_7 = output
    P1SEL &= ~0x80;
    P1_7 = 1;

    PERCFG |= 0x20;             // Timer 3 Alternate location 2
    P1SEL |= 0x40;              // Peripheral function on P1_6
    P1SEL |= 0x80;              // Peripheral function on P1_7

    T3CTL &= ~0x10;             // Stop timer 3 (if it was running)
    T3CTL |= 0x04;              // Clear timer 3
    T3CTL &= ~0x08;             // Disable Timer 3 overflow interrupts
    T3CTL |= 0x03;              // Timer 3 mode = 3 - Up/Down

    T3CCTL0 &= ~0x40;           // Disable channel 0 interrupts
    T3CCTL0 |= 0x04;            // Ch0 mode = compare
    T3CCTL0 |= 0x10;            // Ch0 output compare mode = toggle on compare
    T3CCTL1 &= ~0x40;           // Disable channel 1 interrupts
    T3CCTL1 |= 0x04;            // Ch1 mode = compare
    T3CCTL1 |= 0x10;            // Ch1 output compare mode = toggle on compare
#endif
}

/** \brief	Starts the buzzer
*
* Starts the buzzer with given frequency
*
* \param[in]       frequency
*     The frequency in Hertz of the sound to output
* @return  1 successful - 0 if frequency invalid
*/
uint8 buzzerStart(uint16 frequency)
{
#if defined ( CC2540_MINIDK )
    buzzerInit();
  
    uint8 prescaler = 0;

    // Get current Timer tick divisor setting
    uint8 tickSpdDiv = (CLKCONSTA & 0x38)>>3;

    // Check if frequency too low
    if (frequency < (244 >> tickSpdDiv)){   // 244 Hz = 32MHz / 256 (8bit counter) / 4 (up/down counter and toggle on compare) / 128 (max timer prescaler)
        buzzerStop();                       // A lower tick speed will lower this number accordingly.
        return 0;
    }

    // Calculate nr of ticks required to achieve target frequency
    uint32 ticks = (8000000/frequency) >> tickSpdDiv;      // 8000000 = 32M / 4;

    // Fit this into an 8bit counter using the timer prescaler
    while ((ticks & 0xFFFFFF00) != 0)
    {
        ticks >>= 1;
        prescaler += 32;
    }

    // Update registers
    T3CTL &= ~0xE0;
    T3CTL |= prescaler;
    T3CC0 = (uint8)ticks;
    T3CC1 = (uint8)ticks;

    // Start timer
    T3CTL |= 0x10;
#endif
    
    return 1;
}

/** \brief	Stops the buzzer
*
* Turn off the buzzer
*
*/
void buzzerStop(void)
{
#if defined ( CC2540_MINIDK )
    T3CTL &= ~0x10;             // Stop timer 3
    P1SEL &= ~0x40;
    P1_6 = 0;
    P1SEL &= ~0x80;
    P1_7 = 0;
#endif
}


So, how can I generate two synchronous/reverse phase PWM signals for CC254X? Thanks!