小弟初学stm32串口通信,想通过串口1发送:5A A5 07 82 00 84 5A 01 00 01这样一串16进制数据,串口1接受后用16进制显示为:
5A A5 07 82 00 84 5A 01 00 01;写了代码中的5组数据,只有最后一个数据不同,通过HAL_UART_Transmit()发送,用串口助手
接受并√选Hex显示,结果只显示:5A A5 07 82;数据00及后面的数据无法输出了,请问大佬们是怎么回事啊?
int main(void)
{
const char str1[]={0x5A,0xA5,0x07,0x82,0x00,0x84,0x5A,0x01,0x00,0x01};
const char str2[]={0x5A,0xA5,0x07,0x82,0x00,0x84,0x5A,0x01,0x00,0x02};
const char str3[]={0x5A,0xA5,0x07,0x82,0x00,0x84,0x5A,0x01,0x00,0x03};
const char str4[]={0x5A,0xA5,0x07,0x82,0x00,0x84,0x5A,0x01,0x00,0x04};
const char str5[]={0x5A,0xA5,0x07,0x82,0x00,0x84,0x5A,0x01,0x00,0x05};
HAL_Init(); //初始化HAL库
Stm32_Clock_Init(336,8,2,8); //设置时钟,168Mhz
delay_init(168); //初始化延时函数
LED_Init(); //初始化LED
uart_init(115200); //初始化串口
while(1)
{
HAL_UART_Transmit(&UART1_Handler,(uint8_t*)str1,strlen(str1),1000);
delay_ms(1000);
HAL_UART_Transmit(&UART1_Handler,(uint8_t*)str2,strlen(str2),1000);
delay_ms(1000);
HAL_UART_Transmit(&UART1_Handler,(uint8_t*)str3,strlen(str3),1000);
delay_ms(1000);
HAL_UART_Transmit(&UART1_Handler,(uint8_t*)str4,strlen(str4),1000);
delay_ms(1000);
HAL_UART_Transmit(&UART1_Handler,(uint8_t*)str5,strlen(str5),1000);
delay_ms(1000);
}
}
一周热门 更多>