I have a similar application to this thread but I'm having a hard time getting it to work
I started from the PER example and have modified it to run in basic fixed length mode. I have 4 transmitters that send are synchronized such that a new message is generated every 250us in a round robin fashion... which means the receiver has to receive a new message every 250us (4 times a msec)
I have attempted to turn leave the synthesizer on, set the frequency control register directly and turned repeat on but I seem to be missing something because the setup seems to receive 1 or nothing depending on what the setup is. Note i can set PRF.TASK_CONF.REPEAT = 0 and I can receive packets but the reception is sporadic and can't seem to keep up.
Here is my modified PER receive code, and a few specific questions... but also curious if you see any errors in the code below
- should i let the receiver start up once with PRF.CHAN.SYNTH = 0 to allow the synth to calibrate once? This would require me to set PRF.CHAN.SYNTH = 1 after the first TX_DONE?
- does halRfStartRx() need to be called each time around the loop or just once at the start?
void remoteRxMode(void)
{
// Variables for RSSI, packet sequence, statistics, etc...
uint32 packetSeq = 0, idx = 0;
int8 rssi[8] = {0,0,0,0,0,0,0,0}, rssi_new = 0;
int16 rssi_sum = 0,rssi_avg = 0;
uint32 okPackets = 0, crcPackets = 0, lostPackets = 0, tmp, testTime;
static uint8 pktData[50];
static uint8 pktLen;
static uint8 res;
static bool configSynth = true;
// Clear and update LCD display.
halLcdClear();
halLcdWriteLine(1, c2xd(text_Remote_Mode));
// Setup the radio with the received configuration.
halRfDisableRadio(FORCE);
halRfInit();
halRfConfig( modulation, RX, sync_word_len, PKT_CONF_MODE_BASIC_FIXLEN );
//halRfSetCrc(CRC_16_CCITT);
halRfSetSyncWord( sync_word, 0);
halRfSetRxAddress(0, ADDR_CONF_RX_BASIC_SW1, 0xAA, (packet_length));
//halRfSetFrequency(frequency);
/* setup the packet handling */
PRF.FIFO_CONF.AUTOFLUSH_CRC = 0; // Do Not Flush packets with CRC error
PRF.FIFO_CONF.RX_STATUS_CONF = 1; // add the status to the end of the packet reception
/* for the synthesizer to stay on and ensure that the frequency is set properly */
PRF.CHAN.SYNTH_ON = 1; // leave the synthesizer on after task ends
PRF.CHAN.FREQ = 127;
FREQCTRL = frequency-2379;
/* setup restarting the task */
//PRF.TASK_CONF.START_CONF = 0; // Start immediately after command.
//PRF.TASK_CONF.REPEAT_CONF = 1; // Start immediately after command.
//PRF.TASK_CONF.REPEAT = 1; // repeat the task when done
/* Set timeout value (total test time + 1 second in margin) to end test when done. */
// testTime = (10*(packets)) + 1000;
// halTimer2SetRadioTimeout(testTime, SINGLE);
// halTimer2Start(0); // Start timer 2 (asynchronous).
halRfEnableRadio();
// Enable RF interrupt.
halRfEnableInterrupt(RFIRQF1_TASKDONE);
// Enable global interrupt.
halIntOn();
while(1 /*okPackets < packets*/)
{
// Start receiver.
halRfStartRx();
// Wait for TASKDONE and halt CPU (PM0) until task is completed.
while (!(rfirqf1 & RFIRQF1_TASKDONE));
// Check if task ended correctly
if(PRF.ENDCAUSE == TASK_ENDOK)
{
// Check if packet was received.
if(rfirqf1 & RFIRQF1_RXOK)
{
// Check if packet length is as expected.
pktLen = RFD;
if (packet_length == pktLen)
{
...
}
halRfCommand(CMD_RXFIFO_RESET);
}
else if (rfirqf1 & RFIRQF1_RXNOK)
{
halRfCommand(CMD_RXFIFO_RESET);
crcPackets++;
}
else
{
// Write end cause error code to screen.
}
}
// Check if test time has expired or last packet is received.
if (PRF.ENDCAUSE == TASK_RXTIMEOUT)
{
lostPackets++;
}
// Clear the global RFIRQF1 shadow variable (RF Interrupt flags).
rfirqf1 = 0;
// Set to a undefined value in enum type end cause.
PRF.ENDCAUSE = TASK_UNDEF;
}
/* Disable interrupts enabled in this function, clear timer 2 and return. */
// Disable global interrupt.
halIntOff();
// Reset Timer2.
halTimer2Reset();
// Disable RF interrupt.
halRfDisableInterrupt(RFIRQF1_TASKDONE);
}