Hi,
I'm using the CC1120 to send fixed size packets of 20 bytes. I have tried to incorporate listen-before-talk, as well as up to 3 random backoff time retries for each packet. After a few dozen broadcasts, the GPIO0 interrupt signal stays low and I am constantly timing out.
Is there anything else I need to re-arm before trying to resend a packet, or any suggestions as where I might be going wrong? I have pasted in my code below.
void TxPacketRf(uint8_t* data)
{
uint8_t rssi;
uint8_t txBuffer[PKTLEN+1] = {0};
bool complete = false;
uint8_t retries = 3;
packetCounter++;
trxRfSpiInterfaceInit();
txBuffer[0] = PKTLEN;
for(uint8_t i = 1; i < PKTLEN+1; i++)
{
txBuffer[i] = *data++;
}
while((complete == false)&&(retries--))
{
//Write packet to tx fifo
cc112xSpiWriteTxFifo(txBuffer,sizeof(txBuffer));
//Listen-Before_Talk block from here
// Strobe RX
trxSpiCmdStrobe(CC112X_SRX);
// Wait for RSSI to be valid
do
{
cc112xSpiReadReg(CC112X_RSSI0, &rssi, 1);
} while (!(rssi & 0x01));
// Air is free, strobe TX to send packet
trxSpiCmdStrobe(CC112X_STX);
//generate a 10ms (+up to 5ms random) timeout value
uint8_t timeout = 0;
sd_rand_application_vector_get((uint8_t *)&timeout, 1);
timeout = timeout%6; //to get 0-5
timeout+=10; //15 milliseconds
timeout*=10; //150 * 100us = 15ms
while((packetSemaphore != ISR_ACTION_REQUIRED)&&(timeout > 0))
{
nrf_delay_us(100);
timeout--;
}
packetSemaphore = ISR_IDLE;
if(timeout > 0)
{
//packet went
complete = true;
printf("rfsent\n\r");
}
else
{
printf("timed out\n\r");
}
}
}
Thanks