初级会员

- 积分
- 193
- 金钱
- 193
- 注册时间
- 2014-9-11
- 在线时间
- 15 小时
|
5金钱
现在用的板子是stm32c8t6,不知道为什么用串口发送字节出现问题,现在发送0x01,上位机接收到的是0xe0,有知道怎么回事的吗?麻烦告诉我,急急急
串口配置如下:
GPIO_InitTypeDef GPIO_InitStructure;
USART_InitTypeDef USART_InitStructure;
RCC_APB2PeriphClockCmd( RCC_APB2Periph_GPIOB |RCC_APB2Periph_USART1|RCC_APB2Periph_AFIO, ENABLE);
GPIO_PinRemapConfig(GPIO_Remap_USART1, ENABLE);
/*USART1端口配置
  B6 TX 复用推挽输出PB7 RX 浮空输入模式*/
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6 ;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOB, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7 ;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
GPIO_Init(GPIOB, &GPIO_InitStructure);
/*--------------USART1 USART2配置-------------------*/
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_No;
USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
USART_InitStructure.USART_Mode = USART_Mode_Tx;
USART_Init(USART1, &USART_InitStructure);
USART_Cmd(USART1, ENABLE);
我直接在主函数里发送USART_SendData(USART1, ch);,ch为0x01,但上位机接收到的是0xec,使用重定向发送也不行,也是乱码
|
|