Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
10 years, 9 months ago.
How can i access to UART0 RBR and THR?
Hi, i'm stuck with a project. I have to do a serial communication and access to UART0 receiver buffer register and transmit hold register using the CMSIS. I have basically no idea how to do that. Ones i have define the baudrate (with the function en Serial.h) and the interrupt for the serial port (with the attach function), what i have to put in the callback?
Thank so much in advance, Giacomo
2 Answers
10 years, 9 months ago.
You have to put in the callback what you want the callback to do. But how is that related to your question how to access RBR/THR? Can you try to describe more precise what you want to do exactly?
Regarding the title question:
LPC_UART0->RBR LPC_UART0->THR
Without looking it up, but I believe they are the ones.
10 years, 9 months ago.
In my project everytime i have to read or write on the buffer i have to do that using interrupt on UART0. So if i understood well i have to do in the callback for example
void callback(){ if(pc.readable()) { Cr=LPC_UART0->RBR; os_sys_init(tsinicio); isr_evt_set(EVENTOCR, idrx); }else{ if (pc.writeable()){ os_evt_wait_or(EVENTOTXACK, EVENTOTXNACK, EVENTORXTRAMA); for(indWbtx=0; indWbtx=BUFFER_SIZE, i++){ LPC_UART0->THR=bufferOUT[indWbtx]; } } }
Is it right? Thank you, Giacomo
I have no idea, why don't you just use pc.getc()/pc.putc? Also no idea what they rest is supposed to be, but if it is an RTOS (why not use the mbed RTOS?), you probably aren't allowed to put a wait in an interrupt. (With mbed RTOS you also aren't allowed to do putc/getc in an interrupt, solution is to use then RawSerial instead of Serial).
posted by 03 Mar 2014