In this use case, the USART module is configured for:
- Using USARTD0
- Baudrate: 9600
- Character length: 8 bit
- Parity mode: Disabled
- Stop bit: None
- RS232 mode
The use case sends a string of text through the USART.
Setup steps
Prerequisites
- System Clock Management (sysclk)
Example code
The following configuration must be added to the project (typically to a conf_uart_serial.h file, but it can also be added to your main application file.):
- Note
- The following takes SAM3X configuration for example, other devices have similar configuration, but their parameters may be different, refer to corresponding header files.
#define USART_SERIAL &USARTD0
#define USART_SERIAL_BAUDRATE 9600
#define USART_SERIAL_CHAR_LENGTH US_MR_CHRL_8_BIT
#define USART_SERIAL_PARITY US_MR_PAR_NO
#define USART_SERIAL_STOP_BIT false
Add to application initialization:
Workflow
- Initialize system clock:
- Create USART options struct:
- Initialize in RS232 mode:
Usage steps
Example code
Add to, e.g., main loop in application C-file:
Workflow
- Write a string of text to the USART: