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.

CC1101: CC1101 code

Part Number: CC1101

Hi

could you please explain what the number 3 attached to buffer length means?

it's not related to a specific code but included in many codes

#define CC1101_DATA_LEN  CC1101_BUFFER_LEN - 3

also is TX/RX FIFO means BUFFER?

when First byte is the destination address, dose it mean the sync or preamble byte?

Kind Regards

Mustafa

  • I have assigned an expert to comment.

  • could you please explain what the number 3 attached to buffer length means?

    it's not related to a specific code but included in many codes

    #define CC1101_DATA_LEN  CC1101_BUFFER_LEN - 3

    The above means that CC1101_DATA_LEN is 3 (bytes??) less than CC1101_BUFFER_LEN

    As I have told you previously we cannot answer why some defines/variable are set a specific way when we do not know how they are used. You need to refer to the code example you are looking at for us to be able to give proper answers.

    also is TX/RX FIFO means BUFFER?

    TX_FIFO and RX_FIFO are the FIFOs of the radio. What BUFFER is, I cannot answer without knowing what code you are referring to.

    when First byte is the destination address, dose it mean the sync or preamble byte?

    Again, you need to be more specific. Are you talking about an SPI address to a register, or to the address used in a packet sent over the air?

    Siri

  • Hello Siri

    my sincere apology, I know how much it's frustrating and annoying when you have to answer vague questions from not enough

    experienced or lacking adequate knowledge about this topic.

    regardless of what is the  code itself, when a packet is written to TR FIFO  and read by RX FIFO, there is a buffer (zone) so my question 

    is what is the definition of buffer in this context?

    what dictates or determines the amount of bytes in this example  #define CC1101_DATA_LEN CC1101_BUFFER_LEN - 3 ?

    when the packet is variable, first byte is the length byte.

    when the packet is fixed, first byte.is the address bytes

    whether variable or fixed packet, what is the order of transmission in terms of  (length byte / address bytes, preamble, sync), length, address, data, crc.

    Kind Regards

    Mustafa

  • #ifndef _CCPACKET_H
    #define _CCPACKET_H
    
    #include "Arduino.h"
    
    /**
     * Buffer and data lengths
     */
    #define CC1101_BUFFER_LEN        64
    #define CC1101_DATA_LEN          CC1101_BUFFER_LEN - 3
    
    /**
     * Class: CCPACKET
     * 
     * Description:
     * CC1101 data packet class
     */
    class CCPACKET
    {
      public:
        /**
         * Data length
         */
        byte length;
    
        /**
         * Data buffer
         */
        byte data[CC1101_DATA_LEN];
    
        /**
         * CRC OK flag
         */
        boolean crc_ok;
    
        /**
         * Received Strength Signal Indication
         */
        byte rssi;
    
        /**
         * Link Quality Index
         */
        byte lqi;
    };
    
    #endif
  • Hi Mustafa

    The CC1101 has a TX FIFO and an RX FIFO which is a buffer/area in the device that has room for 64 bytes.

    In your application running on the MCU, you would normally create a buffer that can store the data you want to write to the TX FIFO and read from the RX FIFO. How big these buffers are, depends on how big packets you want to receive. If the radio use packet length filtering, so that you never receive more than 30 bytes (including length and status bytes), your buffers do not have to be larger than 30 bytes, even though the FIFOs are larger than this.

    In the example code you are referring to I would assume that they use standard packet format with variable packet length and APPEND_STATUS enabled. I will also assume that they use packet length filtering and that they want the complete packet to have room in the RX FIFO.

    Since CC1101_BUFFER_LEN is 64 (same length as the RX FIFO), the have set CC1101_DATA_LEN to 61. This will be the actual payload and are stored in the buffer called "data".

    The crc_ok, rssi and lqi variables indicates that they also receives status information.

    The max length byte they can receive is 61. In the RX FIFO there will be the length byte (61), 61 payload bytes, and 2 status bytes (a total of 64 bytes). If they do not use length filtering (with PKTLEN = 61, they will risk that the RX FIFO overflow, and they will not have room to store the received data, since the "data" buffer is only 61 bytes long.

    Regarding packet format, this is explained in Section 15.2 of the data sheet.

    Siri

  • Hello Siri

    thank you very much for the comprehensive and detailed explanations.

    Kind Regards

    Mustafa