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.

CC2544 continuos receive, lost packets.

Other Parts Discussed in Thread: CC2544

Hello, i am developing a basic UART transmitter by the air (unidirectional), using two CC2544 in basic mode.

I am by the moment, using one of boards to continuosly transmit a packet of 124 bytes (in the future that board should read uart data sent by a external pc and transmit it by the air, but for the moment, for simplify the work, i transmit continuosly a packet with a 124 bytes string)

The code i am using in the TX board is the following:

uint8 packet[]=" 1 CIAPROBANDO1234CIAPROBANDO1234CIAPROBANDO1234CIAPROBANDO1234CIAPROBANDO1234CIAPROBANDO1234CIAPROBANDO1234CIAPROBANDO1234 ";

int main(void) {


halBoardInit();
PDIR=0xFF;

   
    halRfDisableRadio(FORCE);
    halRfInit();
    halRfConfig(GFSK_250kbps_160khz, TX, 32, PKT_CONF_MODE_BASIC_VARLEN); //basic mode
    halRfSetCrc(CRC_16_CCITT);
    halRfSetSyncWord(SYNCWORD, 0);
    halRfSetTxAddress(0xEF, ADDR_CONF_TX_AUTO, 16);
    
    halRfSetFrequency(2402);
    halRfEnableRadio();
    
   
    // Enable RF interrupt.
    halRfEnableInterrupt(RFIRQF1_TASKDONE);
    // Enable global interrupt.
    halIntOn();

    // Load packet payload.
  halRfPrepareTxPacket(124, &packet[0]);

    packet[0]=0x0D;
    packet[1]=0x30; //in this position i put a packet id (0 - 9) in ascii (0x30 = ascii "0")
    packet[2]=0x0D; //0x0D only to send a CR 

    while(1) {

        // Start transmitter.
        halRfStartTx();// This only Send Tx command SEND_LLE_CMD(CMD_TX);


        // Wait for TASKDONE and halt CPU (PM0) until task is completed.
        while (!(rfirqf1 & RFIRQF1_TASKDONE)) {
#if(POWER_SAVING)
            halSleepEnterPowerMode(CPU_HALT);
#endif
        }

        
        if(PRF.ENDCAUSE == TASK_ENDOK) 
             // Clear the global RFIRQF1 shadow variable (RF Interrupt flags).
                    rfirqf1 = 0;
        
SEND_LLE_CMD(CMD_TXFIFO_RESET);

packet[1]++;          //i increment the id of packet (position 1 of the array)
  if(packet[1]==58) //if Id is 58 decimal (9 in ascii), reset to 48 decimal (0 in ascii)
packet[1]=48;
    
halRfPrepareTxPacket(124, &packet[0]); //reload the fifo with new packet
           
    }
 }
    

This code work well.
The problem is with the RX code:

    // Setup the radio with the received configuration.
    halRfDisableRadio(FORCE);
    halRfInit();
    halRfConfig(GFSK_250kbps_160khz, RX, 32, PKT_CONF_MODE_BASIC_VARLEN);
    halRfSetFrequency(2402);
    halRfSetCrc(CRC_16_CCITT);
    halRfSetSyncWord(SYNCWORD, 0);
    halRfSetRxAddress(0, ADDR_CONF_RX_AUTO_SW1, 0xEF, 127);
    halRfEnableRadio();

    // Enable RF interrupt.
    halRfEnableInterrupt(RFIRQF1_TASKDONE);

    // Enable global interrupt.
    halIntOn();

 P1_1=0; //turn off a led i have in P1_1


    while(1) {
      
         halRfStartRx();   // Start receiver. This Send Rx command SEND_LLE_CMD(CMD_RX);

       // Wait in loop for TASKDONE 
      while (!( rfirqf1 & RFIRQF1_TASKDONE));
         
                     
        // if taskdone, Check if task NOT ended correctly
       if(PRF.ENDCAUSE != TASK_ENDOK) 
       {
         
          P1_1=1; //if not ended correctly, turn on led
          while(1); //and freeze the program
      }  
         
          length = RFD; //read the first byte (lenght of packet)
                                   
              for(i=0; i<length; i++)
              {
                buffer[indexIN]=RFD; //here i am saving the payload in a circular buffer of 1500 bytes of size
                indexIN++;
                
                if(indexIN==1500) //if buffer is full, reset the index
                  indexIN=0;
              }
                                   
   // Trigger TX interrupt to start transmitting over the 

uart.
        IEN2 |= IEN2_UTX0IE;
        UTX0IF = 1;
        //clear interrupts
      rfirqf1 = 0;
    
        }
    }

