Interrupt doesn't work when UART received on STM32F469I DISCO.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-05-16 8:14 AM
I configured the UART: huart6. I set the global interrupt and I use touchgfx designer (so RTOS as well), maybe that is the reason I can't set the preemption priority lower than 5 for the UART interrupt. The problem is that I can send messages to ESP8266, but I can't receive the messages from the ESP... Here is the code form the interrupt uart receiving and the callback function:
/* USER CODE BEGIN 2 */
HAL_UART_Receive_IT(&huart6, buff_Rx, 13);
/* USER CODE END 2 */
.
.
.
/* USER CODE BEGIN 4 */
void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)
{
CpltDone = 1;
HAL_UART_Receive_IT(&huart6, buff_Rx, 13);
HAL_GPIO_WritePin(GPIOG, GPIO_PIN_11, GPIO_PIN_RESET);
}
/* USER CODE END 4 */
If I put a breakpoint into the callback function the code never stops and if I use breakpoint at another place I can't see values in "buff_Rx" buffer. I examined the line with logic analyzer and the values are correct on the line... but I never get them...
What can be the problem?
- ESP IO voltage is 3v3 and the STM's Arduino compatible pins are 5V and that could be the reason?? (but if I use the SPI communication it works well..)
- Or the problem is the priority of UART interrupt?
- Or something else?
Can anybody help me?
Thanks a lot!
- Labels:
-
Interrupt
-
STM32F4 Series
-
UART-USART
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-05-16 8:25 AM
Hi @SNEM.1​
Just some ideas.
When you set your breakpoint at "another place", could you check the content of the SR register of your UART/USART instance ? Just to check if the Overrun flag (ORE) is not raised, as this could prevent reception.
You could also check if ErrorCallback is executed.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-05-17 10:13 AM - edited ‎2023-11-20 5:20 AM
Thanks for the advice!
How my code actually works: when I send a message via UART/USART the other MCU makes its job and send back a message (sensor values) to the STM.
Based on your words I tried to see what happens in the registers but unfortunately I can't stop the running when I should receive the values.
So I set a breakpoint to the beginning of a "send message function" and when I call this 2nd time it's sure that I had to receive some values already.
Some interesting things (for me,because I don't really understand why it works this way):
- DR's value is always 0x17
- In CR1 the RXNEIE is 0 (but it should be 1 to enable interrupt, am I right?)
- After I sent the message and I stop the running at the very next instruction the registers value are the next: CTS 0, LBD 1, TXE 1, TC 1, RXNE 1, IDLE 1, ORE 1, and the others are 0 (and DR = 0x17)
It means that the message arrive in the shift register and try to transmit to the DR but there is some error? Or it means anything else? And I set the global interrupt for the USART but RXNEIE is 0...Why? :\ I'm not really experienced in this area. Thanks again for your advices!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-05-17 12:50 PM
upload your IOC file
TimerCallback tutorial! | UART and DMA Idle tutorial!
If you find my solution useful, please click the Accept as Solution so others see the solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-05-18 12:57 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-05-18 5:06 AM
Now I received some values somehow... but I had to restart the system and after that the problem comes again... Maybe some synchronization problem?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-05-18 5:28 AM
Clear the overrun error *ORE"
Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-05-18 5:51 AM
Now it seems to be good. What I had to do:
I didn't disconnect the UART lines while I restarted the STM board :D It looks like some synchronization problem... Can anybody explain this? :)
