In the spirit of bulletproofing wireless data transmission, my robot's base station will send out a "start condition". I am using AVRGCC.
The start condition is that the bit 7 of the byte is 1, ALL actual data bytes are 4 bit nibbles and not 8 bit bytes (the 4 bits are stringed back together my the microcontroller). so the start condition is unique.
In the best case scenario, the robot gets the start condition, responds with an acknowledgment, the base station receives the acknowledgment, then A FIXED AMOUNT of data is exchanged, and then both devices idle their radio to deal with other processes.
In the worst case scenario, bytes are missing, the start condition happens again but not expected.
My solution is to insert assembly code with (this goes at the beginning of the radioCom procedure
__asm__ __volatile__("radioComBeginLabel: nop\n\t");
and in the receiving function looks like
uint8_t temp1 = norRead(); // read from FIFO buffer
iniRx = temp1;
__asm__ __volatile__("randomasslabel1: rjmp radioComBeginLabel\n\t");
temp1 <<= 4;
uint8_t temp2 = norRead();
iniRx = temp2;
__asm__ __volatile__("randomasslabel2: rjmp radioComBeginLabel\n\t");
data = temp2 + temp1;
(NOTE, waiting is done in another function with a timeout failsafe, so waiting is not needed here)
My question is, is there any other pointers/program counters that should be changed? Is there another way to accomplish the same goal?
The radios are Nordic nRF24L01 modules from SparkFun, the microcontroller is the massive yet DIP ATMEGA644