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.

CC2500: Configuration

Part Number: CC2500
Other Parts Discussed in Thread: CC1101

Tool/software:

Hi;

          we need to communicate cc2500 modules with maximum length of the packet size >255 bytes .

          we try multiple methods when we give packet size is >64 all results are similar to like first 64bytes of data only repeat while receiving side of cc2500.

for example 

               packet size : 90Bytes

              Transmit Packet : 90(Packet length),1(Address),ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz012345678999abcdefghijklmnopqrstuvwxyz(pay load _ 90 Bytes)

              Received Packet : 90(Packet length),1(Address),ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz012345678999,1(Address),ABCDEFGHIJKLMNOPQRSTUVWXYZ

           we need help to solve this issue.

  • in receiver side how to receive that 90Bytes!!

    1. Directly get the 90Bytes data by single read burst process.

    2. First get the 64Bytes and after that get the 26Bytes

    3. First get the 64Bytes , get 20Bytes and get 6Bytes

    aforementioned 3 methods which one is correct or any other methods are available?

  • You cannot directly get 90 bytes when the FIFO has only room for 64

    You cannot wait for the FIFO to be full either (64) before you start reading, as it will then overflow.

    As explined in the post I linked to you need to program the FIFO_THR to a value (of your choice).

    If you for example program it to be 14, you know that there are 60 bytes in the RXFIFO when you get an interrupt on the FIFO signal (GDOx_CFG = 0).

    You can then read 59 of those bytes (do not empty the FIFO due to the RX FIFO issue described here: https://www.ti.com/lit/swrz002), and wait for the packet received signal is asserted (GDOx_CFG = 0x06) before you read the reminding byte in the packet (31 + potentially 2 status bytes if you have appended these).

    If you know that you will not receive packets that are longer than 90 byte, you should enable packet length filtering for this length.

    Siri

  • Thanks;

             now i tried the same steps like pseudocode given in the https://www.ti.com/lit/swrz002 but again i did not get the correct data which is transmitted.

            Packet Size : 90Bytes

         Txd Data  : 89(Packet length), ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz01234567890123456789:;<=>?@ABCDEFGHIJ

         Rxd Data : xZabcdefghijklmnopqrstuvwxyz01234567890123456789:;<=>?@ABCDEFGHIJZabcdefghijklmnopqrstuvw

    uint16_t CC2500_ReceivePacket_Polling(char *buffer, uint16_t maxLength)
    {
                uint16_t bytesReceived = 0;
                uint8_t rxBytes;
                bool Receive_Done = 0;

                 // Enter RX state
                 TI_CC_SPIStrobe(TI_CCxxx0_SRX);

                while (Receive_Done == 0)
                {
                           rxBytes = TI_CC_SPIReadReg(TI_CCxxx0_RXBYTES) & 0x7F;

                          if (rxBytes > 0)
                          {
                                  uint8_t bytesToRead = (rxBytes > (maxLength - bytesReceived)) ? (maxLength - bytesReceived) : rxBytes;
                                  bytesToRead -= 1;

                                   if (bytesToRead > 0)
                                   {
                                          TI_CC_SPIReadBurstReg(TI_CCxxx0_RXFIFO, &buffer[bytesReceived], bytesToRead);
                                          bytesReceived += bytesToRead;
                                   }
                                   if(bytesToRead == 0)
                                   {
                                          Receive_Done = 1;
                                   }
                        }
                }

                *buffer++ = TI_CC_SPIReadReg(TI_CCxxx0_RXFIFO);

                 return bytesReceived;
    }

    void CC2500_TransmitPacket_Polling(char *data, uint16_t length)
    {
                 uint16_t bytesLeft = length;
                 uint16_t currentIndex = 0;
                 uint8_t bytesToWrite;

                  // Enter idle mode
                  TI_CC_SPIStrobe(TI_CCxxx0_SIDLE);

                  // Flush TX FIFO
                  TI_CC_SPIStrobe(TI_CCxxx0_SFTX);

                  // Start transmission
                  TI_CC_SPIStrobe(TI_CCxxx0_STX);

                 // Write first chunk to FIFO
                 bytesToWrite = (bytesLeft > 64) ? 64 : bytesLeft;
                 TI_CC_SPIWriteBurstReg(TI_CCxxx0_TXFIFO, &data[currentIndex], bytesToWrite);
                 currentIndex += bytesToWrite;
                 bytesLeft -= bytesToWrite;

                 // Continue filling FIFO as space becomes available
                while (bytesLeft > 0)
                {
                       uint8_t txBytes = TI_CC_SPIReadReg(TI_CCxxx0_TXBYTES);
                       uint8_t spaceAvailable = 64 - txBytes;

                       if (spaceAvailable > 0)
                       {
                                bytesToWrite = (bytesLeft > spaceAvailable) ? spaceAvailable : bytesLeft;
                                TI_CC_SPIWriteBurstReg(TI_CCxxx0_TXFIFO, &data[currentIndex], bytesToWrite);
                                 currentIndex += bytesToWrite;
                                bytesLeft -= bytesToWrite;
                       }
                      // Small delay to prevent SPI overrun
                     __delay_cycles(100);
              }
    }

  • Not even sure I undersatnd how you could receive anything with the code above.

    If rxBytes = TI_CC_SPIReadReg(TI_CCxxx0_RXBYTES) & 0x7F; is 1, bytesToRead will be 0 (even if you have not started to read anything, and Receive_Done will be set to 1.

    I would strongly recommend you to make an interrupt based implementation instead of polling, but if you do the changes below, the code will at least work.

    I tested it on a CC1101 + TrxEB:

    #define PKTLEN      89  // Max packet length the radio is to receive
    #define MAX_LEN     PKTLEN + 3      
    
    static void initMCU(void);
    static void registerConfig(void);
    
    uint8 rxBuffer[1 + PKTLEN + 2];
    uint16_t bytesReceived;
    uint8_t rxBytes;
    bool Receive_Done;
    uint8_t bytesToRead;
    uint8_t length;
    uint8 writeByte;
    
    void main(void)
    {
        // initialize MCU and peripherals
        initMCU();
    
        // Write radio registers
        registerConfig();
        
        writeByte = PKTLEN;
        cc1101SpiWriteReg(CC1101_PKTLEN, &writeByte, 1); // Use length filtering
    
        while(1)
        {
            bytesReceived = 0;
            Receive_Done = 0;
            
            trxSpiCmdStrobe(CC1101_SRX);
            
            while (Receive_Done == 0)
            {
                cc1101SpiReadReg(CC1101_RXBYTES, &rxBytes, 1);
              
                rxBytes = rxBytes & 0x7F;
    
                if (rxBytes > 1)
                {
                    bytesToRead = (rxBytes > (MAX_LEN - bytesReceived)) ? (MAX_LEN - bytesReceived) : rxBytes;
                    bytesToRead -= 1;
    
                    if (bytesToRead > 0)
                    {
                        cc1101SpiReadRxFifo(&rxBuffer[bytesReceived], bytesToRead);
                        bytesReceived += bytesToRead;
                        length = rxBuffer[0] + 3; // Total bytes you are supposed to read from the FIFO (Length + payload + status)
                    }
                    if(bytesReceived == length - 1)
                    {
                        Receive_Done = 1;
                    }
                }
            }
            cc1101SpiReadRxFifo(&rxBuffer[bytesReceived], 1);
        }
    }
    

    Siri