This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Radio Transmitter/Receiver example

Your served radio tramsmitter/receiver example using PCA 10000 USB dongle, PCA 10001 evaluation kit. It's just only one byte data communication. It works well. If I communication multi-byte data with one packet, what did I fixed source code in "main.c" , "Radio_config.c"?

Parents
  • Hi.

    If you want a very quick fix without changing to much, set "PACKET_STATIC_LENGTH" in radio_config.h to your desired number of bytes on air.

    Here's some more information, and how to configure your length manually:

    When the length field is used (LFLEN > 0) you can set the content of the length field through the first byte of the packet buffer. The payload itself will start on the second byte. If S0LEN > 0 or S1LEN > 0 you will have to set these fields through the packet buffer as well, each field (S0, Length or S1) will occupy one byte of the packet buffer when enabled.

    The S0 and S1 fields are only there to allow status or padding bits before or after the length field, and they are completely optional if you are defining your own protocol.

    Below is a small example to show you how the length field can be used:

    uint8_t packet_buf[33];
    NRF_RADIO->PACKETPTR = packet_buf;
    NRF_RADIO->PCNF0 = 8 << RADIO_PCNF0_LFLEN_Pos;
    NRF_RADIO->PCNF1 = (RADIO_PCNF1_WHITEEN_Disabled << RADIO_PCNF1_WHITEEN_Pos) |                                   (RADIO_PCNF1_ENDIAN_Big       << RADIO_PCNF1_ENDIAN_Pos)  |                                   
    (3   << RADIO_PCNF1_BALEN_Pos)   |                     
                                      (0   << RADIO_PCNF1_STATLEN_Pos) |                     
                                      (32 << RADIO_PCNF1_MAXLEN_Pos);
     
    // Send a 20 byte payload
    packet_buf[0] = 20;
    packet_buf[1] = USERDATA[0];
    packet_buf[2] = USERDATA[1];
    .
    .
    packet_buf[20] = USERDATA[19];
    

    Best regards Håkon

Reply
  • Hi.

    If you want a very quick fix without changing to much, set "PACKET_STATIC_LENGTH" in radio_config.h to your desired number of bytes on air.

    Here's some more information, and how to configure your length manually:

    When the length field is used (LFLEN > 0) you can set the content of the length field through the first byte of the packet buffer. The payload itself will start on the second byte. If S0LEN > 0 or S1LEN > 0 you will have to set these fields through the packet buffer as well, each field (S0, Length or S1) will occupy one byte of the packet buffer when enabled.

    The S0 and S1 fields are only there to allow status or padding bits before or after the length field, and they are completely optional if you are defining your own protocol.

    Below is a small example to show you how the length field can be used:

    uint8_t packet_buf[33];
    NRF_RADIO->PACKETPTR = packet_buf;
    NRF_RADIO->PCNF0 = 8 << RADIO_PCNF0_LFLEN_Pos;
    NRF_RADIO->PCNF1 = (RADIO_PCNF1_WHITEEN_Disabled << RADIO_PCNF1_WHITEEN_Pos) |                                   (RADIO_PCNF1_ENDIAN_Big       << RADIO_PCNF1_ENDIAN_Pos)  |                                   
    (3   << RADIO_PCNF1_BALEN_Pos)   |                     
                                      (0   << RADIO_PCNF1_STATLEN_Pos) |                     
                                      (32 << RADIO_PCNF1_MAXLEN_Pos);
     
    // Send a 20 byte payload
    packet_buf[0] = 20;
    packet_buf[1] = USERDATA[0];
    packet_buf[2] = USERDATA[1];
    .
    .
    packet_buf[20] = USERDATA[19];
    

    Best regards Håkon

Children
No Data
Related