I am having trouble getting the UART to read anything besides the address. Here's a sample of what I'm doing:
Code: Select all
//Write Address
serwriteaddress(fdserial, ReqMsg[0]); //ReqMsg[0] contains address
//Send Break to allow slave to reconfigure
_delay_us(10);
USER_ENTER_CRITICAL();
UART0->ucr = U0_CMD_ENA_TX;
UART0->ucr = U0_CMD_ENA_BK;
USER_EXIT_CRITICAL();
_delay_us(100);
UART0->ucr = U0_CMD_DIS_BK;
//Write Data
SerialWrite(&ReqMsg[1],ReqMsg[1]+1); //ReqMsg[1] contains msg length
/* Write operation works perfectly. Remote receive request successfully and
/* replies with proper data addressed to 5234 (addr 0x0E).
/* now read...
_delay_us(500);
cnt = 0;
cnt = SerialRecieve((char*)&buffer[0], 4);
// reads 4 bytes:
// 0xFF, 0x7F - reflected address from write operation
// 0xFF, 0x0E - proper address of 5234 from reply
SerialRXEnable(1);
cnt = SerialRecieve((char*)&buffer[1], 8);
// reads 1 byte, always 0x00, never actual data
In addition, You can see that the TX data is being reflected back from the external 485 transceiver chip. While the RX is disabled during TX, it is still in multidrop mode so it reads the reflection of the transmitted address and interrupts.
Any help or direction to more complete documentation would be appreciated. BTW, the serial.h(,cpp) library provided by Netburner seems to have only a few functions documented and then only on a very surface level. It took me a day to reverse engineer the cpp code to figure out why I am receiving an 0xFF every time an address is received. Is there any better documentation or examples of how to use these functions in a 485 multidrop application?