2020-09-29 01:40 AM
hi i'm trying to use the stm32H750 uart with Interrupt i managed to get it working but the message is a bit off ( alot ) here is a bit of the code
uint8_t tx_buff[]=" ";
uint8_t rx_buff[20];
HAL_UART_Receive_IT(&huart1, &rx_buff[0], 20);
void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart){
n3=n3+5;
HAL_UART_Receive_IT(huart, &rx_buff[0], 20);
check = rx_buff[0];
if (check==67){
n1=n1+100;
};
HAL_UART_Transmit_IT(&huart1, rx_buff, 21);
}
what i'm doing to try it , is that i'm monitoring via stmstudio and whenever a message arrive i'll rederect to the the host and read it again
here are the results
rx is coming back from mcu
2020-10-01 07:15 AM
See what it is directly after reset. That's probably the correct value. You could also check the datasheet and reference manual.
2020-10-01 09:30 AM
Ok, then try some simple echoing...
Like
while(1)
{
if((USART1->ISR & USART_ISR_RXNE) == 0) // Wait for Char
{
if (USART1->ISR & USART_ISR_ORE) // Overrun Error
USART1->ICR = USART_ICR_ORECF;
if (USART1->ISR & USART_ISR_NE) // Noise Error
USART1->ICR = USART_ICR_NCF;
if (USART1->ISR & USART_ISR_FE) // Framing Error
USART1->ICR = USART_ICR_FECF;
}
else // RXNE flagged
{
uint16_t data = USART1->RDR; // Read Char
while((USART1->ISR & USART_ISR_TXE) == 0); // Wait for Empty
USART1->TDR = data; // Send Char
}
} // sourcer32@gmail.com