Sysprogs forums › Forums › VisualGDB › I'm not seeing printf(…) in interrupt callback with fast semihosting
- This topic has 2 replies, 2 voices, and was last updated 4 years, 4 months ago by
support.
-
AuthorPosts
-
June 26, 2021 at 16:30 #30782
GeneM
ParticipantI have a new project with fast semihosting enabled. Printf works fine in the main part of my project but doesn’t work in an interrupt callback. Seems like I’ve done this before with cout in a C++ program but this program is just C so far. Here’s the code in main that does work:
printf("Starting receive DMA\n");
if (HAL_UART_Receive_DMA(&UartHandle, (uint8_t *)rxBuffer, RXBUFFERSIZE) != HAL_OK)
{
Error_Handler();
}printf("Starting transmit DMA\n");
if (HAL_UART_Transmit_DMA(&UartHandle, (uint8_t*)txBuffer, TXBUFFERSIZE) != HAL_OK)
{
Error_Handler();
}Here’s the interrupt callback and some associated stuff where printf doesn’t work:
void usart2CharMatchCallback(UART_HandleTypeDef *huart);void USART2_IRQHandler(void)
{
HAL_UART_IRQHandler(&UartHandle);if (__HAL_UART_GET_FLAG(&UartHandle, UART_FLAG_CMF))
{
usart2CharMatchCallback(&UartHandle);
__HAL_UART_CLEAR_FLAG(&UartHandle, USART_ICR_CMCF);
}
}void usart2CharMatchCallback(UART_HandleTypeDef *huart)
{
HAL_Delay(1);
printf("hit HAL_UART_CharMatchIdleCallback\n");
}The Embedded Project C Library Type is “Newlib-nano with floating point support in printf() and scanf()
The Implementations is Minimal (no semihosting)
and I have the Fast Semihosting and Embedded Profiler Embedded Framework checked
and Semihosting console support in Embedded Debug Tweaking > ARM Semihosting is set to Enabled.
Suggestions?
Thanks
June 26, 2021 at 16:52 #30785GeneM
ParticipantActually something a little weird happened. I thought the C Library type and Implementations for _sbrk(), etc. were set as I described above. But they seem to have been reset under the hood to Newlib-nano and Minimal (no semihosting). Same issue though, printf works in main but not in the interrupt callback.
June 28, 2021 at 08:14 #30789support
KeymasterHi,
As far as VisualGDB is concerned, it will handle the semihosting calls regardless of the interrupt context. So it semihosting is not working, the underlying library is not issuing the semihosting calls properly. You can track it down by disabling semihosting handling on the VisualGDB side and calling printf() outside an interrupt handler. The semihosting call trigger by it will cause the debugger to stop like it was a breakpoint, so you can analyze the call stack, and then review the C library sources to understand why this branch of code is never reached within an active interrupt.
-
AuthorPosts
- You must be logged in to reply to this topic.