Question Detail
I would like to know how to use the SCI I/O model (hardware UART) on a Series 5000 chip. It seems like some data bytes are missing when I try to read the incoming data. How can I avoid data loss?
Solution
To use the SCI I/O model properly on series 5000 chips, perform the following tasks: .
- Ensure that Series 5000 Tools Update 2 is installed for your tool (the NodeBuilder FX Development Tool or Mini FX Evaluation Kit). Download it from http://downloads.echelon.com/support/downloads/detail.aspx?partNum=153-0366-01A . Follow the instructions in the readme for the update, and ensure that the gen.lib and echelon.h files are updated.
- Use the
sci_in_request_ex()
function instead of theio_in_request()
function. The sci_in_request_ex() function has different parameters from the io_in_request()function. This is shown in the example below. - Use a "double buffering" technique to switch between two different incoming data buffer so that you will not miss any data.
The following Neuron C code example demonstrates steps 2 and 3, above:
// pragmas
#pragma num_alias_table_entries 0
#pragma specify_io_clock "10 MHz"
// SCI_4800 etc., are declared in this header file
#include <io_types.h>
// SCI declaration
IO_8 sci baud(SCI_115200) iosci;
// Buffers and variable declarations
char szRxBufA[50];
char szRxBufB[50];
unsigned short rx_count;
int bufTog;
// Function declaration
void processRxData(char buffer[50], unsigned short rx_count);
when(io_in_ready(iosci))
{
// Switch to the other buffer and keep the RX count
rx_count = sci_in_request_ex((bufTog) ? szRxBufA : szRxBufB, sizeof(szRxBufA));
bufTog ^= 1; // toggle this
// Do something with RX data using the filled data buffer.
// It may be only a few bytes, or it may be close to 50 bytes.
processRxData((bufTog) ? szRxBufA : szRxBufB, rx_count);
}
when (reset)
{
(void)io_in_request(iosci, szRxBufA, 50);
bufTog = 0; // indicates that A is in use.
}
void processRxData(char buffer[50], unsigned short rx_count)
{
io_out_request(iosci, buffer, rx_count);
}
Related Products
- FT 5000
- Mini EVK
- Mini FX
- Neuron 5000
- Neuron C
- Neuron Chips
- NodeBuilder FX
Comments