2025-11-14 12:43 AM - last edited on 2025-11-14 2:02 AM by Andrew Neil
Hey,
While doing UART communication between Arduino nano and STEVAL-ESC002V1
When i start my UART communication the control goes to function,
void USART1_IRQHandler(void)
{
#ifdef UART_COMM
uint32_t isrflags = READ_REG(huart.Instance->ISR);
uint32_t cr1its = READ_REG(huart.Instance->CR1);
/* -----------UART in mode Receiver ---------------------------------------------------*/
if(((isrflags & USART_ISR_RXNE) != RESET) && ((cr1its & USART_CR1_RXNEIE) != RESET))
{
if ((huart.gState!=HAL_UART_STATE_TIMEOUT)&&(huart.gState!=HAL_UART_STATE_ERROR))
{
huart.gState = HAL_UART_STATE_READY;
huart.RxState &= ~HAL_UART_STATE_READY;
huart.RxState |= HAL_UART_STATE_BUSY_RX;
if (UART_Receive_IT(&huart)==HAL_OK)
{
UART_Set_Value();
}
}
/* Clear RXNE interrupt flag */
__HAL_UART_SEND_REQ(&huart, UART_RXDATA_FLUSH_REQUEST);
}
/*------- UART in mode Transmitter (transmission end) -----------------------------*/
if(((isrflags & USART_ISR_TC) != RESET) && ((cr1its & USART_CR1_TCIE) != RESET))
{
UART_EndTransmit_IT(&huart);
return;
}
#endif
}
The control goes to "UART in mode Transmitter", but i think the control should go to "Uart in mode Receiver", the first if statement in which the ISR & SART_ISR_RXNE is not getting true.
Please guide what should i do,
Please guide me with the solutions so that i can eliminate my problem, and move for further development.
Below down i'm also attaching the reference Arduino nano code
#include <SoftwareSerial.h>
SoftwareSerial STM(12,11); //Rx,Tx
void setup()
{
// put your setup code here, to run once:
Serial.begin(9600);
STM.begin(9600);
// Serial.print("Arduino code step-up....");
}
void loop()
{
// put your main code here, to run repeatedly:
STM.print("SETSPD,");
STM.print(2000);
}Edited to apply source code formatting - please see How to insert source code for future reference.
2025-11-14 1:56 AM
Is it possible that you test the UART communication independently using another serial monitor device if uart interrupt is triggered or not ?
2025-11-14 2:24 AM
@STuser2 wrote:test the UART communication independently using another serial monitor device ?
^^^ Absolutely this! ^^^
@shashank7 You are making the classic mistake of trying to do both ends of the link at once.
This give you too many unknowns:
So, as always, break the problem down into simpler steps.
Also, before getting into the interrupt-driven comms, make sure that basic blocking comms works (HAL_UART_Transmit).
See also: Debugging Serial Comms.
#BothEnds #BothEndsUART
2025-11-14 2:41 AM
@shashank7 wrote:
void USART1_IRQHandler(void)
{
#ifdef UART_COMM
uint32_t isrflags = READ_REG(huart.Instance->ISR);
uint32_t cr1its = READ_REG(huart.Instance->CR1);
/* -----------UART in mode Receiver ---------------------------------------------------*/
if(((isrflags & USART_ISR_RXNE) != RESET) && ((cr1its & USART_CR1_RXNEIE) != RESET))
{What is the point of testing USART_CR1_RXNEIE within the interrupt handler ?