本帖最后由 fredinand 于 2010-7-16 17:10 编辑
硬件状况:开发板一块,自制板卡一块
调试情况说明:串口配置如下:
USART_ClockInitStructure.USART_Clock = USART_Clock_Disable;
USART_ClockInitStructure.USART_CPOL = USART_CPOL_Low;
USART_ClockInitStructure.USART_CPHA = USART_CPHA_2Edge;
USART_ClockInitStructure.USART_LastBit = USART_LastBit_Disable;
USART_ClockInit(USART2, &USART_ClockInitStructure);
USART_InitStructure.USART_BaudRate = 115200;
USART_InitStructure.USART_WordLength = USART_WordLength_8b;
USART_InitStructure.USART_StopBits = USART_StopBits_1;
USART_InitStructure.USART_Parity = USART_Parity_No ;
USART_InitStructure.USART_HardwareFlowControl =USART_HardwareFlowControl_None;
USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;
USART_Init(USART2, &USART_InitStructure);
USART_Cmd(USART2, ENABLE);
采用8M的晶振,该程序在开发板上调试情况良好,串口助手接收数据正常,在本人自制的板卡上调试就出现了问题。串口助手接收到的数据与程序中发送的不同,但并非乱码,而是非常有规律的,比如我发送0,1,2,3四个数结果收到的十六进制数为00,7F,3F,7E.再比如我发送a,b,c,d结果收到的却是3D,7A,1E,79,结果不对但是非常固定。改变波特率也没有效果
十分的懊恼,不知道问题出在哪里,望大家给些提示! |