The program is the exact same (99.9999%) on both boards.
The button board is an Arduino Micro.
The program is rather big, I'll just post relevant RF parts.
//Pins for the RF24 module
#define CE_PIN A8
#define CSN_PIN A9
RF24 radio(CE_PIN, CSN_PIN); // Create a Radio
I'm using Struct to exchange data.
//Struct for data to send
typedef struct {
int rnd;
int type;
int msg;
}
A_t;
RF setup:
//Setting up the RF24
radio.begin();
radio.printDetails();
radio.setDataRate(RF24_250KBPS); //best
radio.setPALevel(RF24_PA_MAX); //max power
radio.setChannel(125);//To avoid Wifi noise
radio.openReadingPipe(1, thisMasterAddress);
radio.enableAckPayload();
radio.setRetries(3, 15); // delay, count
radio.startListening();
The Loop:
void loop() {
do {
BlaBlaBla....
}
while (!radio.available());
radio.read(&Data_Received, sizeof(Data_Received));
btnNr = Data_Received.msg;
if (btnNr != buzzMashedDisplay[0][0] ) {
sendToBtn(btnNr, TURN_LED_ON);
}
}
sendTBtn():
void sendToBtn(int id, int c) {
Data_Sent.msg = c;
Data_Sent.rnd++;
bool rslt;
//We have to stop listening before writing
radio.stopListening();
radio.flush_tx();
radio.openWritingPipe(buttonAddress[id - 1]);
rslt = radio.write(&Data_Sent, sizeof(Data_Sent));
if (rslt) {
btnConnected[id] = true;
if (!radio.isAckPayloadAvailable()) {
Serial.println(" Acknowledge but no data ");
}
}
else {
btnConnected[id] = false;
Serial.println(" Tx failed");
}
//We start the listening again
radio.startListening();
}
Something is working as when I push the button the GC see data are incoming, but it always receive 0.
Same for sending data back to button, the button receive the data, but alwas 0.
They both send an acknowledge.
If I change the GC by a Mega everything is working fine.
I've tried to run Mega and GC in parallel, when I push the button the Mega react correctly, the GC receive 0....
The only thing I see, apart it's totally different MC, is the speed difference between both boards 16Mhz vs 120Mhz.
Could that be an issue for SPI ?
I've tried with many SPI_CLOCK_DIV16 values, without success, result is always the same.