根据原子STM32F407的USART1修改成STM32F429的UART5无法实现通讯,还请指点以下初始化是否有错!

2019-07-21 00:34发布

void uart5_init(u32 pclk2,u32 bound)



float temp;
u16 mantissa;
u16 fraction;   
temp=(float)(pclk2*1000000)/(bound*16);//????USARTDIV@OVER8=0
mantissa=temp; //??????????·?
fraction=(temp-mantissa)*16; //??????????·?@OVER8=0 
    mantissa<<=4;
mantissa+=fraction; 
RCC->AHB1ENR|=(1<<2)|(1<<3);   //????PORTCPORTD???±??  
RCC->AHB1ENR|=1<<20;   //?????®??UART5?±?? 
// GPIO_Set(GPIOB,PIN6|PIN7,GPIO_MODE_AF,GPIO_OTYPE_PP,GPIO_SPEED_50M,GPIO_PUPD_PU);//PA9,PA10,????????,????????
GPIO_Set(GPIOC,PIN12,GPIO_MODE_AF,GPIO_OTYPE_PP,GPIO_SPEED_50M,GPIO_PUPD_PU);//PC12????????,????????
GPIO_Set(GPIOD,PIN2,GPIO_MODE_AF,GPIO_OTYPE_PP,GPIO_SPEED_50M,GPIO_PUPD_PU); //PD2????????,????????

  GPIO_AF_Set(GPIOC,12,8); //PC12
GPIO_AF_Set(GPIOD,2,8); //PD2   
//?¨?????è??
  UART5->BRR=mantissa; //?¨?????è??  
UART5->CR1&=~(1<<15); //?è??OVER8=0   
UART5->CR1|=1<<3;   //?®??·??????? 
#if EN_UART5_RX   //??????????????
//???????????? 
UART5->CR1|=1<<2;   //?®??????????
UART5->CR1|=1<<5;     //??????????·???????????    
MY_NVIC_Init(3,3,UART5_IRQn,2);//×é2??×????????? 
#endif
UART5->CR1|=1<<13;   //?®??????
}
//===============================================
void Uart5_putch(u8 k) 
{
if(k == ' ')
{
//????·?????×???????UART2??·?????????
UART5->DR = k;
//????·????ê??
  while (!(UART5->SR & USART_FLAG_TXE));
}
else
{
UART5->DR = k;
while (!(UART5->SR & USART_FLAG_TXE));
}
}



USART1已经能够正常使用,只是UART5找不到是哪里出问题了!还请原子指点
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。