We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hi, I wanted to write a simple program that doesn’t use interrupts or check any of the possible error flags, but that shows a simple UART application for receiving data. This is a part of the code I wrote.
int uart0Getch(void)
{
if (LPC_UART->LSR & LSR_RDR) // check if character is available
{ return LPC_UART->RBR; // return character
}
return -1;
#include "includes.h"
#include "uart.h"
int value;
extern int main( void )
system_init();
screen1[0]='a';
screen1[1]='b';
screen1[2]='c';
while(1)
//KeyScanProc(buf,screen1);
if ((value = uart0Getch()) >= 0)
send_to_uart(screen1,3);
Have you tried not calling uart0TxFlush ?
(it should not be necessary to flush the outgoing data, and is not recommended).
Ok, let me try that and see if it works. Thanks for all!
2015-01-13 12:45 GMT-04:30 jensbauer <community@arm.com>:
<http://community.arm.com/?et=watches.email.thread> Receiving DataUsing the UART CORTEX M0reply from jensbauer<http://community.arm.com/people/jensbauer?et=watches.email.thread> in *ARMProcessors* - View the full discussion<http://community.arm.com/message/24330?et=watches.email.thread#24330>
<http://community.arm.com/?et=watches.email.thread> Receiving Data
Using the UART CORTEX M0
reply from jensbauer
<http://community.arm.com/people/jensbauer?et=watches.email.thread> in *ARM
Processors* - View the full discussion
<http://community.arm.com/message/24330?et=watches.email.thread#24330>
Just in case you were wondering why flushing is probably not what you want:
fflush(stdout); for printf will send all cached characters to the current output device.
flushing the transmit-buffer in a UART, means to throw away any data that has not yet been sent.
That means if you send the string:
"Hello World"
and you flush the transmit-buffer immediately after, you'll probably end up receiving only the first few charaters, perhaps only "He" or "Hel".
Yes, in fact I just ran the program with the flush function and the output
was something like: "HEL W". Thank you very much for your help!!! It has
been very useful
2015-01-13 15:32 GMT-04:30 jensbauer <community@arm.com>:
<http://community.arm.com/?et=watches.email.thread> Receiving DataUsing the UART CORTEX M0reply from jensbauer<http://community.arm.com/people/jensbauer?et=watches.email.thread> in *ARMProcessors* - View the full discussion<http://community.arm.com/message/24333?et=watches.email.thread#24333>
<http://community.arm.com/message/24333?et=watches.email.thread#24333>