I am looking for pointers on how to debug an issue. I am attempting to alternate the PWM duty cycle using pwmEnableChannel and have verified via scope that this works when I call pwmEnableChannel from my main.c. But what I really want to do is call pwmEnableChannel via a callback that I register with a library. This, however, leads to a chSysHalt and the following stack-trace:
Code: Select all
(gdb) backtrace
#0 0x080094f4 in chSysHalt (
reason=0x801eb4c <__func__.8261> "pwmEnableChannel")
at ChibiOS_19.1.2/os/rt/src/chsys.c:206
#1 0x080136a4 in pwmEnableChannel.constprop.84 (channel=<optimized out>,
width=<optimized out>, pwmp=0x200035a0 <PWMD2>)
at ChibiOS_19.1.2/os/hal/src/hal_pwm.c:171
#2 0x0800f370 in ext_set_duty (args=<optimized out>, argn=<optimized out>)
at main.c:180
#3 0x080018ea in apply_continuation ()
#4 0x08001aec in run_eval ()
#5 0x08001fc6 in eval_cps_program ()
#6 0x0800f17e in cmd_repl.lto_priv.141 (chp=0x20001af8 <SDU1>,
argc=<optimized out>, argv=<optimized out>) at main.c:325
#7 0x0800d62c in cmdexec (argv=<optimized out>, argc=<optimized out>,
name=<optimized out>, chp=<optimized out>, scp=<optimized out>)
at ChibiOS_19.1.2/os/various/shell/shell.c:106
#8 shellThread (p=0x801dd0c <shell_cfg1>)
at ChibiOS_19.1.2/os/various/shell/shell.c:401
#9 0x08000352 in _port_thread_start ()
at ChibiOS_19.1.2/os/common/ports/ARMCMx/compilers/GCC/chcoreasm_v7m.S:122
Backtrace stopped: previous frame identical to this frame (corrupt stack?)
In this trace #5, #4, #3 takes place withing the external library code. at #2 it calls the callback (ext_set_duty) that in turn calls pwmEnableChannel which seems to lead to a "halt".
Any hints, pointers or ideas are very much appreciated. Thanks!