Can anyone advise why my actions described below do not work?:
I have been trying to run the code snippet from the post Can Cortex M4 data watchpoint trigger an interrupt without a debugger? on(STM32F407VG board emulated with QEMU on eclipse.), but the DebugMon_Handler is not triggered even after enabling it by adding the extra two lines mentioned as a solution in that post.
I have also tried on Keil uMicrovision IDE and it throws the below error after running "DWT->COMP1 = &test_variable;" this line.
***** error 65: access violation at 0xE0001020 : no 'write' permission**
You can read more about my issue in the below link.
My CODE:
#include <stdio.h>
#include <stdlib.h>
#include "diag/Trace.h"
//#include "core_cm3.h"
#include "stm32f4xx.h"
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-parameter"
#pragma GCC diagnostic ignored "-Wmissing-declarations"
#pragma GCC diagnostic ignored "-Wreturn-type"
void watchpoint_enable()
{
CoreDebug->DEMCR = CoreDebug_DEMCR_TRCENA_Msk /*enable tracing*/ |
CoreDebug_DEMCR_MON_EN_Msk /*enable debug interrupt*/;
uint32_t test_variable;
trace_printf("enable watch points.... \n");
DWT->COMP1 = &test_variable;
DWT->MASK1 = 0; // match all comparator bits, don't ignore any
DWT->FUNCTION1 = (1 << 11) /*DATAVSIZE 1 - match whole word*/
| (1 << 1) | (1 << 2) /*generate a watchpoint event on write*/;
trace_printf("watch points enabled....\n");
test_variable = 5; // <<----- CPU stops after this line
}
int main(int argc, char *argv[])
{
watchpoint_enable();
}
void DebugMon_Handler(void)
{
trace_printf("Debug handler in action...\n");
}
#pragma GCC diagnostic pop