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.