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.

MSP430I2020: can TA0,TA1 work together?

Part Number: MSP430I2020
Other Parts Discussed in Thread: MSP-FET, MSP430FR5992

Hi,

below is my timer initial code.

I need a 1ms interrupt and 1 ch PWM output.

but if I start TA0, TA1 will stop. If I start TA0, TA1 will stop.

Pls help resolve it.

TA0CCTL0 = CCIE; // CCR0 Interrupt Enabled
TA0CCR0 = 2047;
TA0CTL = TASSEL_2 | MC_1 | ID_3; 

P2SEL0 |=  BIT2; 
P2DIR |= BIT2;
TA1CCR0 = 1;
TA1CCTL2 = OUTMOD_4 ;
TA1CTL = TASSEL_2 | MC_1 | ID_1; 

  • Hi,

    TA0 and TA1 should work independently. 

    I do not find issues in the initial code. Could you send more code about how you start the timer?

    Best regards,

    Cash Hao

  • #define TIME_1ms                 ((__SYSTEM_FREQUENCY_HZ__ / 8000) - 1)
    #define PWM_1024KHz                 ((__SYSTEM_FREQUENCY_HZ__ / 8000000) - 1)
    //#define TIME_1ms                 2000
    #define StartTimer0()                 TA0CTL = TASSEL_2 | MC_1 | ID_3
    #define StartTimer1()                 TA1CTL = TASSEL_2 | MC_1 | ID_1
    
    #include <Timer.h>
    
    uint8_t  _1msFlag;
    uint32_t  _1msCnt;
    
    void InitTimer(void)
    {
        TA0CCTL0 = CCIE;                    // CCR0 Interrupt Enabled
        TA0CCR0 = TIME_1ms;
        //TA0CTL = TASSEL_2 | MC_1 | ID_3;    // SMCLK/8, Up Mode
    /* P2.2 = 2.048MHz PWM output */
    
        P2SEL1 =0;
        P2SEL0 |= BIT2;                    // P2.2 CCRx Function
        P2DIR  |= BIT2;                    // Set P2.2 as output
        TA1CCR0 = 1;
        TA1CCTL2 = OUTMOD_4;                // CCR1 Toggle/set
    
    }
    
    #pragma vector = TIMER0_A0_VECTOR
    __interrupt void Timer0_A0_ISR(void)
    {
        _1msCnt++;
        _1msFlag=1;
    }
    
    void InitPeripheral(void){
        REFCAL1 = FlashTlv[TLV_CAL_REFCAL1];
        REFCAL0 = FlashTlv[TLV_CAL_REFCAL0];
        CSIRFCAL = FlashTlv[TLV_CAL_CSIRFCAL]+4;
        CSIRTCAL = FlashTlv[TLV_CAL_CSIRTCAL];
        SD24TRIM = FlashTlv[TLV_SD24_TAG];
        CSCTL0  =  0;                   // Internal Resistor
        CSCTL1 =  0;   // MCLK = DCO, SMCLK = DCO
        //P1SEL1 |=    BIT1;        // MCLK, SMCLK Pin Function
        //P1SEL0 &= ~(BIT1);
        GPIO_init();
        InitTDS();
        //InitPWG();
        InitModbus();
        InitTimer();
        //InitData();
        InitPWG();
        TaskStep=TASK_INITIAL;TaskT=0;
        StartTimer0();
    }
    void InitData(void)
    {
        Flash_I *FlashT;
        uint16_t  i, DataValid=1;
    
        FlashT = (Flash_I*)(FlashBuf);
        InitFlash();
        FlashReadAll();
        for (i=1; i < TDS_CH_MAX; i++){
            if ((FlashT->TDS_CalKF[i] > MAX_TDS_CalK) || (FlashT->TDS_CalKF[i] < MIN_TDS_CalK)){
                FlashT->TDS_CalKF[i]=DEF_TDS_CalK;
                DataValid=0;
            }
        }
        for (i=1; i < TDS_CH_MAX; i++){
            if ((FlashT->TDS_CalKF[i] > MAX_TDS_CalK) || (FlashT->TDS_CalKF[i] < MIN_TDS_CalK)){
                FlashT->TDS_CalKF[i]=DEF_TDS_CalK;
                DataValid=0;
            }
        }
    
    }
    
    void CheckCalRange(void){
        TaskStep=TASK_MEAS_TDS;TaskT=0;
    }
    
    void Process_Task(void){
        if (TaskT) TaskT--;
        else{
            switch (TaskStep){
                case TASK_INITIAL: // Initial mode
                    TaskStep++;
                    TaskT=100;
                    break;
                case (TASK_INITIAL+1): // Initial mode
                    PWG_On();
                    TaskStep=TASK_MEAS_TDS;
                    TaskT=100;
                    break;
                case TASK_CHECK_CAL:
                    CheckCalRange();
                    break;
                case TASK_MEAS_TDS:
                    TDS_Task();
                    break;
            }
        }
    }
    
    int main(void)
    {
        InitWatchdog(); // Init WDT & Stop WDT
    
        /* Initialization */
        InitPeripheral();
    #ifdef EN_WDT
        StartWatchdog(); // Start WDT
    #endif
        _EINT();     // enable interrupt
    
        while (1)
        {
            if (_1msFlag)
            {
                _1msFlag = 0;
                //P2OUT^=BIT2;
    
                //PWG_Task();
                ModbusRxTask();
                Process_Task();
    
    #ifdef EN_WDT
                FeedWatchdog();
    #endif
            }
        }
    }
    
    

    I start TA1@ other function.

    for previous code,

    I initial TA0 and TA1 in InitTimer(). And it can't work normally.

  • Hi,

    Its issue is similarly dependent on debug tool(MSP-FET) and CCS. When I enter debug mode, TA1 can't work with TA0 and SPI output can affect TA1, too.

    I don't know how to debug it.

    Or this issue is caused by CCS?

    CCS has bugs for some parts?

    I debug MSP430FR5992 by CCS is OK.

  • Hi,

    The code looks fine. I am not sure if it is related to the CCS. You can find all the known issues for the CCS in the CCS release note.  https://software-dl.ti.com/ccs/esd/CCSv11/CCS_11_2_0/exports/CCS_11.2.0_ReleaseNotes.htm

    Best regards,

    Cash Hao

  • Hi,

    I can't find related issues. I will try to install CCS 11.2 and then retry it.

**Attention** This is a public forum