进入猫次元 发表于 2025-10-22 18:40

CW32F030C8T6 UART中断接收完整示例代码

c
#include "cw32f030.h"

volatile uint8_t rxBuffer;
volatile uint16_t rxIndex = 0;
volatile uint8_t rxFlag = 0;

void UART_Configuration(void) {
    // 时钟、GPIO、UART参数配置(同上)
    // ...
}

void NVIC_Configuration(void) {
    // 中断优先级配置(同上)
    // ...
}

void UART_Interrupt_Enable(void) {
    // 启用RXNE中断(同上)
    // ...
}

int main(void) {
    // 初始化系统时钟
    SystemInit();
   
    // 配置UART
    UART_Clock_Enable();
    GPIO_Configuration();
    UART_Configuration();
    NVIC_Configuration();
    UART_Interrupt_Enable();
   
    while (1) {
      if (rxFlag) {
            // 处理接收到的数据
            ProcessReceivedData(rxBuffer, rxIndex);
            rxFlag = 0;
      }
    }
}

OKAKAKO 发表于 2025-10-22 20:15

中断接收完整示例代码参考一下

AdaMaYun 发表于 2025-10-23 15:05

过程中出现一些配置问题,楼主是如何解决的

中国龙芯CDX 发表于 2025-10-24 13:48

建议参考库文件进行程序编写
页: [1]
查看完整版本: CW32F030C8T6 UART中断接收完整示例代码