原子哥:
请问一下,在串口程序中
void uart_init(u32 pclk2,u32 bound)ffice ffice" />
{
float temp;
u16 mantissa;
u16 fraction;
temp=(float)(pclk2*1000000)/(bound*16);//得到USARTDIV
mantissa=temp;//得到整数部分
fraction=(temp-mantissa)*16; //得到小数部分
mantissa<<=4;
mantissa+=fraction;
RCC->APB2ENR|=1<<2; //使能PORTA口时钟
RCC->APB2ENR|=1<<14; //使能串口时钟
GPIOA->CRH=0X444444B4;//IO状态设置
RCC->APB2RSTR|=1<<14; //复位串口1
RCC->APB2RSTR&=~(1<<14);//停止复位
//波特率设置
USART1->BRR=mantissa; // 波特率设置74
USART1->CR1|=0Xffice:smarttags" />200C; //1位停止,无校验位.
问题是:
1、为什么要对串口进行一次复位?对于程序的作用是什么?
2、对于USART1->CR1|=0X200C; 中设置0X200C具体意义是什么?有点不懂。
|