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.

PER TEST code explanation

Other Parts Discussed in Thread: CC1200

Hi, I would like to reuse some chunks of code from PER TEST software (www.ti.com/.../swru296b.pdf) but some points are unclear to me

File cc120x_per_test_api.c
Receiver code includes this block

/* The RX FIFO is not empty, process contents */ 
cc120xSpiReadRxFifo(&rxLength, 1); 
/* Check that the packet length just read + status bytes(2B) + length byte match the RXBYTES */
/* If these are not equal:
* - Packet is not like expected
*/
if(rxBytes != (rxLength+3))
{
/* This is a fault FIFO condition -> clean FIFO and register a sync detection */
/* IDLE -> FLUSH RX FIFO -> RX */
perCC120xRxIdle(); 
perCC120xEnterRx(); 
/* Report that a sync was detected */
rxData_tmp.rssi = perCC120xRead8BitRssi();
return;

Questions:

1. if(rxBytes != (rxLength+3))

Is this checking have the same meaning as below from cc120x_easy_link_rx.c:

// Read marcstate to check for RX FIFO error
cc120xSpiReadReg(CC120X_MARCSTATE, &marcStatus, 1);

// Mask out marcstate bits and check if we have a RX FIFO error
if((marcStatus & 0x1F) == RX_FIFO_ERROR){

So is it just another way of RX FIFO error checking?


2. Comment below mentions FLUSH RX FIFO. But I do not see explicit function like trxSpiCmdStrobe(CC120X_SFRX) inside perCC120xRxIdle()and perCC120xEnterRx():

/* This is a fault FIFO condition -> clean FIFO and register a sync detection */
/* IDLE -> FLUSH RX FIFO -> RX */
perCC120xRxIdle(); 
perCC120xEnterRx();

/*******************************************************************************
* @fn perCC120xRxIdle
*
* @brief Radio state is switched from RX to IDLE
*
* input parameters
*
* @param none
*
* output parameters
*
* @return void
*/ 
static void perCC120xRxIdle(void)
{
/* Disable pin interrupt */
trxDisableInt();
/* Strobe IDLE */
trxSpiCmdStrobe(CC120X_SIDLE); 
/* Wait until chip is in IDLE */
while(trxSpiCmdStrobe(CC120X_SNOP) & 0xF0);
/* Clear pin interrupt flag */
trxClearIntFlag();
return;
}

/*******************************************************************************
* @fn perCC120xIdleRx
*
* @brief Radio state is switched from Idle to RX. Function assumes that
* radio is in IDLE when called. 
* 
* input parameters
*
* @param none
*
* output parameters
*
* @return void
*/ 
static void perCC120xIdleRx(void)
{
trxClearIntFlag();
trxSpiCmdStrobe(CC120X_SRX);
trxEnableInt();
return;
}
/*******************************************************************************

How FIFO cleaning is implemented here?

  • Hi Oleg

    1) Yes this will be the same as checking the marcstate and I recommend using the marcstate approach.

    2) Your observations are correct. There should be a SFRX strobe flushing the FIFO in this case. I suspect the reason why this is not the case is because the check here is redundant. The application already filters the packets on both address and length so the if statement will never be true for this application. So this if check should actually be removed from the code. I suspect that when the address and length filtering was implemented this if statement where overlooked.
  • Hi, Martin

    In case there is no total filtering:
    I want to compose RX subroutine with exhaustive possible error checking. Is the RX_FIFO_ERROR the only error state at this point? May be it would be better to check MARC_STATE for the only expected state?
    Not to use
    if((marcStatus & 0x1F) == RX_FIFO_ERROR)
    But rather
    if((marcStatus & 0x1F) != RIGHT_STATE)
    { error handling…
    I.e. any other state instead of expected one will mean Error and code will force CC1200 to IDLE and FLUSH RX FIFO then.

  • Hi

    The RX and TX FIFO_ERROR are the only states that the radio can be stuck in. All other states in the MARC_STATE are intermediate settling states, so depending on your application you could read out other states while you for instance are transitioning between IDLE and RX/TX or between RX to TX.

    the FIFO_ERROR states are the only states that require handling by the application