STM32串口收发单字节数据原理及程序实现
2024-4-19 16:42
- ST MCU
- 27
- 534
程序现象:
main.c
#include "stm32f10x.h" // Device header
#include "DELAY.h"
#include "OLED.h" ...
Serial.h
#ifndef __SERIAL_H
#define __SERIAL_H
#include
void Serial_Init();
void Serial_SendByte ...
函数代码:
Serial.c
#include "stm32f10x.h" // Device header
#include
#include
uin ...
主函数实现:
int main() {
OLED_Init();
Serial_Init();
OLED_ShowString(1, 1, "RxData:");
while ...
这里两个变量Serial_RxData; Serial_RxFlag为事先定义好的全局变量,表示收到的数据和标志位。
这 ...
使用中断:
在初始化中,已经将NVIC初始化,这里编写中断函数
void USART1_IRQHandler() {
if(USA ...
这个代码就是不使用中断直接进行数据接收操作,如程序所示,在主函数while循环中,不断地查询RXNE标志位是 ...
两种实现方式:
不使用中断,直接在主函数实现:
while(1){
if(USART_GetFlagStatus(USART1, USART_FLAG ...
线路连接:
显示屏的SCA接在B11,SCL接在B10,串口的RX连接A9,TX连接A10。
程序编写:
...
定时器点灯
2024-3-31 12:33
- GigaDevice GD32 MCU
- 7
- 945
STM32 定时器编码器模式时,如何理解编码器计数
2024-4-1 13:52
- ST MCU
- 6
- 275
2
3
近期访客