M52235EVB - Reading 2 bytes from UART

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

M52235EVB - Reading 2 bytes from UART

856 Views
JHarvey
Contributor I
Hey all, I'm pretty new to freescale products and was hoping someone could help me out.  I've been researching some issues for awhile and haven't made much progress.
 
We were able to modify the source in freescale_dynamic_http.c from the demo ColdFire_Lite project to read one byte from the serial port.
 
Code:
void collect_sensor_data( void ){     ...     ...     html_vars[14]  = MCF_UART1_URB;     html_vars_flags[14]  = 1;}

However, we need to read decimal numbers up to around 500, which would require 2 byes of data.  Is there any easy way to grab 2 bytes of data at a time from the UART?
 
Would I have to investigate multiple sends or DMA?
 
Thanks,
-Jesse
Labels (1)
0 Kudos
1 Reply

190 Views
mjbcswitzerland
Specialist V
Jesse

It doesn't seem a good idea to read directly from the UART at this position in a real application since it is simply getting the data byte that has arrived at the serial port. Any further which arrive will get lost (overrun) so it would be necesary to synchronise the requests to the real UART data which is not very practical in a real-word application.

It is best to add a UART driver which stores any data (any length up to the driver buffer size) and then retrieve these from the buffer instead. Then nothing will get lost, there is no synchronisation requirement and the driver can perform flow control (RTS/CTS or XON/OFF) to control any further flow of data between collection. You can then retrieve as much data as required via Web browser or other methods.

Take a look at the uTasker project since it contains also UART drivers (flow control, DMA or intetrrupt) as well as a complete TCP/IP stack - it is also fully supported (see http://www.uTasker.com/forum/) as well as being open-source and completely free for non-commercial work. On top of that you can use its simulator to develop and test M5223X projects without hardware which can greatly increase development efficiency.

Regards

Mark

www.uTasker.com



0 Kudos