想通过串口tx打印调试信息,但是始终调不通,没用中断,没用rx。示波器观察PA2时钟高电平。 代码如下: void SysClkInit(void) { CLK_CKDIVR_bit.CKM = 3; CLK_ICKCR_bit.HSION = 1; CLK_SWR = 1; CLK_PCKENR1_bit.PCKEN15 = 1; //USART1 CLK_PCKENR1_bit.PCKEN10 = 1; //TIM2 CLK_PCKENR2_bit.PCKEN27 = 1; //Boot ROM CLK_PCKENR2_bit.PCKEN20 = 1; //ADC1 } void SysUSART1Init(void) { SYSCFG_RMPCR1_bit.USART1TR_REMAP = 1; //USART1_TX on PA2 and USART1_RX on PA3 PA_DDR_DDR2 = 1; //output PA_ODR_ODR2 = 1; //data PA_CR1_C12 = 1; //push pull PA_CR2_C22 = 1; //10M USART1_CR1_bit.M = 0; //1 start bit, 8 data bits, n stop bit USART1_CR3_bit.STOP0 = 0; USART1_CR3_bit.STOP1 = 0; //1 stop bit USART1_CR1_bit.PCEN = 0; //parity disable USART1_BRR2 = 0x00; //9600 USART1_BRR1 = 0x0D; USART1_CR2_bit.TEN = 1; //transmitter enable USART1_CR1_bit.USARTD = 0; //usart enable } void UsartTxAByte(unsigned char ucData) { USART1_DR = ucData; while (0 == USART1_SR_bit.TXE); } |