2014-04-03 03:54 PM
Hello!
I would like to add watchpoints from application to DWT periphery on stm32f100, which would then trigger DebugMon_Handler to perform some diagnostic task. I have already written a simple driver which does that. The driver works when using GNU toolchain. Unfortunately, when trying to import the same code to Keil (uVision 4) HardFault occurs. The fault occurs when CoreDebug->DEMCR is accessed. Does anyone have any clues what might be wrong? Thanks. Bojan #dwt-keil-stm32f100-watchpoint2014-04-05 05:39 AM
And what was the cause of HF?
Perhaps you were accessing DEMCR in a wrong mode? Or you have made something with undefined behavior?2014-04-05 06:13 AM
I've used other code in Keil that touches DEMCR, and not observed issues. What address does it end up accessing? And can you share enough code for others to replicate your condition?
2014-04-07 12:33 PM
The dwt driver is attached.
Example: ...#include ''dwt.h''
uint32_t my_var; /* Watchpoint callback*/ void do_diagnostics(int32_t wp_n) { /* Do some diagnostics */ ... } int main(void) { dwt_Comp_Num_t wp_n; my_var = 0; /* init */ dwt_comp_init(); /* Setup Write access watchpoint on my_var. */ wp_n = dwt_watchp_set((void *) &my_var) ; /* Add callback to watch point. */ dwt_watchp_attach_callback(wp_n, do_diagnostics); my_var = 10; /* this should trigger a debug handler and callback */ ... } This code compiled with gcc works on stm32f1-discovery (stm32f100) board, but fails under Keil uVision4. Maybe I missed something ... Any suggestion would be really helpful. Thanks Bojan ________________ Attachments : dwt.c : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006I1C5&d=%2Fa%2F0X0000000bjd%2Fe73lIo86tenOrYS5wrnhYIWHZfbXfSBvWq49ZZLrn.E&asPdf=falsedwt.h : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006I1C0&d=%2Fa%2F0X0000000bje%2Fo1UwTaP4mt4nNgnxUwWTIc2xKE8xlUy9PR22R2.MGoM&asPdf=falsedwt_conf.h : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006I1Bv&d=%2Fa%2F0X0000000bjf%2FVKIGRajQbr8JQra4cVqdjsHCkuHmf2xUA9qKmkGJ1dU&asPdf=false