Hello everybody,
I’m using ez430RF2500 board and I’m trying to send data from a Chip to another one,
When I use 20 bytes payload length there is no problem but when I want to use 50 bytes I must send data more than one time before I can receive it and I don’t know where the problem is. If you can help me I will be grateful.
Please find the code bellow (I use the same code in the 2 chips):
#include "radios/family1/mrfi_spi.h"
#include "mrfi.h"
void TXStringB( char* string, int length );
uint8_t index_output = 9;
mrfiPacket_t packetToSend;
int main(void)
{
BSP_Init();
MRFI_Init();
P3SEL |= 0x30; // P3.4,5 = USCI_A0 TXD/RXD
UCA0CTL1 = UCSSEL_2; // SMCLK
UCA0BR0 = 0x41; // 9600 from 8Mhz
UCA0BR1 = 0x3;
UCA0MCTL = UCBRS_2;
UCA0CTL1 &= ~UCSWRST; // Initialize USCI state machine
IE2 |= UCA0RXIE; // Enable USCI_A0 RX interrupt
__enable_interrupt();
mrfiSpiWriteReg(CHANNR,0x02);
MRFI_WakeUp();
MRFI_RxOn();
index_output=0;
__bis_SR_register(GIE+LPM4_bits);
}
void MRFI_RxCompleteISR()
{
uint8_t i;
P1OUT ^= 0x02;
mrfiPacket_t packet;
MRFI_Receive(&packet);
char output[] = {" "};
for (i=9;i<59;i++) {
output[i-9]=packet.frame[i];
}
TXStringB(output, (sizeof output));
}
#pragma vector=USCIAB0RX_VECTOR
__interrupt void USCI0RX_ISR(void)
{
char rx = UCA0RXBUF;
uint8_t i;
MRFI_SET_PAYLOAD_LEN((&packetToSend),50);
packetToSend.frame[index_output]=rx;
index_output++;
if (rx=='\r' || index_output==59 ) {
packetToSend.frame[0]=58;
MRFI_Transmit(&packetToSend, MRFI_TX_TYPE_FORCED);
for(i=9;i<index_output;i++) {
packetToSend.frame[i]=' ';
}
index_output = 9;
P1OUT ^= 0x01;
}
P1OUT ^= 0x02;
}
void TXStringB( char* string, int length )
{
int k;
for( k = 0; k < length; k++)
{
if (string[k] != '\0')
UCA0TXBUF = string[k];
while (!(IFG2&UCA0TXIFG)); // USCI_A0 TX buffer ready?
}
}
Best,
Imane