Embedded Road , The most important thing is daily drip

                                                                --- Ajie sends code online

first , You have to understand that we are sending ASCII code , Namely character .

Single byte transmission
*uart.c void usart1_out(unsigned char arr) { USART_SendData(USART1,arr);
while(USART_GetFlagStatus(USART1,USART_FLAG_TC)==RESET){;} } *uart.c void
USART1_IRQHandler(void) // Serial port 1 Interrupt service routine { u8 Res; // Entry interrupt , Identify whether to accept data , Execute if yes
if(USART_GetFlagStatus(USART1,USART_IT_RXNE) != RESET) {
Res=USART_ReceiveData(USART1); if(Res=='A') lanya_UART1_flag = 1;// forward
if(Res=='B') lanya_UART1_flag = 2;// backward if(Res=='C') lanya_UART1_flag = 3;// towards the left
if(Res=='D') lanya_UART1_flag = 4;// towards the right if(Res=='E') lanya_UART1_flag = 5;// accelerate
if(Res=='F') lanya_UART1_flag = 6;// Decelerate if(Res=='S') lanya_UART1_flag = 7;// stop it
usart1_out(Res);// Return to the upper computer assistant display } }
Multibyte transmission

first , It needs to be configured in advance

*uart.c // With this, we can use printf Output multiple characters int fputc(int ch, FILE * f)//stdio.h ->673 {
USART_ClearFlag(USART1,USART_FLAG_TC); USART_SendData(USART1, (u8) ch);
while(USART_GetFlagStatus(USART1, USART_FLAG_TC) == RESET); return ch; }
*main.c int main(void) { u16 pwm = 500; uart_init(9600);// Initialize baud rate while(1) {
printf("%03d",pwm); } }

Technology
©2019-2020 Toolsou All rights reserved,
C++ of string of compare usage Python Study notes ( one )evo Tool usage problems ——Degenerate covariance rank, Umeyama alignment is not possibleRISC-V_GD32VF103-TIMER0 timer interrupt java Array subscript variable _Java Basic grammar : array be based on stm32 Control four-wheel trolley motor drive ( one ) be based on redis Design of liking function Software engineering career planning mysql Query random data by conditions _MySQL Random query of several qualified records centos7 install RabbitMq