2022-04-09 05:33 PM
Can only be duplicated using LPTIM2, enabling interrupts for LPTIM1 works fine.
Hard Fault can be resolved by only re-locating the VTOR to a 512-byte boundary.
2022-04-10 01:03 PM
I have found the source of the crash and it can be duplicated using a slightly modified source of this ST LL sample app:
STM32CubeWB\STM32Cube_FW_WB_V1.13.0\Projects\P-NUCLEO-WB55.Nucleo\Examples_LL\LPTIM\LPTIM_PulseCounter
I have attached the code which will run as-is, but if you download and debug (run to main) and change this variable to zero:
lptimSel = 0
Then the code will crash by hard fault.
But, you can make it run with lptimSel=0 if you re-locate the vector table to a modulo 512 offset (e.g. 0x08008000, 0x08008200, 0x08008400, and so on). Of course, whenever you change the VTOR offset, you must change the value on main.c line 56 and in the linker file line 49 to match.
For operations relocating the vector table, the STM32WB Reference Manual refers you to PM0223, which shows on page 91, 4.3.4, that the restriction to re-locate is to an address modulo 128, which is of course satisfied by an address modulo 256 (e.g. 0x08008100 should be a good address to re-locate, but we see empirically with LPTIM2 that it is not).