#define UART4_BASE (APB1PERIPH_BASE + 0x4C00)
/******UART4寄存器地址映射**************************/
#define UART4_SR (*(volatile unsigned long *) (UART4_BASE + 0x00))
#define UART4_DR (*(volatile unsigned long *) (UART4_BASE + 0x04))
#define UART4_BRR (*(volatile unsigned long *) (UART4_BASE + 0x08))
#define UART4_CR1 (*(volatile unsigned long *) (UART4_BASE + 0x0C))
#define UART4_CR2 (*(volatile unsigned long *) (UART4_BASE + 0x10))
#define UART4_CR3 (*(volatile unsigned long *) (UART4_BASE + 0x14))
#define UART4_GTPR (*(volatile unsigned long *) (UART4_BASE + 0x18))
以上是自己定义的映射,下面是定义的初始化,可为什么芯片上就是发不出来呢?请大家多提意见,急死了啊!芯片是STM32F103RET6
RCC->APB2ENR |= 1 << 4; //使能PORTC时钟
RCC->APB1ENR |= 1 << 19; //使能串口4UART时钟
GPIOC->CRH |= 0x44444B22;
RCC->APB1RSTR |= 1 << 19; //复位串口4
RCC->APB1RSTR &= ~(1<<19);//停止复位
//波特率设置
UART4_BRR = baud; // 波特率设置
UART4_CR1 |= 0X200C; //1位停止,无校验位.
//使能接收中断
UART4_CR1 |= 1 << 8; //PE中断使能
UART4_CR1 |= 1 << 5; //接收缓冲区非空中断使能
|