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.

CC1200EMK-868-930: Problems receiving all of my sent data dependent on the packet length

Part Number: CC1200EMK-868-930
Other Parts Discussed in Thread: CC1200

Hi,

I am using an ST Nucleo microcontroller to configure and use a CC1200 EM to transmit data to another CC1200EM chip connected to a TrxEB board that is using SmartRF to decode the packets. Depending on which fixed packet length size that I am using, I get more or less of the total data that I am sending. I am using a fixed packet length configuration.

For example, I am sending packet that just have values that count from 0 to 255. If I use a packet of length 6, I only get data from 0 to 114 (19 packets total, expecting ~42 packets). When I use packets of length 15, I get all of the data. And when I use other lengths in between or more than 15, I do not get all of my data. In SmartRF, it looks like the packets with values greater than a certain point (114 in the case of packets of length 6) never get sent or just can't be received for some reason. 

My application uses packets of smaller size (less than 10 bytes per packet) and the packets are all the same size, so I want them configured to fixed length size. Is this a known issue or is there some configuration that I am missing to make sure all of my data gets sent. I check for errors by using the command strobe registers and making sure that I got back into transmit mode in the case of TX FIFO errors. 

  • Hi

    I took the cc120x_easy_link example from and modified it as shown below:

    #define ISR_ACTION_REQUIRED 1
    #define ISR_IDLE            0
    
    #define PKTLEN              6
    #define GPIO3               0x04
    #define GPIO2               0x08
    #define GPIO0               0x80
    
    static uint8  packetSemaphore;
    static uint32 packetCounter, countValue = 0;
    
    static void initMCU(void);
    static void registerConfig(void);
    static void runTX(void);
    static void createPacket(uint8 randBuffer[]);
    static void radioTxISR(void);
    static void updateLcd(void);
    static void waitUs(uint16 uSec);
    static void waitMs(uint16 mSec);
    
    void main(void) {
    
        uint8 writeByte;
        
        // Initialize MCU and peripherals
        initMCU();
    
        // Write radio registers
        registerConfig();
        
        writeByte = 0x00; // Fixed Packet Lenght
        cc120xSpiWriteReg(CC120X_PKT_CFG0, &writeByte, 1);
        
        writeByte = PKTLEN; // length = PKTLEN
        cc120xSpiWriteReg(CC120X_PKT_LEN, &writeByte, 1);
    
        // Enter runTX, never coming back
        runTX();
    }
    
    static void runTX(void) {
        // Initialize packet buffer of size PKTLEN + 1
        uint8 txBuffer[PKTLEN] = {0};
    
        // Connect ISR function to GPIO2
        ioPinIntRegister(IO_PIN_PORT_1, GPIO2, &radioTxISR);
    
        // Interrupt on falling edge
        ioPinIntTypeSet(IO_PIN_PORT_1, GPIO2, IO_PIN_FALLING_EDGE);
    
        // Clear ISR flag
        ioPinIntClear(IO_PIN_PORT_1, GPIO2);
    
        // Enable interrupt
        ioPinIntEnable(IO_PIN_PORT_1, GPIO2);
    
        // Update LCD
        updateLcd();
    
        // Infinite loop
        while(TRUE)
        {
            // Update packet counter
            packetCounter = 0;
            countValue = 0;
            
            while(!bspKeyPushed(BSP_KEY_ALL)); 
            
            while (packetCounter++ < (256/PKTLEN)) {
                for(uint8 i = 0; i < PKTLEN; i++) {
                    txBuffer[i] = countValue++;
                }
                
                cc120xSpiWriteTxFifo(txBuffer, sizeof(txBuffer));
    
                trxSpiCmdStrobe(CC120X_STX);
    
                while(packetSemaphore != ISR_ACTION_REQUIRED);
    
                packetSemaphore = ISR_IDLE;
            
                updateLcd();
                waitMs(100);
            }
        }
    }
    
    static void radioTxISR(void) {
    
        // Set packet semaphore
        packetSemaphore = ISR_ACTION_REQUIRED;
    
        // Clear ISR flag
        ioPinIntClear(IO_PIN_PORT_1, GPIO2);
    }
    
    static void initMCU(void) {
    
        // Init clocks and I/O
        bspInit(BSP_SYS_CLK_8MHZ);
    
        // Init LEDs
        bspLedInit();
    
        // Init buttons
        bspKeyInit(BSP_KEY_MODE_POLL);
    
        // Initialize SPI interface to LCD (shared with SPI flash)
        bspIoSpiInit(BSP_FLASH_LCD_SPI, BSP_FLASH_LCD_SPI_SPD);
    
        // Init LCD
        lcdInit();
    
        // Instantiate transceiver RF SPI interface to SCLK ~ 4 MHz
        // Input parameter is clockDivider
        // SCLK frequency = SMCLK/clockDivider
        trxRfSpiInterfaceInit(2);
    
        // Enable global interrupt
        _BIS_SR(GIE);
    }
    
    static void registerConfig(void) {
    
        uint8 writeByte;
    
        // Reset radio
        trxSpiCmdStrobe(CC120X_SRES);
    
        // Write registers to radio
        for(uint16 i = 0;
            i < (sizeof(preferredSettings)/sizeof(registerSetting_t)); i++) {
            writeByte = preferredSettings[i].data;
            cc120xSpiWriteReg(preferredSettings[i].addr, &writeByte, 1);
        }
    }
    
    static void updateLcd(void) {
    
        // Update LDC buffer and send to screen.
        lcdBufferClear(0);
        lcdBufferPrintString(0, "EasyLink Test", 0, eLcdPage0);
        lcdBufferSetHLine(0, 0, LCD_COLS-1, 7);
        lcdBufferPrintString(0, "Sent packets:", 0, eLcdPage3);
        lcdBufferPrintInt(0, packetCounter, 70, eLcdPage4);
        lcdBufferPrintString(0, "Packet TX" , 0, eLcdPage7);
        lcdBufferSetHLine(0, 0, LCD_COLS-1, 55);
        lcdBufferInvertPage(0, 0, LCD_COLS, eLcdPage7);
        lcdSendBuffer(0);
    }
    
    #pragma optimize=none
    static void waitUs(uint16 uSec) { // 5 cycles for calling
    
        // The least we can wait is 3 usec:
        // ~1 usec for call, 1 for first compare and 1 for return
        while(uSec > 3) {  // 2 cycles for compare
                           // 2 cycles for jump
            NOP();         // 1 cycle for nop
            NOP();         // 1 cycle for nop
            NOP();         // 1 cycle for nop
            NOP();         // 1 cycle for nop
            NOP();         // 1 cycle for nop
            NOP();         // 1 cycle for nop
            NOP();         // 1 cycle for nop
            NOP();         // 1 cycle for nop
            uSec -= 2;     // 1 cycle for optimized decrement
        }
    }                      // 4 cycles for returning
    
    #pragma optimize=none
    static void waitMs(uint16 mSec) {
        while(mSec-- > 0) {
            waitUs(1000);
        }
    }
    

    I used SmartRF Studio in fixed packet length mode, and were able to receive all packets.

    BR

    Siri

    link