Hi
I am using STM32H7A3 Nucleo board. I am using uart receive in interrupt mode by enabling global interrupt.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-06-09 3:44 AM
After receiving some data through interrupt, Is there any way to disable interrupt mechanism and go back to blocking mode for receiving remaining data.
I tried NVIC_DisableIRQ(0 to disable interrupt.
After that when i tried to receive through blocking mode, it fails. I just need to know whether its possible in stm32?
- Labels:
-
Interrupt
-
STM32H7 series
-
UART-USART
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-06-09 5:16 AM
Yes, blocking mode should work after using any of interrupt functions unless you've left the interrupt function unfinished
(not completed or canceled).
Also, disable RX overrun detection in UART initialization. It can cause problems.
But it is better to not use any HAL functions for UART, rather make your own.
--pa
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-06-09 5:46 AM
Thanks for your response.
Please find attached code. What i am trying is read 5 characters from teraterm using UART interrupt method and stop interrupt after that. Then read 2 char by polling method.
But what i noticed is that after receiving 5 character through interrupt, the code is getting exited. It is not waiting for receiving 2 char. It would be great if you can help in this matter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-06-09 6:04 AM
Attached code not found.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-06-09 9:23 PM
PFA
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-06-09 9:24 PM
PFA
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-06-09 11:10 PM
Hi Pavel,
Can you please provide some solution for the attached code. I am using STM32H&A3 Nucleo board.
Thanks,
Jestina
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-06-10 6:16 AM
Any update?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-06-10 7:25 AM
Hi @JJoy.1​
Your code unfortunately has so many mistakes that IMHO it's hardly workable and beyond easy fix.
Calling HAL_UART_Receive_IT in the IRQ handler is very strange.
HAL_UART_RxCpltCallback looks strange too.
If this is a student assignment, request better documentation or examples from your teachers.
void USART3_IRQHandler(void)
{
/* USER CODE BEGIN USART3_IRQn 0 */
/* USER CODE END USART3_IRQn 0 */
HAL_UART_IRQHandler(&huart3);
/* USER CODE BEGIN USART3_IRQn 1 */
HAL_UART_Receive_IT(&huart3, status, 5);
/* USER CODE END USART3_IRQn 1 */
}
void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)
{
int j;
for(j =0; j <5; j++)
{
Serial_PutByte(status[j]);
resp =1;
}
NVIC_DisableIRQ(USART3_IRQn);
__HAL_UART_DISABLE_IT(&huart3,UART_IT_RXNE);
}
In any case I'd recommend disabling RX overflow. Change in MX_USART3_UART_Init
the line with huart3.AdvancedInit.AdvFeatureInit and add the next one:
static void MX_USART3_UART_Init(void)
{
.......
huart3.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_RXOVERRUNDISABLE_INIT;
huart3.AdvancedInit.OverrunDisable = UART_ADVFEATURE_OVERRUN_DISABLE;
if (HAL_UART_Init(&huart3) != HAL_OK)
....................
Good luck.
-- pa
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-06-10 7:33 AM
Hi Pavel,
From where can i call the disabling function - NVIC_DisableIRQ(USART3_IRQn);
Jestina
