Nations Technologies Inc.
Tel
:
+86-755-86309900
:
Address: Nations Tower, #109 Baoshen Road, Hi-tech Park North.
Nanshan District, Shenzhen, 518057, P.R.China
495
/
631
Transmi process
During an LPUART transmission, the least significant bit of the data is shifted out on TX pin. In this mode, the
LPUART_DAT register contains a buffer between the internal bus and the transmitter shift register (see Figure 23-1).
Each character is preceded by a low level starting bit; and is terminated by a stop bit.
Note: You cannot reset the LPUART_CTRL.TXEN bit during data transfer, otherwise the data on the TX pin will be
corrupted because the baud rate counter stops counting. The current data being transferred will be lost.
The LPUART sends data as follows:
1.
Configure baud rate, parity check, DMA, flow control, etc.
2.
Set the LPUART_CTRL.TXEN bit to enable data transmission.
3.
Write data to the LPUART_DAT register.
4.
Check if the LPUART_STS.TXC flag is set, it means the transmission is over. If the flag is set, write 1 to the
LPUART_STS.TXC bit to clear the flag.
5.
Check the LPUART_STS.PEF bit to confirm whether the parity is wrong.
6.
Otherwise, go to Step 3 and send the next data.
Note: Be sure to initialize the LPUART module before using the transmitter.
LPUART initialization as follows:
1.
Set all flag bits in the LPUART_STS register to clear the interrupt flag.
2.
To enable the interrupt function, configure LPUART_INTEN.
3.
Set LPUART_CTRL.FLUSH clear the RX buffer.
When send data:
After configuring the baud rate and setting LPUART_CTRL.TXEN, the CPU can write directly to the
LPUART_DAT register to send data.
When a frame transmission is completed (after the stop bit is sent), the LPUART_STS.TXC bit is set. If the
LPUART_INTEN.TXCIE bit is set, an interrupt occurs immediately.
After the last data byte is written to the LPUART_DAT register, you must wait for LPUART_STS.TXC=1 before
shutting down the LPUART module or setting the microcontroller into low-power mode.