nrf24 pluse and using the writebackpayload does not clear tx

I have set up communication from chip to chip and it works great but I need to use the writebackack for a new project. Everything is fine accept it does not clear the tx. So I only can use it once. I tried to clear it using start listening but my loop order is prevent it from working at all. I re-ranged my calls in many ways but can not figure this out.

here is my current code.

basic idea is I send a no ack, then a act with 0xff. One send to set data for the return and the second to retrieve it.

#include "nRF24L01.h" // NRF24L01 library created by TMRh20 GitHub - nRF24/RF24: OSI Layer 2 driver for nRF24L01 on Arduino & Raspberry Pi/Linux Devices
#include "RF24.h"
#include "SPI.h"
#include "printf.h"

byte ReceivedMessage[1] = {0};
byte ack[1] = {0x0a};
RF24 radio(9, 10); // CE, CSN0
void setup(void)
{

Serial.begin(9600);
printf_begin();
Serial.println("serial test ...");
Serial.println("1...");

radio.begin(); // Start the NRF24L01
radio.printDetails();
radio.setChannel(2);
const byte add[5] = {0xe7,0xe7,0xe7,0xe7,0xe7};
radio.setPALevel(RF24_PA_MAX);
radio.setCRCLength(RF24_CRC_8);
radio.setDataRate (RF24_2MBPS);
//radio.setAutoAck(true);//default
radio.enableAckPayload();
radio.enableDynamicPayloads();
//radio.spiWriteRegister(NRF24_REG_1D_FEATURE, NRF24_EN_DYN_ACK);

//hack - why not support for this I do not know?
digitalWrite(10, LOW);
SPI.transfer(0x3d);
SPI.transfer(0x07);
digitalWrite(10, HIGH);

radio.setRetries(0,0);
radio.setPayloadSize(1);
radio.openReadingPipe(0, add);
radio.startListening(); // Listen to see if information received
radio.writeAckPayload(0,ack,sizeof(ack));
radio.printDetails();

}
void loop(void)
{

//trying to flush tx here.
radio.startListening();
radio.writeAckPayload(0,ack,sizeof(ack));
//but this makes nothing work. Leaving this out I can send only once. as the TX is full afterwords.

while (radio.available())
{
radio.read(ReceivedMessage,sizeof(ReceivedMessage));
Serial.println(ReceivedMessage[0],HEX);

if (ReceivedMessage[0]==0xff)
{
Serial.print("fetch");Serial.println(ack[0],HEX);
}
else if (ReceivedMessage[0]==1) ack[0] = 0xA1;

else if (ReceivedMessage[0]==2) ack[0] = 0xA2;
else if (ReceivedMessage[0]==3) ack[0] = 0xA3;

}
}

Have a look at this Simple nRF24L01+ Tutorial. The second example illustrates the use of the ackPayload feature.

To make it easy for people to help you please modify your post and use the code button </>
codeButton.png

so your code 
looks like this

and is easy to copy to a text editor. See How to use the Forum

Your code is too long for me to study quickly without copying to my text editor.

And, for wireless problems you need to post the code for both Arduinos.

...R

Hi, Robin2. I looked everywhere for that code tag. I could not find it thx for pouting it out. The other device is not arduino, its a bare chip. I'm only using the arduinoto get a better form of debug as the analyzer can be hard to look at, at time.

I have tried the SimpleRxAckPayload.ino method without lucy but it says its good so i'll have to assume its something else.

thx for the link.

ulao:
The other device is not arduino, its a bare chip.

[.....]

I have tried the SimpleRxAckPayload.ino method without lucy

Unless you provide details of the hardware and the actual programs you tried I can't help.

I have nRF24s working with bare Atmega328, Attiny1634 and Attiny84 chips

...R

I feel you already helped. :slight_smile:

Working with nordic it seems the Arduino functions are not clearing the interrupts. Specially "The library you're using is not clearing the interrupt source, as that register is accumulating. " I'm guessing the library is attempting to clear them.

Your suggestion above has cleared up a lot of confusion and that was the main direction I needed, and I thank you for that.

There is a small suspicion my choice of chip (clone) is to blame. I have a sparkfun one on the way. I am assuming there is no function in the library to clear interrupts (Specifically MAX_RT)?

ulao:
Working with nordic it seems the Arduino functions are not clearing the interrupts.

There is no use of interrupts in the code in your Original Post and my programs don't use interrupts and don't have any problems. I think this is just a distraction.

There is a small suspicion my choice of chip (clone) is to blame.

You still have not told us what chip you are using. And when you use the word "clone" it makes me wonder if you mean a clone of an Arduino board or a clone of an Atmel microchip?

...R

The use of AckPayload uses the interrupts in the status register, since you do not understand this, you can not possibly help with the second issue.

I have been nothing but kind to you and you continue to show me disrespect. I think this is more for your amusement. Sincerely, as I have already said, thx for the input. "writebackpayload does not clear tx" has already been answered in your first reply.

I'll leave this place for you to make a mess about, have fun.

ulao:
The use of AckPayload uses the interrupts in the status register, since you do not understand this, you can not possibly help with the second issue.

That's very interesting.

I wonder how it is then possible for my ackPayload example to work reliably every time I want it to - and for other Forum users also.

My programs work. I don't think it is I who is making the mess.

...R

You have to write the ackPayload in setup and after a reception on the pipe.