USART2_IRQHandler not called when using SEGGER_SYSVIEW_PrintfTarget.
Hello,
I am learning about RTOS and SEGGER tracing with a NucleoF7222ZE. For some reasons the UART2 IRQ handler is never called to get SEGGER continuous recoding. In the main I only call SEGGER_SYSVIEW_PrintfTarget like bellow.
int main(void)
{
/* USER CODE BEGIN 1 */
TaskHandle_t Task_RedLED_Handle;
BaseType_t TaskStatus;
/* USER CODE END 1 */
/* MCU Configuration--------------------------------------------------------*/
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();
/* Configure the system clock */
SystemClock_Config();
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_USART3_UART_Init();
MX_USB_OTG_FS_PCD_Init();
MX_USART2_UART_Init();
// CYCLCNT enable
DWT_CTRL |= ( 1 << 0);
// Initializing SEGGER UART
SEGGER_UART_init(115200);
// Starting SEGGER SYSVIEW
SEGGER_SYSVIEW_Conf();
// Creating Tasks
TaskStatus = xTaskCreate(Task_RedLED_Handler, "RedLED", 100, "Red LED TASK", 1, &Task_RedLED_Handle);
configASSERT(TaskStatus == pdPASS);
// Start FreeRTOS scheduler
vTaskStartScheduler();
while (1)
{
}
}static void Task_RedLED_Handler(void* parameters)
{
while(1)
{
// Needed for SEGGER print function
snprintf(user_msg, 100,"%s\n", (char*)parameters);
// SEGGER print function
SEGGER_SYSVIEW_PrintfTarget(user_msg);
//SEGGER_SYSVIEW_PrintfTarget("Toggling Red LED");
HAL_GPIO_TogglePin(LD3_GPIO_Port, LD3_Pin);
// 800 system tickes -> needs to be converted to ms
vTaskDelay(800);
HAL_GPIO_TogglePin(LD3_GPIO_Port, LD3_Pin);
vTaskDelay(800);
}
}Here is definition of UART2_IRQHandler.
void USART2_IRQHandler(void) {
int UsartStatus;
uint8_t v;
int r;
UsartStatus = USART_SR; // Examine status register
if (UsartStatus & (1 << USART_RXNE)) { // Data received?
v = USART_RDR; // Read data
if ((UsartStatus & USART_RX_ERROR_FLAGS) == 0) { // Only process data if no error occurred
(void)v; // Avoid warning in BTL
if (_cbOnRx) {
_cbOnRx(v);
}
}
}
if (UsartStatus & (1 << USART_TXE)) { // Tx (data register) empty? => Send next character Note: Shift register may still hold a character that has not been sent yet.
//
// Under special circumstances, (old) BTL of Flasher does not wait until a complete string has been sent via UART,
// so there might be an TxE interrupt pending *before* the FW had a chance to set the callbacks accordingly which would result in a NULL-pointer call...
// Therefore, we need to check if the function pointer is valid.
//
if (_cbOnTx == NULL) { // No callback set? => Nothing to do...
return;
}
r = _cbOnTx(&v);
if (r == 0) { // No more characters to send ?
USART_CR1 &= ~(1UL << USART_TXEIE); // Disable further tx interrupts
} else {
USART_SR; // Makes sure that "transmission complete" flag in USART_SR is reset to 0 as soon as we write USART_DR. If USART_SR is not read before, writing USART_DR does not clear "transmission complete". See STM32F4 USART documentation for more detailed description.
USART_TDR = v; // Start transmission by writing to data register
}
}
}