Differences
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| stm32:peripherals:usart [2016/03/03 12:14] – created feur | stm32:peripherals:usart [2022/12/28 08:39] (current) – ruan | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ====== Universal | + | ====== Universal Asynchronous Receiver Transmitter ====== |
| - | The USART offers a very flexible, full-duplex, | + | The UART offers a very flexible, full-duplex, |
| Including IrDA and modem operations (CTS/RTS). \\ | Including IrDA and modem operations (CTS/RTS). \\ | ||
| Line 13: | Line 13: | ||
| * DMA and interrupt support. | * DMA and interrupt support. | ||
| \\ | \\ | ||
| - | |||
| - | ===== Programming Example ===== | ||
| ===== Configuration Registers ===== | ===== Configuration Registers ===== | ||
| - | ==== CRx ==== | + | ==== USART_CR1 - Configuration register 1 ==== |
| - | + | ||
| - | === CR1 === | + | |
| - | + | ||
| - | Configuration register 1 | + | |
| \\ {{usart_reg_cr1.svg}} \\ \\ | \\ {{usart_reg_cr1.svg}} \\ \\ | ||
| Line 43: | Line 37: | ||
| \\ | \\ | ||
| - | === CR2 === | + | ==== USART_CR2 - Configuration register 2 ==== |
| - | + | ||
| - | Configuration register 2 | + | |
| \\ {{usart_reg_cr2.svg}} \\ \\ | \\ {{usart_reg_cr2.svg}} \\ \\ | ||
| Line 56: | Line 48: | ||
| \\ | \\ | ||
| - | ==== BRR ==== | + | ==== USART_BRR - Baud rate register |
| - | + | ||
| - | Baud rate register | + | |
| \\ {{usart_reg_brr.svg}} \\ \\ | \\ {{usart_reg_brr.svg}} \\ \\ | ||
| Line 69: | Line 59: | ||
| ===== Status Register ===== | ===== Status Register ===== | ||
| - | ==== SR ==== | + | ==== USART_SR - Status register |
| \\ {{usart_reg_sr.svg}} \\ \\ | \\ {{usart_reg_sr.svg}} \\ \\ | ||
| Line 84: | Line 74: | ||
| ===== Data Register ===== | ===== Data Register ===== | ||
| - | ==== DR ==== | + | ==== USART_DR - Data register |
| \\ {{usart_reg_dr.svg}} \\ \\ | \\ {{usart_reg_dr.svg}} \\ \\ | ||
| Line 92: | Line 82: | ||
| \\ | \\ | ||
| - | ===== Legend ===== | ||
| - | \\ {{legende.svg}} \\ \\ | + | ===== Programming Example ===== |
| + | |||
| + | ==== Setup GPIO ==== | ||
| + | |||
| + | <code c> | ||
| + | #include " | ||
| + | |||
| + | RCC-> | ||
| + | |||
| + | /* Configure GPIO pin A.0 and A.1 in alternate function mode. */ | ||
| + | GPIOA-> | ||
| + | GPIOA-> | ||
| + | |||
| + | GPIOA-> | ||
| + | GPIOA-> | ||
| + | |||
| + | GPIOA-> | ||
| + | GPIOA-> | ||
| + | </ | ||
| + | \\ | ||
| + | |||
| + | ==== Transmitting Data ==== | ||
| + | |||
| + | <code c> | ||
| + | #include " | ||
| + | |||
| + | RCC-> | ||
| + | |||
| + | UART4-> | ||
| + | UART4-> | ||
| + | |||
| + | UART4-> | ||
| + | UART4-> | ||
| + | while(!(UART4-> | ||
| + | UART4-> | ||
| + | while(!(UART4-> | ||
| + | UART4-> | ||
| + | while(!(UART4-> | ||
| + | </ | ||
| + | \\ | ||
| + | |||
| + | ==== Receiving Data ==== | ||
| + | |||
| + | <code c> | ||
| + | #include " | ||
| + | |||
| + | RCC-> | ||
| + | |||
| + | UART4-> | ||
| + | UART4-> | ||
| + | |||
| + | UART4-> | ||
| + | while(!(UART4-> | ||
| + | data_received = UART4-> | ||
| + | </ | ||
| + | \\ | ||