All IRQ handler not called when using STM32F107VCT
I am experiencing an issue with my STM32-based project. All interrupt handlers never invoked, including the SysTick handler and USART1_IRQ_Handler. I try to resolve the problem. here is my trying...
1. Vector Table Offset Register (VTOR) Configuration:
I have explicitly set SCB->VTOR = 0x08000000 to ensure the vector table points to the correct memory address. Despite this, the issue persists.
2. SysTick Initialization:
The HAL_InitTick function successfully initializes the SysTick, returning HAL_OK.
3. Global Interrupts:
I have attempted disabling and re-enabling global interrupts using __disable_irq() and __enable_irq() before initialized, but this had no effect.
4. Real-Time Operating System (RTOS):
No RTOS is being used in this project. The setup involves minimal configuration, primarily focusing on clock settings, which have been verified to function correctly.
5. SysTick Control and Status Register:
The CTRL register's 16th bit is set to 1, indicating that the SysTick counter is enabled. However, the SysTick handler is still not being called.
6. Debugger Behavior:
The debugger indicates that the SysTick handler's address is at 0x08000854. Despite this, breakpoints within the handler are never hit, suggesting it is not being invoked.
7. HAL_GetTick Function:
As a result of that, HAL_GetTick function(uwTick) return always zero.
8. SysTick Handler Priority:
The priority of the SysTick handler has been set to 0, the highest priority.
9. UART Interrupts:
After enabling UART and observing that the RXNEIE and RXNE bits are set to 1, the UART interrupt handler is also not being called.
10. Debugger:
Debugger set rcc->cfgr. As that result, the clock configuration of rcc cfgr set incorrectly. So i cleared cfgr register of rcc, RCC->CFGR = 0x00, before HAL_RCC_OscConfig has invoked.
11. code:
#define printr(fmt, ...) printf("[\x1b[31m%s\x1b[0m]" fmt "\r\n", __FUNCTION__, ##__VA_ARGS__)
#define printm(fmt, ...) printf(fmt "\r", ##__VA_ARGS__)
char uart_recv_buf[1024] = {0, };
void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)
{
if(&huart1 == huart)
{
HAL_UART_Receive_IT(huart, (void *)uart_recv_buf, sizeof(uart_recv_buf));
printm("%s", uart_recv_buf);
}
}
void uart_init()
{
HAL_UART_Receive_IT(&huart1, (void *)uart_recv_buf, sizeof(uart_recv_buf));
}
int _write(int file, char *ptr, int len)
{
(void) file;
HAL_UART_Transmit(&huart1, (void*) ptr, len, 10);
return len;
}
/*
uint32_t HAL_GetTick(void) {
if ((SysTick->CTRL >> 16) == 1) //1ms
{
uwTick++;
}
return uwTick;
}
*/
/*
void HAL_Delay(uint32_t Delay) {
uint32_t tickstart = HAL_GetTick();
uint32_t wait = Delay;*/
/* Add a freq to guarantee minimum wait */
/*if (wait < HAL_MAX_DELAY)
{
wait += (uint32_t) (uwTickFreq);
}
while ((HAL_GetTick() - tickstart) < wait){}
uwTick = 0;
}*/
/*
void HAL_IncTick(void) {
return;
}*/
/* USER CODE END PFP */
/* Private user code ---------------------------------------------------------*/
/* USER CODE BEGIN 0 */
void uart_printf(char *fmt, ...)
{
char uart_send_buffer[1024] = {0, };
va_list va;
va_start(va, fmt);
vsnprintf(uart_send_buffer, sizeof(uart_send_buffer), fmt, va);
HAL_UART_Transmit(&huart1, (uint8_t *)uart_send_buffer, strlen(uart_send_buffer), 10);
va_end(va);
}
/* USER CODE END 0 */
/**
* @brief The application entry point.
* @retval int
*/
int main(void)
{
/* USER CODE BEGIN 1 */
SystemInit();
RCC->CFGR = 0x00;
/* USER CODE END 1 */
/* MCU Configuration--------------------------------------------------------*/
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();
/* USER CODE BEGIN Init */
/* USER CODE END Init */
/* Configure the system clock */
SystemClock_Config();
/* USER CODE BEGIN SysInit */
/* USER CODE END SysInit */
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_USART1_UART_Init();
/* USER CODE BEGIN 2 */
//__disable_irq();
//__enable_irq();
uart_init();
/* USER CODE END 2 */
/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1)
{
HAL_GPIO_TogglePin(GPIOC, GPIO_PIN_4);
printr("uart send data");
HAL_Delay(500);
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
}
/* USER CODE END 3 */
}
Given these observations, I suspect that the inability to write to the option bytes and the potential misconfiguration of the vector table are contributing factors. The failure of both SysTick and UART interrupts suggests a broader issue with interrupt handling in the system.
I would appreciate any insights or suggestions from the community to help diagnose and resolve this problem.
