usart串口输入后,一位位的用printf输出对应的数组元素,总是多48。比如本来是1,读出来应该是49,本来是2,读出来应该是50
//对所用数组的一些设置
#define USART_REC_LEN 10
#define EN_USART1_RX 1
extern uint16_t USART_RX_BUF[USART_REC_LEN];
extern uint16_t USART_RX_STA;
//USART串口的部分主要配置
USART_InitStructure.USART_BaudRate = bound;
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(USART1, &USART_InitStructure);
USART_ITConfig(USART1, USART_IT_RXNE, ENABLE);
USART_Cmd(USART1, ENABLE);
//输出函数
printf("%d",USART_RX_BUF[0]);
|