本帖最后由 lc115647 于 2024-10-6 17:25 编辑
在项目开发过程中,经常会使用到串口外设模块实现数据交互,本文介绍如何使用E103的接收中断和空闲中断来实现串口数据分包段帧处理。
硬件准备:使用官方APM32E103ZE_EVALBOARD_V1.0评估板USART1模块实现;

软件SDK:基于APM32E10x_SDK_V1.2版本
1、主要通过使能下面两个中断控制寄存器的实现。

2、初始化串口参数

3、在apm32e10x_int.c中添加串口中断函数

4、在main.c中添加中断回调函数,在接受收中断中把接收寄存器值读入数组中,在空闲中断时把数组中的数据发送出去

5、在main函数中调用串口初始化、设置中断优先级

|