Hello
I'm havin the following problem. My device is supposed to listen to traffic and when receiving a message react to it and respond.
At the momemt it's able to do this but after send a reply it won't accept any further incoming messages.
The scanario is as following:
-interrupt routine listens for incoming data.
- once data is received it's stored in a global array
- the main function polls the array and handles it accordingly by send an appropriate response by calling the send function
- the send function prepares the packet and calls the transfer function which send the packet.
- loop repeats itself, though with the problem being that after the transfer it won't accept any further data (doesn't invoke the interrupt)
I've narrowed the problem down to it being related to the following lines in the end of the transfer function:
while(!(RF1AIFG & BIT9));
RF1AIFG &= ~BIT9;
If these are left out it continously accept data but without transmitting it. This is probably a "simple task" where some flag is left active.
Unfortunately my skills are limited and haven't managed to solve the issus. Any help would be highly appreciated!
Best regards Richard Salin
ps. The device calls ReceiveOn in the beginning so that's it's initial state.
#pragma vector=CC1101_VECTOR
__interrupt void CC1101_ISR(void)
{
switch(__even_in_range(RF1AIV,32)) // Prioritizing Radio Core Interrupt
{
case 20:
// If device isn't tranmitting -> receive // RFIFG9
if(!transmitting){ // RX end of packet
RxBufferLength = ReadSingleReg( RXBYTES );
// Check packet size
if(RxBufferLength>50){
ReadBurstReg(RF_RXFIFORD, RxBuffer, RxBufferLength);
// store length to array
for(i=1;i<RxBufferLength-3;i++){
uip_buf[i-1] = RxBuffer[i];
}
// set received size (subtract length & status bytes)
uip_length=RxBufferLength-4;
// Flush buffer
ReceiveOff();
ReceiveOn();
}
}
else if(transmitting) // TX end of packet
{
RF1AIE &= ~BIT9; // Disable TX end-of-packet interrupt
transmitting = 0;
}
else while(1); // trap
break;
}
}
void cc430_send(void)
{
transmitting = 1;
TxBuffer[0] = 55;
for(u=0;u<54;u++){
TxBuffer[u+1] = uip_buf[u];
}
for(u=0;u<55;u++){
while (!(UCA0IFG&UCTXIFG)); // Wait for TX buffer ready to receive new byte
UCA0TXBUF = TxBuffer[u]; // Output character
for(j=0;j<1000;j++);
}
ReceiveOff();
Transmit( (unsigned char*)TxBuffer, 54);
ReceiveOn();
transmitting = 0;
return;
}
void Transmit(char *buffer, unsigned char length)
{
while (!(UCA0IFG&UCTXIFG)); // Wait for TX buffer ready to receive new byte
UCA0TXBUF = length;
/* Wait for radio to be ready for next instruction */
while( !(RF1AIFCTL1 & RFINSTRIFG));
/* Write cmd: TXFIFOWR */
RF1AINSTRB = 0x7F;
while(length){
/* Wait for radio to be ready to accept the data */
while( !(RF1AIFCTL1 & RFDINIFG) );
/* Write one byte to FIFO */
RF1ADINB = *buffer;
buffer++;
length--;
}
Strobe( RF_STX ); // Strobe STX
// THIS LINE IS THE PROBLEM. WHEN CALLED THE DEVICES STOPS SENDING, BUT IF NOT IT DOESN'T TRANSMIT THE PACKET
while(!(RF1AIFG & BIT9));
RF1AIFG &= ~BIT9;
}
void ReceiveOn(void)
{
// PA
P3OUT |= 0x40; // Set RX
P1OUT &= ~0x1; // Clear TX
RF1AIES |= BIT9; // Falling edge of RFIFG9
RF1AIFG &= ~BIT9; // Clear a pending interrupt
RF1AIE |= BIT9; // Enable the interrupt
// Radio is in IDLE following a TX, so strobe SRX to enter Receive Mode
Strobe( RF_SRX );
}
void ReceiveOff(void){
P3OUT &= ~0x40; // Clear RX
P1OUT |= 0x01; // Set TX
RF1AIE &= ~BIT9; // Disable RX interrupts
RF1AIFG &= ~BIT9; // Clear pending IFG
Strobe( RF_SIDLE );
Strobe( RF_SFRX );
}