Reply
Posts: 2
Registered: ‎04-20-2015

Si446x bidirectional variable length packets with crc

I've managed to achieve bidirectional variable length packets with crc with the Si4460/3 devices, with some difficulty at times!, so thought I'd post my results in case anyone finds them useful.

 

One issue that I haven't managed to resolve is why the Si446x loses the PKT_FIELD_1_LENGTH configuration parameter when transitioning from Tx to Rx. Anyone have any ideas on this?

 

------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------

**** Overview:

  Packet structure:

    Preamble
    sync word
    length byte (loaded into tx fifo by software, read from rx fifo by software
    variable length data (32 bytes max)

-------------------------------------------

**** CRC when Transmitting

  The whole payload (length byte plus variable length data) is FIELD 1 as far as the
  Si446x is concerned, so it uses its FIELD 1 properties when calculating the CRC when
  transmitting the packet.


-------------------------------------------

**** CRC when Receiving

  The Si446x has been configured to have packets that consisit of 2 fields:

    field 1: length byte (1 byte)
    field 2: variable length data (32 bytes max)

  The transmitter uses the length byte (field 1) and the variable length data (field 2)
  in its CRC calculation, so both fields must be enabled for CRC calculation for Rx.
  The CRC should be checked at the end of field 2.

-------------------------------------------

**** Key Packet Settings

// from header file
#define RF_PKT_CRC_CONFIG_7 0x11, 0x12, 0x07, 0x00, 0x84, 0x01, 0x08, 0xFF, 0xFF, 0x00, 0x02
#define RF_PKT_LEN_12 0x11, 0x12, 0x0C, 0x08, 0x2A, 0x01, 0x00, 0x30, 0x30, 0x00, 0x01, 0x04, 0xA2, 0x00, 0x20, 0x00


// WDS settings

    Enable variable packet length - YES
    Field number varying in length: 2
    Length stored in Field number: 1
    Packet length in MSB - YES
    Add length to RX FIFO - YES
    Packet length adjust: 0

    field 1: length size: 1
             Transmit CRC at the end of this field - YES
             Check CRC at the end of this field    - NO
             Enable CRC over this field            - YES

    field 2: Max length: 32
             Transmit CRC at the end of this field - NO
             Check CRC at the end of this field    - YES
             Enable CRC over this field            - YES

-------------------------------------------

**** Tx Procedure

// start tx of variable length packet
void rad_startTxPkt(const char* buffer, const int length)
{
    unsigned int i;

    SI446x_CHANGE_STATE(SI446X_CMD_CHANGE_STATE_ARG_NEW_STATE_ENUM_READY);

    // clear pending interrupts
    SI446x_GET_INT_STATUS(0,0,0);

    // Reset TX FIFO
    SI446x_FIFO_INFO(SI446X_CMD_FIFO_INFO_ARG_TX_BIT);

    // write length byte to tx fifo
    spi_xfer(SI446X_CMD_ID_WRITE_TX_FIFO);

    // write length byte
    spi_xfer(length);

    // write variable length data to tx fifo
    for(i=0;i<length;i++)
    {
      spi_xfer(buffer[i]);
    }

    // start tx of packet using channel 0,
    // go to ready state after tx has finnished,
    // total number of bytes to send is variable data length + 1 (length byte itself)
    SI446x_START_TX(0, 0x30, length + 1);
}

-------------------------------------------

Rx Procedure

// puts radio into rx mode.
void radio_startRx(const unsigned int channel)
{
  unsigned char s[2];

  // clear pending interrupts
  SI446x_GET_INT_STATUS(0,0,0);

  // **** IMPORTANT - THIS FIELD CAN BECOME CORRUPTED BY
  // TRANSITION FROM TX TO RX.
  // restore field 1 length to 1 byte
  s[0] = 0;
  s[1] = 1;
  SI446x_SET_PROPERTY(0x12, 0x02, 0x0D, s);

  // use FIFO_INFO cmd to reset Rx fifo
  SI446x_RESET_RX_FIFO();

  // put Si446x into Rx mode immediately, Packet length according to PH
  SI446x_START_RX(channel, 0, 0x00,
                    SI446X_CMD_START_RX_ARG_RXTIMEOUT_STATE_ENUM_NOCHANGE,
                    SI446X_CMD_START_RX_ARG_RXVALID_STATE_ENUM_RX,
                    SI446X_CMD_START_RX_ARG_RXINVALID_STATE_ENUM_RX);

}

-------------------------------------------

Posts: 1
Registered: ‎09-08-2014

Re: Si446x bidirectional variable length packets with crc

Thanks for this post.

It took me a some time to understand the fact that TX only sees it as one field instead of two, therefor the "CRC send after packet 1" had to be enabled.

 

I also struggled with the resetting of the length field for RX.

 

thanks again!

 

Maarten

Highlighted
Posts: 156
Registered: ‎06-11-2015

Re: Si446x bidirectional variable length packets with crc

This seems to a be a pretty old and forgotten topic Robot Happy I might as well answer it for people who run into the same problem.

 

This is how the radio works by default: TX and RX package structure is shared, and on the TX side, you can't setup variable length (since it doesn't make much sense).

 

The easiest solution to this problem is to enable PH_FIELD_SPLIT in PKT_CONFIG1. Then you can use the PKT_RX_FIELD* properties to set up variable length, and it wouldn't matter if you overwrite PKT_FIELD* properties during transmission.