cancel
Showing results for 
Search instead for 
Did you mean: 

Issue with UART/USB Rx interrupt in STM32F407VGT6 and using DP83848 LWIP stack.

Satya_VVM
Associate II

Hello, Good morning all,

I am doing a project with STM32F407VGT6 and DP83848 Ethernet Controller using LWIP stack. My requirement is UART/USB to Ethernet. I have enabled global interrupt and IRQ Handlers for both USB & UART, but when I send data from UART/USB RX interrupt is not enabling by MCU. Please suggest me the solution to enable USB/UART interrupt for receiving data.

Thanks and regards

Satyanarayana 

1 ACCEPTED SOLUTION

Accepted Solutions

Hello @Saket_Om

Thanks a lot for your valued support, actually there was an hardware issue.

Thanks

Satyanarayana

 

View solution in original post

11 REPLIES 11
Saket_Om
ST Employee

Hello @Satya_VVM 

Did you enable UART global interrupt in CubeMX side please?

If your question is answered, please close this topic by clicking "Accept as Solution".

Thanks
Omar

Hello @Saket_Om,

Yes, I have enabled global interrupts in .ioc configuration settings, I am receiving data from Ethernet to UART & USB, please find the screen shots for your reference.

Screenshot 2025-03-19 103202.png

Screenshot 2025-03-19 103139.png

void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)
{
if (huart->Instance == USART1)
{
Uart_RX_flag =1;
Tcp_send_flag =1;
HAL_UART_Receive_IT(&huart1,  (uint8_t *)Uart_RX_Buffer,strlen((char*)Uart_RX_Buffer));
if (huart->Instance == USART2)
{
Uart_RX_flag =1;
Tcp_send_flag =1;
HAL_UART_Receive_IT(&huart2,  (uint8_t *)Uart_RX_Buffer,strlen((char*)Uart_RX_Buffer));
}
}

  

and also I called in main function for UART1_IRQHandler(); HAL_UART_RxCpltCallback(&huart1);.
The Uart RX interrupt is working normally without LWIP software. Please suggest me in solving the problem
Thanks & Regards
Satyanarayana.
 

@Satya_VVM wrote:
and also I called in main function for UART1_IRQHandler(); HAL_UART_RxCpltCallback(&huart1);
 

Could explain more please? If possible share the code.

If your question is answered, please close this topic by clicking "Accept as Solution".

Thanks
Omar

Hello @Saket_Om 

In my project(UART to Ethernet), as I told you, UART RX interrupt is not working with the Lwip stack, but ethernet interrupt is working and receiving data from ethernet to UART, but my requirement is also to send from UART to ethernet. It has been observed that while using Lwip stack UART interrupts are not working. I am sharing the Uart code for your reference.

Uart Interrupt RX receive function:

void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)
{
if (huart->Instance == USART1)
{
Uart_RX_flag =1;
Tcp_send_flag =1;
HAL_UART_Receive_IT(&huart1,  (uint8_t *)Uart_RX_Buffer,strlen((char*)Uart_RX_Buffer));
}
if (huart->Instance == USART2)
{
Uart_RX_flag =1;
Tcp_send_flag =1;
HAL_UART_Receive_IT(&huart2,  (uint8_t *)Uart_RX_Buffer,strlen((char*)Uart_RX_Buffer));
}
UART1 Init function:
static void MX_USART1_UART_Init(void)
{

/* USER CODE BEGIN USART1_Init 0 */

/* USER CODE END USART1_Init 0 */

/* USER CODE BEGIN USART1_Init 1 */

/* USER CODE END USART1_Init 1 */
huart1.Instance = USART1;
huart1.Init.BaudRate = 115200;
huart1.Init.WordLength = UART_WORDLENGTH_8B;
huart1.Init.StopBits = UART_STOPBITS_1;
huart1.Init.Parity = UART_PARITY_NONE;
huart1.Init.Mode = UART_MODE_TX_RX;
huart1.Init.HwFlowCtl = UART_HWCONTROL_NONE;
huart1.Init.OverSampling = UART_OVERSAMPLING_16;
if (HAL_UART_Init(&huart1) != HAL_OK)
{
Error_Handler();
}
/* USER CODE BEGIN USART1_Init 2 */

/* USER CODE END USART1_Init 2 */

}

Main function:

int main(void)
{
HAL_Init();
SystemClock_Config();

MX_USART1_UART_Init();
MX_LWIP_Init();
MX_USART2_UART_Init();
MX_USB_DEVICE_Init();
USART1_IRQHandler();
USART2_IRQHandler();
OTG_FS_IRQHandler();
I2C1_ER_IRQHandler();
udpServer_init ();
app_echoserver_init();
HAL_UART_RxCpltCallback(&huart1);
HAL_UART_RxCpltCallback(&huart2);
HAL_PCD_RxCpltCallback(&hpcd);
HAL_UART_Receive_IT(&huart1, (uint8_t *)Uart_RX_Buffer,strlen((char*)Uart_RX_Buffer));
HAL_UART_Receive_IT(&huart2, (uint8_t *)Uart_RX_Buffer,strlen((char*)Uart_RX_Buffer));
}

 

@Satya_VVM 

Please use </> button to share your code.

Thank you for your understanding.

See this post.

Thank you for your understanding.

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.

Hello @Satya_VVM 

Please refer to the HAL user manual to get started with using HAL.

  • You should not call directly IRQ Handler routines, nor callbacks.
  • IRQ handler will be executed once a IRQ will occur.
  • Complete callbacks might be executed if IRQ processing detects that a process is completed.

The user should only initiate transfers using HAL API, as HAL_UART_Receive_IT().

If your question is answered, please close this topic by clicking "Accept as Solution".

Thanks
Omar

Hi, Thanks for the information.

Thanks 

Satya

Hello @Saket_Om 

Thanks for the information.

Thanks

Satyanarayana

Hello @Saket_Om 

I have tried with HAL_UART_Receive_IT() function, but still Uart interrupt is not working.

Thanks 

Satyanarayana