From 4d69f1a0ef2ef3aa23b0ac9f1b9cbc84582136a7 Mon Sep 17 00:00:00 2001 From: Paul Selkirk Date: Sat, 6 May 2017 13:07:59 -0400 Subject: Correct offset to get the PC. A previous version of this code ran over the RTOS, where threads used the Process Stack, while the SysTick interrupt used the Main Stack. Now everything's on the main stack, so we need to account for 2 extra words that SysTick_Handler pushes on the stack at entry. --- libraries/libprof/profil.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'libraries/libprof/profil.c') diff --git a/libraries/libprof/profil.c b/libraries/libprof/profil.c index 07761dd..004af77 100644 --- a/libraries/libprof/profil.c +++ b/libraries/libprof/profil.c @@ -30,7 +30,7 @@ extern void set_SysTick_hook(void (*hook)(void)); /* sample the current program counter */ static void SysTick_hook(void) { - size_t pc = (size_t)((uint32_t *)__get_MSP())[5]; + size_t pc = (size_t)((uint32_t *)__get_MSP())[7]; if (pc >= prof.lowpc && pc < prof.highpc) { size_t idx = PROFIDX (pc, prof.lowpc, prof.scale); prof.counter[idx]++; -- cgit v1.2.3