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.
I have successfully set baud rate, stop bit and data of size 8-bit, but I'm unable to set the start bit. How can i do it? Peripheral device has frame size of 10-bit with 1 start bit.
I've attached my code.
thank you!
There's a discussion over on the Keil forums from a while back which might help: Baud rate setting for UART in LPC1788
There are other similar questions with code snippets that you can examine:
http://www.keil.com/forum/20854/lpc-1788-uart-recieves-no-data/
Also, a quick google brings up plenty of example code which is achieving the same thing.
Hope this helps,
Joe
Thank you joealderson I've successfully communicated with devices that require 8 bit data and one stop bit eg. SIM900 but I'm unable to communicate with devices that requires 1 start bit ,8 bit data and 1 stop bit. I cound not find any thing about the start bit in the user manual of LPC1788 ,I don't know how to set the frame format of 10 bit,is there any way?
Hello
The start bit must always be there: Something must be the signal that signifies the start of the frame and this is it. It is not an option. The only time I am aware that a change to the start bit can be made is to extend the start bit to 11 or 13 bit times on some UARTs to use with the LIN protocol.
Keil MDK 5 has a serial example using the MCB1768 board (BLINKY): I reproduce the configuration code from it below.
Bob
************************************************************************
/*----------------------------------------------------------------------------
Initialize UART pins, Baudrate
*----------------------------------------------------------------------------*/
void SER_Init (void) {
#ifndef __DBG_ITM
#ifdef __UART0 /* UART0 */
LPC_SC->PCONP |= ((1 << 3) | (1 << 15)); /* enable power to UART0 & IOCON */
LPC_PINCON->PINSEL0 |= (1 << 4); /* Pin P0.2 used as TXD0 */
LPC_PINCON->PINSEL0 |= (1 << 6); /* Pin P0.3 used as RXD0 */
#else /* UART1 */
LPC_SC->PCONP |= ((1 << 4) | (1 << 15)); /* enable power to UART1 & IOCON */
LPC_PINCON->PINSEL4 |= (2 << 0); /* Pin P2.0 used as TXD1 */
LPC_PINCON->PINSEL4 |= (2 << 2); /* Pin P2.1 used as RXD1 */
#endif
UART->LCR = 0x83; /* 8 bits, no Parity, 1 Stop bit */
UART->DLL = 9; /* 115200 Baud Rate @ 25.0 MHZ PCLK*/
UART->FDR = 0x21; /* FR 1,507, DIVADDVAL=1, MULVAL=2 */
UART->DLM = 0; /* High divisor latch = 0 */
UART->LCR = 0x03; /* DLAB = 0 */
}