Question
DWT_CYCCNT does not seems to count cycle
I'm using follow code:
volatile unsigned int *DWT_CYCCNT = (volatile unsigned int *)0xE0001004; //address of the register
volatile unsigned int *DWT_CONTROL = (volatile unsigned int *)0xE0001000; //address of the register
volatile unsigned int *DWT_LAR = (volatile unsigned int *)0xE0001FB0; //address of the register
volatile unsigned int *SCB_DEMCR = (volatile unsigned int *)0xE000EDFC; //address of the register
*SCB_DEMCR |= 0x01000000;
*DWT_LAR = 0xC5ACCE55; // unlock
*DWT_CYCCNT = 0; // reset the counter
*DWT_CONTROL |= 1 ; // enable the counter
uint32_t start=0, end=0;
uint32_t array[100];
uint32_t idx=0;
*DWT_CYCCNT = 0;
start = *DWT_CYCCNT;
idx=1;
end = *DWT_CYCCNT;
idx=0;I put a breackpoint on line 18 and I get:
start=9
end=22
*DWT_CYCCNT = 29
I'm expecting that start could be something like 2 and end something like 4 or 6. Why I get this results?
Is DWT working in an stm32f722?
thank