38 lines
846 B
Markdown
38 lines
846 B
Markdown
uart_polling
|
|
---
|
|
|
|
This is an example of UART polling
|
|
|
|
+ Select the UART TX/RX pins
|
|
|
|
```
|
|
// in main.c
|
|
#define CONFIG_UART_IO_TX_PORT GPIOA
|
|
#define CONFIG_UART_IO_TX_PIN GPIO_Pin_01
|
|
#define CONFIG_UART_IO_TX_AF_MODE GPIO_AF_1
|
|
#define CONFIG_UART_IO_RX_PORT GPIOA
|
|
#define CONFIG_UART_IO_RX_PIN GPIO_Pin_00
|
|
#define CONFIG_UART_IO_RX_AF_MODE GPIO_AF_1
|
|
```
|
|
|
|
+ Configure the parameters related to UART
|
|
+ It can be modified according to the requirements
|
|
|
|
```
|
|
// in main.c
|
|
#define CONFIG_BAUD_RATE_VALUE 38400
|
|
UART_WordLength_8b //Data bit 8
|
|
UART_StopBits_1 //Stop bit 1
|
|
UART_Parity_No //No check bit
|
|
UART_Mode_TxRx //Transmit-Receive Mode
|
|
```
|
|
|
|
|
|
## Log
|
|
|
|
Use serial port with baudrate 38400, 8bit, no parity check
|
|
|
|
+ PC sends 1~255 to PEC930
|
|
+ PEC930 receives and sends back data
|
|
|