Issue with UART/USB Rx interrupt in STM32F407VGT6 and using DP83848 LWIP stack.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2025-03-17 10:47 PM
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
Solved! Go to Solution.
- Labels:
-
Interrupt
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2025-03-20 3:35 AM
Hello @Saket_Om
Thanks a lot for your valued support, actually there was an hardware issue.
Thanks
Satyanarayana
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2025-03-18 5:30 AM
Hello @Satya_VVM
Did you enable UART global interrupt in CubeMX side please?
Saket_Om
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2025-03-18 10:14 PM - last edited on ‎2025-03-19 1:25 AM by mƎALLEm
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.
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));
}
}
  
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2025-03-19 12:07 AM
@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.
Saket_Om
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2025-03-19 1:22 AM - last edited on ‎2025-03-19 1:27 AM by mƎALLEm
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));
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2025-03-19 1:26 AM
Please use </> button to share your code.
Thank you for your understanding.
See this post.
Thank you for your understanding.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2025-03-19 3:25 AM
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().
Saket_Om
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2025-03-19 4:54 AM
Hi, Thanks for the information.
Thanks
Satya
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2025-03-19 5:01 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2025-03-19 5:06 AM
Hello @Saket_Om
I have tried with HAL_UART_Receive_IT() function, but still Uart interrupt is not working.
Thanks
Satyanarayana
