Hi
I have been using packet mode RX and TX (using DMA) successfully using a CC1110 but need to change to receiving & checking individual bytes because I need to receive data from a different protocol where the packet length doesn't fit the DMA method.
So now I have a interrupt as follows....
#pragma vector=RFTXRX_VECTOR __interrupt void rfbyte_IRQ(void) {
if (sppIntData.mode == SPP_RX_MODE) { byteRcvdFlag = TRUE;
recdByte=RFD; } RFTXRXIF=0;}
.....but this only ever fires once. The correct byte is received (first after the SYNC byte) but no others.
I have tried testing for RX_OVERFLOW etc but no difference. Clearly I am missing something fundamental.
Thanks in advance.
Here is some code you can use to test the RFTXRXIF flag. This code can be tested together with SmartRF Studio as the transmitter (use the recommended 1.2 kBaud setting).
void main(void) { // Choose the crystal oscillator as the system clock and set system clock // speed = fRef (fxosc) CLKCON = CLKCON_26_MHZ_XOSC; // Request switch to crystal oscillator while (CLKCON & OSC_BIT); // Wait until the clock switch has occurred SLEEP |= OSC_PD_BIT; // Power down unused oscillator PKTCTRL0 = 0x05; // packet automation control FSCTRL1 = 0x06; // frequency synthesizer control FREQ2 = 0x21; // frequency control word, high byte FREQ1 = 0x65; // frequency control word, middle byte FREQ0 = 0x6A; // frequency control word, low byte MDMCFG4 = 0xF5; // modem configuration MDMCFG3 = 0x83; // modem configuration MDMCFG2 = 0x13; // modem configuration DEVIATN = 0x15; // modem deviation setting MCSM0 = 0x18; // main radio control state machine configuration FOCCFG = 0x17; // frequency offset compensation configuration FSCAL3 = 0xE9; // frequency synthesizer calibration FSCAL2 = 0x2A; // frequency synthesizer calibration FSCAL1 = 0x00; // frequency synthesizer calibration FSCAL0 = 0x1F; // frequency synthesizer calibration TEST1 = 0x31; // various test settings TEST0 = 0x09; // various test settings PA_TABLE0 = 0x50; // pa power setting 0 IOCFG0 = 0x06; // radio test signal configuration (p1_5) // Infinite loop while (TRUE) { UINT8 i = 0; RFST = STROBE_RX; while (!RFTXRXIF); RFTXRXIF = 0; rxBuffer[i++] = RFD; while (i < rxBuffer[0] + 3 ) { while (!RFTXRXIF); RFTXRXIF = 0; rxBuffer[i++] = RFD; } if (rxBuffer[rxBuffer[0] + 2] & 0x80) packetReceived++; } }
I have tested this and it works. If you get this to work your problem is probably related to the way you set up your interrupts.
BR
Siri
Hi Siri
Many thanks for your reply.
After checking all the regsiters in your sample against my code I find the only differences that have an effect are to do with the packet size. I have PKTCTRL0 as 0x04, i.e. fixed packet size.
I have now tried a variable size and find that all data is received as expected, as long as PKTLEN is defined as longer than the actual packet size transmitted. That's fine and as expected.
If I try a fixed packet size on the transmitter, I seem to get one good packet received but no more; subsequently I just get one byte and no further RFTXRXIF assertions (whatever the packet size is defined as).
I am trying to receive packets from an older CC1010 system and I don't know what the packet size is going to be before I receive part of it. The size is not defined in the first byte after SYNC, as it would be for a CC1110 packet (the size is actually in the 3rd byte, the first byte is the destination address of the packet).
Is it the case that, even when receiving data in a 'byte-by-byte' mode (i.e. not using DMA for packets) , that the receiver will still attempt to collect 'x' bytes before RFTXRXIF is asserted, where x is either the first byte of the packet (variable length mode) or the number of bytes defined by PKTLEN (fixed length mode)? In other words, is there any way I can set this up to receive (and interrogate) just three bytes of a packet, without knowing the packet size or waiting for an arbitrarily long packet to arrive?
If not, this gives me a problem because I need to send an acknowledgement within a short time of receiving the packet. If the packet is small then the originator of the packet will time out waiting for this acknowledgement. (The orginator of the packet is using the 'SImple Packet Protocol' which was example code for the CC1010.)
Best regards
Chris
Assume you want to receive the following packet:
Preamble - sync - x - x - Length n - data_1 - data_2 - ... - data_n-1 - data_n - CRC - CRC
On the receiver you should use fixed packet length and set packet length to a high number. Then you can run the following code:
while (TRUE) {
UINT8 i = 0; RFST = STROBE_RX; while (i < 3 ) { while (!RFTXRXIF); RFTXRXIF = 0; rxBuffer[i++] = RFD; } PKTLEN = rxBuffer[2] + 3; while (i < rxBuffer[2] + 5 ) { while (!RFTXRXIF); RFTXRXIF = 0; rxBuffer[i++] = RFD; } if (rxBuffer[rxBuffer[2] + 4] & 0x80) packetReceived++;
}
It is here assumed that CRC calculation is enabled together with append status.
Brilliant, this has solved it. I never thought to change PKTLEN on the fly like this.
I now have CC1010 talking to CC1110 with the orginal 'SPP' protocol.
Many thanks