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.

MSP430FR2475: Timer interrupt not working

Part Number: MSP430FR2475

Hi All,

I am working on a lora project, my requirement is after sending data, if tx is not done,  i want to wait util time out is reached. for this after send the data i called timer, i am waiting in my while loop to check timer interrupt is executed or not.  even i checked TAR register is populated and working fine. After overflow of TCCR0  Timer interrupt is not working. below is my sample code

Timer Code:

void TIMER_INIT(void)
{
TA1CCR0 = 0; //Initially, Stop the Timer
TA1CCTL0 |= CCIE; //Enable interrupt for CCR0.
TA1CTL = TASSEL_2 + ID_0 + MC_1; //Select SMCLK, SMCLK/1 , Up Mode
}

#pragma vector = TIMER1_A0_VECTOR
__interrupt void Timer_A (void)
{
OFCount++;
if(OFCount >= 200)
{
sx1262.rf_reach_timeout=1;
OFCount = 0;
}
}

TX code:

void Tx_Start(uint8_t *txbuf,uint8_t payload_length)
{
SetStandby(1);//0:STDBY_RC; 1:STDBY_XOSC
SetBufferBaseAddress(0,0);//(TX_base_addr,RX_base_addr)
WriteBuffer(0,txbuf,payload_length);//(offset,*data,length)
SetPacketParams(payload_length);//PreambleLength;HeaderType;PayloadLength;CRCType;InvertIQ
SetDioIrqParams(TxDone_IRQ);//TxDone IRQ

//Define Sync Word value
SetTx(0);//timeout = 0
Sx1262_Flag.is_tx = 1; //Launch logo and launch indicator
TIMER_INIT();
TA1CCR0 = 1000-1;
Sx1262_Flag.rf_timeout = 0;
Sx1262_Flag.rf_reach_timeout = 0; //Send timeout flag cleared
//Wait for the IRQ TxDone or Timeout
while(!RF_IRQ())
{

if(Sx1262_Flag.rf_reach_timeout) //Reset the module when sending timeout
{
uart_write("RF Time out...\n");
ClearIrqStatus(TxDone_IRQ);//Clear the IRQ TxDone flag
SetStandby(1);//0:STDBY_RC; 1:STDBY_XOSC
reset_sx1262(); //reset RF
sx1262_Config();
break;
}
Sx1262_Flag.Irq_Status = GetIrqStatus();
if(TxDone_IRQ&Sx1262_Flag.Irq_Status)break; 
}
Sx1262_Flag.Irq_Status = GetIrqStatus();
ClearIrqStatus(TxDone_IRQ);//Clear the IRQ TxDone flag
}

pls suggest.

Thanks in Advance.

  • Hi Vinod Kumar,

    I would recommend not setting TA1CCR to 0 in your timer init and instead set it to the 999 value, then when you configure the timer you can use the TACLR mask to clear the timer. You can place a breakpoint inside of the TimerA ISR to see if you ever reach it.

    See msp430fr267x_TA0_16.c for an example.

    Regards,

    Luke

  • Hi Luke,

    Thanks for your quick response.

    As you suggested, i made changes to the code, still Timer interrupt is not executing. 

    my simple requirement is i want to break while loop, based on the timer interrupt flag.

    Current issue is when while loop executing, timer interrupt is not working.

    please suggest.

    Regards,

    Vinod

  • Hi Vinod,

    I assume you've already put the breakpoint in the Timer ISR and you aren't getting there. I do see in your code you have this sx1262.rf_reach_timeout and a Sx1262_Flag.rf_timeout. Although they look similar I'm guessing there is something in the background that is changing this variable to set them equal to each other. I would also expect them to be global to prevent any scope issues. 

    Can you place a breakpoint after the TimerInit() and check the TimerA registers in the register view? I want to verify that all the registers got updated with the appropriate values and that the TA1CCR0 is getting correctly set to 999. What can happen is when the value of TA1CCR0 is initially set to 0 it causes conflict with the count as there is nothing to count to and the interrupt never triggers because the value never gets reset.

    Regards,

    Luke

**Attention** This is a public forum