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.

MSP430F529 SPI frequency output using Port 1.4



Dear all,

I'm trying to write a frequency output on my P1.4 pin on the MSP430F529, with the following code :

#define TIMER_PERIOD 511
#define DUTY_CYCLE  350

void main(void)
{
    //Stop WDT
    WDT_A_hold(WDT_A_BASE);

    //P1.4 as PWM output
    GPIO_setAsPeripheralModuleFunctionOutputPin(
        GPIO_PORT_P1,
        GPIO_PIN4
        );

    //Generate PWM - Timer runs in Up mode
    TIMER_A_outputPWMParam param = {0};
    param.clockSource = TIMER_A_CLOCKSOURCE_SMCLK;
    param.clockSourceDivider = TIMER_A_CLOCKSOURCE_DIVIDER_1;
    param.timerPeriod = TIMER_PERIOD;
    param.compareRegister = TIMER_A_CAPTURECOMPARE_REGISTER_1;
    param.compareOutputMode = TIMER_A_OUTPUTMODE_RESET_SET;
    param.dutyCycle = DUTY_CYCLE;
    TIMER_A_outputPWM(TIMER_A1_BASE, &param);

    //Enter LPM0
    __bis_SR_register(LPM0_bits);

    //For debugger
    __no_operation();
}

Using the code with pin 2.0, works pretty well, but with pin 1.4 we have no signal. Looking at the datasheet, should work.

Could you please help me?

Thank you in advance

ip

  • Have a look at the "Terminal Functions" table in the F5529 datasheet. In peripheral module function mode, pin P2.0 is connected to TA1.1. Pin P1.4, however, is connected to TA0.3.

    The code still generates a PWM output on CCR1 of timer A 1.

  • Hello Clems!

    Thank you in advance!

    So how should I modify the code in order to use TA0.3 and not TA1.1?

    Best regards

    ip
  • The first parameter of TIMER_A_outputPWM() specifies which timer module to use.

    The compareRegister field specifies which CCR to use.

  • Thank you Clems! It works pretty well now!

    I modified the registers of the folloging :

    param.compareRegister = TIMER_A_CAPTURECOMPARE_REGISTER_3; ///CCR3
    TIMER_A_outputPWM(TIMER_A0_BASE, &param); ///Timer 0

    After modification, the code stays as the following


    /// So pin 1.4 is sourced on TA0.3, in the following code :
    void main(void)
    {
    //Stop WDT
    WDT_A_hold(WDT_A_BASE);

    //P1.4 as PWM output
    GPIO_setAsPeripheralModuleFunctionOutputPin(
    GPIO_PORT_P1,
    GPIO_PIN4
    );

    //Generate PWM - Timer runs in Up mode
    TIMER_A_outputPWMParam param = {0};
    param.clockSource = TIMER_A_CLOCKSOURCE_SMCLK;
    param.clockSourceDivider = TIMER_A_CLOCKSOURCE_DIVIDER_1;
    param.timerPeriod = TIMER_PERIOD;
    param.compareRegister = TIMER_A_CAPTURECOMPARE_REGISTER_3;
    param.compareOutputMode = TIMER_A_OUTPUTMODE_RESET_SET;
    param.dutyCycle = DUTY_CYCLE;
    TIMER_A_outputPWM(TIMER_A0_BASE, &param);

    //Enter LPM0
    __bis_SR_register(LPM0_bits);

    //For debugger
    __no_operation();
    }

**Attention** This is a public forum