Hello,
I modified "eZ430-RF2500 Wireless Sensor Monitor" Access Point firmware. Instead of sending a single char as a poll command, I send a set of characters with line ending \r\n. Sometimes I get incomplete poll command e.g. TX from Realterm client poll command [poll_t\r\n] is received [pl_t\r\n]. The actual poll is 36 char long, but you get the idea.
According to the documentation for UART (slau144.pdf), least RX error is at 12MHz and 19200baud rate which is almost 0. My configuration is as follows:
bsp_config.h
#define BSP_CONFIG_CLOCK_MHZ_SELECT 12
virtual_com_cmds.c
#elif (BSP_CONFIG_CLOCK_MHZ_SELECT == 12)
// 19200 from 12Mhz
UCA0BR0 = 0x71;
UCA0BR1 = 0x2;
UCA0MCTL = 0;
main_AP.c
#define CMD_MAX_LEN 36
char cmdBuffer[CMD_MAX_LEN];
#pragma vector=USCIAB0RX_VECTOR
__interrupt void USCI0RX_ISR(void) {
char rx = UCA0RXBUF;
memmove(cmdBuffer, cmdBuffer + 1, sizeof(cmdBuffer) - sizeof(cmdBuffer[0]));
cmdBuffer[sizeof(cmdBuffer) - 1] = rx;
if (cmdBuffer[34] == '\r' && cmdBuffer[35] == '\n') {
if (isPOLL()) {
doSomething1(); //TX data back to the client
memset(cmdBuffer, 0x0, sizeof(cmdBuffer));
} else if (isAudit()) {
doSomething2(); //TX data back to the client
memset(cmdBuffer, 0x0, sizeof(cmdBuffer));
} else { //output what's in the buffer presuming that wrong command has been sent by a client
char tmp[36];
int i;
int out = 0;
for (i = 0; i < sizeof(tmp); ++i) {
if (cmdBuffer[i] != '\0') {
tmp[out] = cmdBuffer[i];
++out;
}
}
TXString(tmp, out);
memset(cmdBuffer, 0x0, sizeof(cmdBuffer));
}
}
}
In the main loop I removed self measuring part of the temperature, Access Point is just listening for the incoming frames from End Devices.
In general it works fine, except occasional UART RX errors!
If I am doing something silly or it could be done more efficiently, please excuse me as I am not a strong embedded C programmer.
I would appreciate any help!
Best Regards,
Rihards