Nations Technologies Inc.
Tel
:
+86-755-86309900
:
info@nationstech.com
Address: Nations Tower, #109 Baoshen Road, Hi-tech Park North.
Nanshan District, Shenzhen, 518057, P.R.China
465
/
631
errors occurred during the transmission process. If it is not even, it means that an error has occurred, the
USART_STS.PEF flag is set to '1', and if USART_CTRL1.PEIEN is enabled, an interrupt is generated.
Odd parity
Configure USART_CTRL1.PSEL to 1, you can choose odd parity.
Make the number of '1' in the transmitted data (including
parity bit
) be an odd number. That is: if Data=11000101,
there are 4 '1's, then the
parity bit
will be '1' (5 '1' in total). After the data and check digit are sent to the receiver, the
receiver calculates the number of 1s in the data again. If it is an odd number, the check is passed, indicating that no
errors occurred during the transmission process. If it is not an odd number, it means that an error has occurred, the
USART_STS.PEF flag is set to '1', and if USART_CTRL1.PEIEN is enabled, an interrupt is generated.
DMA application
The USART supports the DMA mode using multi-buffer configuration, which can realize high-speed data
communication.
Using DMA transmission
Set USART_CTRL3.DMATXEN to enable DMA mode when transmitting. When the USART's transmit shift register
is empty (USART_STS.TXDE=1), the DMA will transfer the data from the SRAM to the USART_DAT register of
the USART.
When using DMA transmission, the process of configuring the DMA channel is as follows:
1.
Set the address of the data memory. When a data transfer request occurs, the transferred data will be read from this
address.
2.
Set the address of the USART_DAT register. When a data transfer request occurs, this address will be the
destination address of the data transfer.
3.
Set the amount of data to transfer.
4.
Set the priority of the channel, set whether to use the cyclic mode, the incremental mode of peripherals and memory,
the data width of peripherals and memory, the interrupt generated by half of the transfer or the interrupt when the
transfer is completed.
5.
Start the channel.
6.
After the data transfer is completed, the transfer complete flag (DMA_INTSTS.TXCFx) is set to 1.