cancel
Showing results for 
Search instead for 
Did you mean: 

Debugger not entering the Callback interrupt functions

MichalPorazko
Associate III

I wrote a simple program using interrupts:

 

Turns on the LD2 the diode if signs "O", "N" and enter are received respectively, turns off if "O", "F", "F" and enter are received otherwise (Im passing only the parts where I made changes :(

 

/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */
#include <stdio.h>
#include <string.h>

/* USER CODE END Includes */

......

/* Private user code ---------------------------------------------------------*/
/* USER CODE BEGIN 0 */

#define LINE_MAX_LENGTH 80
static char line_buffer[LINE_MAX_LENGTH + 1];
static uint32_t line_length;
void line_append(uint8_t value)
{
  if (value == '\r' || value == '\n') {
    if (line_length > 0) {
      line_buffer[line_length] = '\0';
      if (strcmp(line_buffer, "on") == 0) {
        HAL_GPIO_WritePin(LD2_GPIO_Port, LD2_Pin, GPIO_PIN_SET);
      } else if (strcmp(line_buffer, "off") == 0) {
        HAL_GPIO_WritePin(LD2_GPIO_Port, LD2_Pin, GPIO_PIN_RESET);
      }
      line_length = 0;
    }
  }
  else {
    if (line_length >= LINE_MAX_LENGTH) {
      line_length = 0;
    }
    line_buffer[line_length++] = value;
  }
}

uint8_t uart_rx_buffer;
void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)
{
  if (huart == &huart2) {
    line_append(uart_rx_buffer);
    HAL_UART_Receive_IT(&huart2, &uart_rx_buffer, 1);
  }
}

/* USER CODE END 0 */

MichalPorazko_0-1746719418082.png

Unfortunately, as it is shown in the picture up, the debugger is not entering the interrupt code part and I don't know why 

2 REPLIES 2

What board are you using?

Before getting into interrupts, have you checked that you can received characters using simple polling?

Can you transmit OK?

 


@MichalPorazko wrote:

 as it is shown in the picture up, the debugger is not entering the interrupt code part and I don't know why 


All that picture shows is that you weren't in the interrupt at the time you took the screenshot.

The code you posted doesn't show anything which enables interrupts.

Please post a minimum but complete example which illustrates the issue.

Have you tried one of the standard ST examples?

A complex system that works is invariably found to have evolved from a simple system that worked.
A complex system designed from scratch never works and cannot be patched up to make it work.

Not showing code the initializes the NVIC, the USART2_IRQHandler() dispatching into HAL, or the initial priming of the HAL_UART_Receive_IT(&huart2, &uart_rx_buffer, 1)

Any functions reporting errors or failure status?

An error call-back?

Are other interrupts working? Would prove the Vector Table is being used.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..