2022-02-21 05:02 AM
STM32G473VC, custom board.
I use an own bootloader which resides at address 0x00000000 , the user application resides at 0x00008000.
I did set external files correct to use the bootloader
in user application
system_stm32g4xx.c : #define VECT_TAB_OFFSET 0x00008000U
STM32G473VCTX_FLASH.ld : FLASH (rx) : ORIGIN = 0x8008000, LENGTH = 220K
in bootload application
STM32G473VBTX_FLASH.ld : FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 32K
in bootloader we use this code to jump to the user application
void deinitEverything()
{
//-- reset peripherals to guarantee flawless start of user application
HAL_TIM_Base_DeInit(&htim6);
HAL_CRC_DeInit(&hcrc);
HAL_SPI_DeInit(&hspi2);
HAL_NVIC_DisableIRQ(DMA1_Channel2_IRQn);
HAL_NVIC_DisableIRQ(DMA1_Channel1_IRQn);
HAL_NVIC_DisableIRQ(EXTI15_10_IRQn);
HAL_GPIO_DeInit(GPIOA, GPIO_PIN_1);
HAL_RCC_DeInit();
HAL_DeInit();
SysTick->CTRL = 0;
SysTick->LOAD = 0;
SysTick->VAL = 0;
}
static void jumpToApp(const uint32_t address)
{
const JumpStruct* vector_p = (JumpStruct*)address;
deinitEverything();
/* let's do The Jump! */
/* Jump, used asm to avoid stack optimization */
asm("msr msp, %0; bx %1;" : : "r"(vector_p->stack_addr), "r"(vector_p->func_p));
}
In user application we use this code to jump to bootloader
HAL_NVIC_SystemReset();
timer 7 is used as Timebase Source, FreeRTOS is also running.
We used this bootloader setup successfully in many other projects , but in this one the timer 7 interrupt stops interrupting if we jump to bootload code and back to user application.
This cause HAL_IncTick() not getting called, and uwTick staying at 0 . Which cause HAL_MspInit() ... HAL_SYSCFG_EnableVREFBUF() run in an endless loop.
The only different with other projects is that we use SPI in this bootloader to bootload , where we use UART in all other projects.
I checked the timer 7 registers which seems all fine .
the strange thing is that both bootloader and user application runs correctly after a reset or power down - up cycle. Bootloader starts first and starts user application which runs fine. But when i use (SPI) commands to switch to bootloader and back to user application, then the TMR7 interrupt stops working.
What else can i check to find out why timer 7 is not firing an interrupt?
Solved! Go to Solution.
2022-02-24 07:31 AM
i have removed __disable_irq which i have added the past days in the bootloader code while i was searching for a solution... now it works.
i don't understand 100% why, i guess i need more knowledge about the STM32 NVIC interrupt system to know whats going on. But good documentation about this part is hard to get .
anyway , Thank you for assisting !
2022-02-21 06:49 AM
Do you set SCB->VTOR to the correct value within your application? Are interrupts enabled globally? Is the timer's NVIC interrupt enabled?
2022-02-21 07:35 AM
SCB->VTOR shows the expected 0x8008000 in debugger.
interrupts are enabled in NVIC settings
as a test i have added this code in the beginning of the user application, which did not help.
int main(void)
{
/* USER CODE BEGIN 1 */
HAL_NVIC_EnableIRQ(TIM7_DAC_IRQn);
/* USER CODE END 1 */
2022-02-22 07:21 AM
i've read all i can about NVIC and have found some extra information trough debugger.
The moment the interrupts are not firing NVIC_ISER1 has value 0x800100, which means EXTI15_10_IRQn and TIM7_DAC_IRQn interrupts are activated. While timer 7 DIER and CR1 registers are also correctly initialized .
The NVIC_ICER1 contains the same value.
NVIC ISPR1 and ICPR1 (pending set and reset) contains also set bits, while these are all 0 when everything works fine. Can that be the cause no interrupts are fired?
I did not find a way to reset these registers at the start of the user application.
I found out no interrupt at all is fired while i EXTI interrupts and TMR7 should interrupt. Is there a register which can block all interrupts?
2022-02-22 07:50 AM
2022-02-23 07:34 AM
can't find whats wrong, __enable_irq() at the first line of main, does not help neither. Timer is activated and interrupt tmr7 is enabled in timer 7 registers.
the NVIC registers are the same compared with a working version.
What else is needed to execute an interrupt ? All registers looks correct, but there comes no signal handler ....
2022-02-23 08:43 AM
Read out SBC_ICSR and check/post.
JW
2022-02-23 09:06 AM
Are you jumping to the app from within an interrupt? If so, it's still in the interrupt so others won't fire unless they have higher priority.
2022-02-24 06:55 AM
this was the case, i have changed the code now so i jump to application when no interrupt is serving, but the outcome is the same
2022-02-24 06:59 AM