/*********************************************************

**************************
* @fn          UART0_TX_ISR
*
* @brief       Function which completes the UART transmit session, that is it 
*sends the rest of the UART0 packet.
*
* @param       void
*
*/
#pragma vector = UTX0_VECTOR
__interrupt void UART0_TX_ISR(void)
{
    // Clear UART0 TX Interrupt Flag (IRCON2.UTX0IF = 0).
    UTX0IF = 0;
    
   
    
if(indexOUT!=indexIN)
{
      
    U0DBUF = buffer[indexOUT];
    indexOUT++;
    if (indexOUT==1500)
      indexOUT=0;
 
}
    // If no UART byte left to transmit, stop this UART TX session
else
{
    IEN2 &= ~IEN2_UTX0IE;
}        
     
}


When i connect the receiver board to the pc and see the data in hyperterminal, i see i lost packet (viewing the id), i receive completely the packet 1, 3, 5, ( i lost the packet 2 and 4).

If i modify the code and only receive the byte of packet[1] (the id) and transmit it by the uart (without transmit all payload), i can see i receive ALL packets. For this reason i know the transmitter is working ok and the problem is with rx code.

I guess i am lost packets when i am running the following block:

for(i=0; i<length; i++)
{
buffer[indexIN]=RFD;
indexIN++;

if(indexIN==1500
indexIN=0;
}
I guess In that moment are arriving data and i not receive it. I need the radio listening all time. I read in the datasheet about the PRF_TASK_CONF.REPEAT register, but i dont know how use it well.
I tried modifying the code as:

PRF_TASK_CONF.REPEAT = 1; 
  halRfStartRx();   // Start receiver only one time, before the infinite loop, is correct?


while(1) {

// Check if packet was received.

 if((rfirqf1 & RFIRQF1_RXOK)) <--- i this version of code, i see i never enter here 

         {
          length = RFD; //read the first byte (lenght of packet)
                                   
              for(i=0; i<length; i++)
              {
                buffer[indexIN]=RFD; //here i am saving the payload in a circular buffer of 1500 bytes of size
                indexIN++;
                
                if(indexIN==1500) //if buffer is full, reset the index
                  indexIN=0;
              }
              
                      
   // Trigger TX interrupt to start transmitting over the uart.
        IEN2 |= IEN2_UTX0IE;
        UTX0IF = 1;
        //clear interrupts
      rfirqf1 = 0;
    }
        }
    }


This code does nothing, never receive packets with it.

Anyway, please can help me with the rx code so i can receive continuosly data by rf, and put out it trought the uart without lost info?
The final app should work with 2mbps in rf, and SPI instead UART, but for the moment i am triying work with UART and 250kbps for simplest. The final app is to transmit a photo from a nanosatellite to earth, for a project of my university..

Thanks in advance.
Regards,
Darío.

  • Dario, 

    Have you seen this appnote, it does basically that.

    Regards,
    /TA

  • Hi TA, yes, i had read that appnote, and the PER test. In those examples i inspired my code.

    The RX code is basically the same function of appnote. In that appnote, the rx function is named "rf_rx_packet" and have practically the same code as my function.

    Any ideas where is the error in my code? Am i right if i intend in the rx board keep the rf core in RX status continually and read all the time the rxfifo and put its data in a circular buffer, to put then its content in the uart by isr? Or i am thinking bad?

    thanks!