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

PTX with dyn ack, sleep problem

Hi, There's a problem when using dynamic ack with return payload plus timer/sleep. Sending a single packet doesn't work. sending two packets works. not sleeping/using timer works. I've attached details (and code) files. Thanks in advance for your help! Best, Mahesh

OVERVIEW:

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

The PTX device needs to send data to PRX and get ACK and a return payload of data. It should then SLEEP for two seconds, wake up, and do it all over again. It does not work properly. PTX and PRX C files (ptx-main.c, prx-main.c) are attached and the output for 3 test cases follow.

Case 1: WORKS (but we don't need this): wake, send data continuously. packets are received and the return ack payload is received by PTX.

Case 2: DOES NOT WORK (but we want this!!!): send ONE packet, sleep. PRX IRQ is fired ONLY the first time. PTX, strangely, gets an ack BUT it always has only the data from the first (and only) return packet.

Case 3: WORKS (but we don't need this): wake, send TWO packets, sleep. both packets are received and the return ack payloads are received by PTX.

PTX & PRX OUTPUTS:

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

TEST CASE 1: (send packets continuously, no sleep)
-------------------------------------------------------------------
PTX:
Sent. Ack pack:length:32, Payload: C9, 02, 03
Sent. Ack pack:length:32, Payload: CA, 02, 03
Sent. Ack pack:length:32, Payload: CB, 02, 03
Sent. Ack pack:length:32, Payload: CC, 02, 03
Sent. Ack pack:length:32, Payload: CD, 02, 03
Sent. Ack pack:length:32, Payload: CE, 02, 03
Sent. Ack pack:length:32, Payload: CF, 02, 03
Sent. Ack pack:length:32, Payload: D0, 02, 03
Sent. Ack pack:length:32, Payload: D1, 02, 03
Sent. Ack pack:length:32, Payload: D2, 02, 03
Sent. Ack pack:length:32, Payload: D3, 02, 03
Sent. Ack pack:length:32, Payload: D4, 02, 03
Sent. Ack pack:length:32, Payload: D5, 02, 03
Sent. Ack pack:length:32, Payload: D6, 02, 03
Sent. Ack pack:length:32, Payload: D7, 02, 03
Sent. Ack pack:length:32, Payload: D8, 02, 03
Sent. Ack pack:length:32, Payload: D9, 02, 03
Sent. Ack pack:length:32, Payload: DA, 02, 03
Sent. Ack pack:length:32, Payload: DB, 02, 03
PRX:
got packet!
got packet!
got packet!
got packet!
got packet!
got packet!
got packet!
got packet!
got packet!
got packet!
(etc...)
TEST CASE 2: (send one packet, then go sleep, repeat)
-------------------------------------------------------------------
PTX: gets a first ACK payload, but it never gets updated. PRX sends only one and never again.
woke up:
Sent. Ack pack:length:32, Payload: 1B, 02, 03
woke up:
Sent. Ack pack:length:32, Payload: 1B, 02, 03
woke up:
Sent. Ack pack:length:32, Payload: 1C, 02, 03
woke up:
Sent. Ack pack:length:32, Payload: 1C, 02, 03
(etc...)
PRX: (prints the following ONCE, and that too, not always)
got packet!
TEST CASE 3: (sending two packets, then going to sleep, and repeat)
-------------------------------------------------------------------
PTX: (byte #1 of payload increments, my packet counter)
woke up:
Sent. Ack pack:length:32, Payload: 7C, 02, 03 -------> packet 1
Sent. Ack pack:length:32, Payload: 7D, 02, 03 -------> packet 2
woke up:
Sent. Ack pack:length:32, Payload: 7E, 02, 03
Sent. Ack pack:length:32, Payload: 7F, 02, 03
woke up:
Sent. Ack pack:length:32, Payload: 80, 02, 03
Sent. Ack pack:length:32, Payload: 81, 02, 03
woke up:
Sent. Ack pack:length:32, Payload: 82, 02, 03
Sent. Ack pack:length:32, Payload: 83, 02, 03
woke up:
Sent. Ack pack:length:32, Payload: 84, 02, 03
Sent. Ack pack:length:32, Payload: 85, 02, 03
woke up:
Sent. Ack pack:length:32, Payload: 86, 02, 03
Sent. Ack pack:length:32, Payload: 87, 02, 03
woke up:
Sent. Ack pack:length:32, Payload: 88, 02, 03
Sent. Ack pack:length:32, Payload: 89, 02, 03
woke up:
Sent. Ack pack:length:32, Payload: 8A, 02, 03
Sent. Ack pack:length:32, Payload: 8B, 02, 03
PRX:
got packet!
got packet!
got packet!
got packet!
got packet!
got packet!
got packet!
got packet!
got packet!
got packet!
got packet!
got packet!
(etc....)

prx-main.c

ptx-main.c

  • Assuming that my understanding is correct, at 250Kbps, what delay would you recommend between the "ack packet prepare" and the "fetch ack payload" packets sent by the PTX? Thanks, Mahesh

  • Hi Mahesh,

     

    Q1: Do you mean that if the PTX asks for ACK+payload, the PRX radio will AUTOMATICALLY send an ACK + the payload ALREADY in its buffer? The PRX CPU has NO control over this, correct?

    Does this mean that calling hal_nrf_write_ack_payload(pipe, payload_data, length) on the PRX ONLY "uploads" the packet to the radio and DOES NOT actually send the ACK packet out? So it's best to have the PRX radio "primed" with the ACK packet as far as possible. Correct?

     

    That is correct. The function call uploads the ack-payload to the chosen rf-pipe in the radio FIFO.

    If you upload an ACK-payload to pipe 0 and pipe 1, they will only be transmitted (read: appended to the ACK going from PRX->PTX) when you receive a payload on each of these pipes. This means that if you never receive a TX-payload on pipe1, the ack-payload will remain there.

     

    Q2: Thus, if no new ACK packet is uploaded to the PRX radio by its CPU, it will send the SAME ACK packet to the PTX over and over and over again. Correct?

     

    No, that is not correct. If you upload one ACK-payload, this will be sent back to the PTX on the next received "payload #1". This will then be removed from the FIFO if the "PID" field in the "payload #2" has incremented, which indicates that this was not a re-transmitted payload.

     

    Chapter 7.8 in the datasheet for protocol examples.

     

    Q3: What do you mean by "this has to be updated to a specific RF pipe?" Shouldn't the PRX use the same pipe on which the RX packet was received to transmit the ACK packet?

     

    See answer for Q1 for details on this. The command "W_ACK_PAYLOAD" command (which is the command used for ack payload) requires that you also set the RF pipe this should be addressed to.

     

    Q4: Assuming that my understanding is correct, at 250Kbps, what delay would you recommend between the "ack packet prepare" and the "fetch ack payload" packets sent by the PTX?

     

    You can send them back-to-back if you'd like. In gazell, we use a delay of a couple of ms between "ack prepare" and "fetch ack", in case the PRX is busy doing other processing.

     

    Best regards,

    Håkon

Related