stm32h750串口屏
时间: 2023-09-09 14:09:03 浏览: 125
在STM32H750上使用串口与屏幕进行通信,可以使用以下函数进行数据发送:
void HMI_Usart_SendDataValue(uint8_t *Head, int16_t data); //串口发送数据到HMI屏幕
void HMI_Usart_SendDataText(uint8_t *Head, uint8_t *SData); //串口发送字符数据到HMI屏幕\[1\]
在接收中断中,可以使用以下代码进行处理:
if(__HAL_UART_GET_IT(&Uart6_Handle,USART_IT_ORE)!=RESET) {
__HAL_UART_CLEAR_OREFLAG(&Uart6_Handle);
}
if((__HAL_UART_GET_FLAG(&Uart6_Handle,UART_FLAG_RXNE)!=RESET)) {
HAL_UART_Receive(&Uart6_Handle, (uint8_t *)(&temp),1, 1000);
BSP_RS485_BusFreeCount = 0;
USART_RX_vect(temp);
} else if(__HAL_UART_GET_FLAG(&Uart6_Handle,USART_IT_TC)!=RESET) {
__HAL_UART_CLEAR_IT( &Uart6_Handle, USART_IT_TC );
} else {
HAL_UART_Receive(&Uart6_Handle, (uint8_t *)(&temp),1, 1000);
}
__HAL_UART_CLEAR_OREFLAG(&Uart6_Handle);
if(__HAL_UART_GET_FLAG(&Uart6_Handle, USART_FLAG_NE) != RESET) {
__HAL_UART_CLEAR_NEFLAG(&Uart6_Handle);
}
if(__HAL_UART_GET_FLAG(&Uart6_Handle, USART_FLAG_FE) != RESET) {
__HAL_UART_CLEAR_FEFLAG(&Uart6_Handle);
}
if(__HAL_UART_GET_FLAG(&Uart6_Handle, USART_FLAG_PE) != RESET) {
__HAL_UART_CLEAR_PEFLAG(&Uart6_Handle);
}\[2\]
在发送数据时,可以使用以下代码:
if(BSP_RS485_TxState != RS485_TX_ING) {
BSP_RS485_BusFreeCount = 0;
Enter_485Tx();
p = RS485_Tx_Buf;
for(i=0; i<DatLen; i++) *p++ = *myData++;
pTx = RS485_Tx_Buf;
TxLen = DatLen;
Tx_Last = *pTx++;
HAL_UART_Transmit(&Uart6_Handle, (uint8_t *)&Tx_Last, 1, 10);
return TRUE;
}\[3\]
以上是在STM32H750上使用串口与屏幕进行通信的相关函数和代码。
#### 引用[.reference_title]
- *1* [基于HMI串口屏的协议(STM32)](https://blog.csdn.net/qq_43603289/article/details/119191886)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insert_down1,239^v3^insert_chatgpt"}} ] [.reference_item]
- *2* *3* [stm32h750 RS485收发问题](https://blog.csdn.net/u011983700/article/details/106449349)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insert_down1,239^v3^insert_chatgpt"}} ] [.reference_item]
[ .reference_list ]
阅读全文