Tool/software:
Hello everyone im currently working on a program to communicate between msp430 and arduino right now im facing a problem in synchronization and i need to sync the communication between the arduino and msp.
When i try to do switch from tx to rx mode in the arduino and switch from rx to tx in the msp430 i cant seem to communicate, i think this is due to synchronization problem because when i try to do only one of the modes (RX or TX) and not switch between the modes the arduino and the mps430 can communicate i think this is due to the fact the arduino is being used with pooling so if the sync word fails it will repeat either way and fire the GDO interrupt and the msp will eventually read the buffer (in case of arduino (TX) and msp (RX)).
Here i have the codes for both to shorten the codes i will only include the more important parts:
ARDUINO
/* ARDUINO CODE - NOTE: the wakeUp routine dosent do nothing */
while (1)
{
digitalWrite(4, HIGH);
sendPacketINT(buffer_tx, 5);
delay(500);
attachInterrupt(2, wakeUp, FALLING);
LowPower.powerDown(SLEEP_FOREVER, ADC_OFF, BOD_OFF);
detachInterrupt(2);
digitalWrite(4, LOW);
SendStrobe(CC2500_SIDLE);
SendStrobe(CC2500_SFTX);
SendStrobe(CC2500_SFRX);
// RX
SendStrobe(CC2500_SRX);
delay(500);
attachInterrupt(2, wakeUp, FALLING);
LowPower.powerDown(SLEEP_FOREVER, ADC_OFF, BOD_OFF);
detachInterrupt(2);
//while(digitalRead(GDO0));
listenForPacket(buffer_rx, 5);
if (buffer_rx[4] == length)
{
digitalWrite(4, HIGH);
}
}MSP
// GDO init: P2.0 - reg 0x02 | val 0x06
P2DIR &= ~BIT0; // input
P2REN |= BIT0; // enable pull up/pull down resistor
P2OUT |= BIT0; // use as pull up resistor
P2IES |= BIT0; // interrupt edge (H -> L)
P2IFG &= ~BIT0;
P2IE &= ~BIT0;
while (1)
{
// LER
P2IFG &= ~BIT0;
P2IE |= BIT0;
sendStrobe(CC2500_SRX);
__bis_SR_register(GIE + LPM0_bits);
for (int i = 0; i < 5; i++)
{
buffer_rx[i] = CC2500_read_register(CC2500_RXFIFO);
}
if (length == buffer_rx[4])
{
P1OUT |= BIT0;
received = 1;
}
sendStrobe(CC2500_SIDLE);
// Flush RX FIFO
sendStrobe(CC2500_SFRX);
for (int i = 0; i < 5; i++)
{
write(*(point_tx + i),CC2500_TXFIFO);
}
// Transmitter mode
sendStrobe(CC2500_STX);
__delay_cycles(500000); // 500 ms
// reativar interrupt gdo e escrever tudo no TXFIFO
P2IFG &= ~BIT0;
P2IE |= BIT0;
__bis_SR_register(GIE + LPM0_bits);
// go back to rx mode and flush TX FIFO
sendStrobe(CC2500_SIDLE);
//__delay_cycles(100);
sendStrobe(CC2500_SFTX);
P1OUT &= ~BIT0;Block diagram of the system:

The goal is for the arduino to send a message and the msp430 respond with another.
I have tried using delays on the arduino, but found out pretty quick that its not efficient maybe use a timer for both?
Really would appreciate help with this, thank you for your time!