Enable and trigger an interrupt vector manually. This is not the usually way to trigger an interrupt but is just here for illustration purpose
#include "bsp.h"
int main(void)
{
HAL_Init(); /*Init HAL library*/
/*Enable interrupt vector WWDG_IRQ where the CPU will jump if a watchdog event happens*/
/*set to the lowest of the four priorities, third paramter indicates sub-priority but is not
in use for Cortex-M0 Mcu, it is here but compatibility reason on HAL libraries*/
HAL_NVIC_SetPriority( WWDG_IRQn, 2, 0 );
/*enable watchdog interrupt vector, the vector number defintions can be found at stm32g0b1xx.h*/
HAL_NVIC_EnableIRQ( WWDG_IRQn );
while (1)
{
/*Manually trigger the WWDG_IRQ interrupt vector*/
HAL_NVIC_SetPendingIRQ( WWDG_IRQn );
HAL_Delay( 300 ); /*300ms Delay*/
}
}
/*The program will jump here inmedialty after the function HAL_NVIC_SetPendingIRQ trigger the WWDG_IRQ interrupt.
The interrupt service rutine is declared as it is in sthe tartup_stm32g0b1xx.s file*/
void WWDG_IRQHandler( void )
{
/*we do something, it is not necesary to un-pending the interrupt since it does by hardware*/
}