On 16/07/2023 21:52, Liviu Ionescu wrote:

On 16 Jul 2023, at 22:13, Tomas Vanek<tom_...@users.sourceforge.net>  wrote:

Just to be sure, check the counter with J-Link and ST-LINK GDB server
I placed a breakpoint on the `pendsv_cnt++;` in the PendSV_Handler, and an 
Expression watch in Eclipse on the `pendsv_cnt` variable.
Such breakpoint would collide with the induced rogue break - don't place any breakpoint to the PendSV_Handler(), just watch `pendsv_cnt` when execution
stops at BKPT instruction.


With both the J-Link and the ST-LINK GDB server, the PendSV_Handler was invoked 
only once (the breakpoint was hit once, and the watch reads the value of 1),

although this should not happen if the interrupts are disabled at reset.
???
ARM DDI 0403E.b:

B1.5.1 Overview of the exceptions supported
PendSV is permanently enabled, and is controlled using the ICSR.PENDSVSET and
ICSR.PENDSVCLR bits.

but

C1.6.2 Debug Halting Control and Status Register, DHCSR
C_MASKINTS, bit[3]

When debug is enabled, the debugger can write to this bit to mask PendSV, SysTick and
external configurable interrupts:
0 Do not mask.
1 Mask PendSV, SysTick and external configurable interrupts.


We need to make sure the PendSV_Handler() is called because there is no rogue break issue without an interrupt. Simply `pendsv_cnt` must be incremented before each stop at BKPT. If not, the debugger masks interrupts.

T


Reply via email to