the code is repeating the void setup()

Hello everybody
Hope you are fine
i am using nrf module to transfer data but the code is act strange

void setup(){
  Serial.begin(9600);
  mySerial.begin(9600);
  radio.begin();
  radio.setAutoAck(false);
  //radio.setRetries(15,15);
  radio.openWritingPipe(pipes[0]);
  radio.openReadingPipe(1,pipes[1]);
  radio.setPALevel(RF24_PA_MAX); 
  radio.startListening();
  
}
void loop() {
  radio.stopListening();
  
  if (mySerial.available()) {
    c_CA = mySerial.read();
    

      if(int(c_CA)==13){
      
   bool ok = radio.write(&text , sizeof(text));
      command_CA = "";
    
    else {
    text[count] = c_CA;
      command_CA += c_CA;
     count++;}
 
  }

the program should read some serial data and then send it . it works fine without the " bool ok = radio.write(&text , sizeof(text)); " statement . after adding it the program is like start over again every time as the function " t_data_title() " is called only one time in the void setup () but it keeps repeating it like it starts the code from the first and i don't know what is the problem .
Thank you

Your processor is resetting.

It is also incomplete.

what is 'text'?

If you want help with the resetting issue, you need to post your complete sketch.

I don't see any mechanism for preventing count from becoming larger than 31 and causing a write outside the bounds of the text array. When you write outside the bounds of an array, you corrupt some random memory, which will often lead to a reset.

This Simple nRF24L01+ Tutorial may be of interest.

…R

In addition to the above comment about "count", use of Strings leads to program crashes and resetting on the Arduino. If you don't want that to happen, use C-strings (zero terminated character arrays) instead.

In other words, get rid of these:

String command_CA;
...
String part1_CA, part2_CA, part3_CA, part4_CA, part5_CA;

pert:
I don’t see any mechanism for preventing count from becoming larger than 31 and causing a write outside the bounds of the text array. When you write outside the bounds of an array, you corrupt some random memory, which will often lead to a reset.

You are right !
After i reviewed the code i found that i go out beyond the bounds of the array (text) without making the count back to zero

if(int(c_CA)==13){
      
   bool ok = radio.write(&text , sizeof(text));
      command_CA = "";
      count = 0 ; [color=red]// Correctness <<<<[/color]
    else {
    text[count] = c_CA;
      command_CA += c_CA;
     count++;} [color=red]// Here <<<[/color]
  t_data1();