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

elaboration of NRF_RADIO->END

I don’t fully understand the nRF51 event NRF_RADIO->END. NRF_RADIO->END identifies the completion of a packet transmission or reception. My question is what triggers NRF_RADIO->END? For example, on the completion of a receiving packet, is NRF_RADIO->END set when the number of bytes received equals (LENGTH + STATLEN)? For example

LENGTH = 3            // 8-bit field in received packet
PCNF1.STATLEN = 2     // number of bytes in static section of the payload

Does NRF_RADIO->END change to 1 when the number of received bytes equals 5? Is packet length the criteria used for triggering NRF_RADIO->END?

  • Hi Jeff

    Thank you for your question.

    When you send a packet, you specify the length of the packet in bytes, the RADIO sends the specified number of bytes and then issues the NRF_RADIO->END event. The length of the packet is specified by the sum of PCNF1.STATLEN and the PCNF0.LFLEN fields.

    The radio example in the nRF51 SDK uses only the PCNF1.STATLEN field but sets the PCNF0.LFLEN field to zero, which means it is unused. This means that the length of the payload is specified only by PCNF1.STATLEN, and is fixed to 1 byte.

    By writing a non zero value to PCNF0.LFLEN, you specify how many bits in the on air packet should specify the length of the packet payload. The actual value is however written by adding a byte at the start of the array that you point to with NRF_RADIO->PACKETPTR. A few examples:

    • Set PCNF0.LFLEN = 2 and PCNF1.STATLEN = 0. This will specify 2 on-air bits to specify the length of the payload. If you want to transmit 3 byte payload of {7,8,9}, then you should create a 4 byte array with value {3,7,8,9} and let NRF_RADIO->PACKETPTR point to that array. The first value in the array indicates the length of the payload.

    • Set PCNF0.LFLEN = 2 and PCNF1.STATLEN = 0. This will specify 2 on-air bits to specify the length of the payload. If you want to transmit 4 byte payload of {6,7,8,9}, then you should create a 5 byte array with value {4,6,7,8,9} and let NRF_RADIO->PACKETPTR point to that array. What you will see on air will probably be {0} (the 2xLSB of the length field) as the MSB of the LENGTH parameter did not fit into 2 bits. This would be correctly transferred however if we set PCNF0.LFLEN = 3

    • Set PCNF0.LFLEN = 0 and PCNF1.STATLEN = 3. There will be no on-air bits to specify the length of the payload. The radio will tranfer fixed 3 bytes instead. If you want to transmit 3 byte value of {7,8,9}, then you should create a 3 byte array with value {7,8,9} and let NRF_RADIO->PACKETPTR point to that array.

    • Set PCNF0.LFLEN = 3 and PCNF1.STATLEN = 3. There will be 3 on-air bits to specify the length of the payload. The radio will transfer number of bytes specified in the first byte of the array and fixed 3 bytes additionally. If you create 6 byte array with value {1,5,6,7,8,9} and let NRF_RADIO->PACKETPTR point to that array, 4 payload bytes with values {5,6,7,8} would be sent since array[0] + STATLEN = 1 + 3 = 4.

    • If you would like to specify the LENGTH, S0 and S1 fields, you could do that with e.g. PCNF0.LFLEN = 2, PCNF0.S0LEN = 1, PCNF0.S1LEN = 2. If you want to send data of {7,8,9} then you could create a 6 byte array with value {1,3,1,7,8,9} and let NRF_RADIO->PACKETPTR point to that array. The first '1' indicates the value for the S0 field, the '3' indicates the LENGTH of the payload to be transfered, and the second '1' indicates the value for the S1 field.

    This is my understanding so far. Let me know if you find out it is inaccurate.

  • Hi Stefan,

    The reference manual further says the LENGTH field is optional (PCNF0.LFLEN can be 0). Can you describe the behavior of the receiver when the LENGTH field is omitted during a received packet? Is NRF_RADIO->END set to one when the number of bytes arriving equals PCNF1.STATLEN in the receiver?

  • Hi Jeff

    That is correct. On the receiver, if you set LENGTH = 0, the NRF_RADIO->END event is triggered when PCNF1.STATLEN bytes have been received

Related