USART通讯问题请教楼主: 我也是用Example2中断方式和PC通讯的,检查UASRT1的各项配置好像都是正常的,但是我用SSVCOM32接收的数据是乱码,用超级终端只能收到个别字符,无法识别,感觉是波特率不对,是不是还有什么参数需要修改啊 USART_InitStructure.USART_BaudRate = 9600; USART_InitStructure.USART_WordLength = USART_WordLength_8b; USART_InitStructure.USART_StopBits = USART_StopBits_1; USART_InitStructure.USART_Parity = USART_Parity_Even; USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None; USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx; USART_InitStructure.USART_Clock = USART_Clock_Disable; USART_InitStructure.USART_CPOL = USART_CPOL_Low; USART_InitStructure.USART_CPHA = USART_CPHA_2Edge; USART_InitStructure.USART_LastBit = USART_LastBit_Disable; /* Configure the USART1 */ USART_Init(USART1, &USART_InitStructure); /* Enable the USART Transmoit interrupt: this interrupt is generated when the USART1 transmit data register is empty */ USART_ITConfig(USART1, USART_IT_TXE, ENABLE); /* Enable the USART Receive interrupt: this interrupt is generated when the USART1 receive data register is not empty */ USART_ITConfig(USART1, USART_IT_RXNE, ENABLE); /* Enable USART1 */ USART_Cmd(USART1, ENABLE); USART的波特率和主频是无关的,我跟踪进USART的初始化看了,应该和我修改了主频没有关系吧?
|