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!
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 */
}