This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Can't write into DWT Registers

Hello,

I want to measure microseconds with the Cycle Counter of the DWT-Unit on a STM32F7. After long long searching, I found a lot of examples to do this by setting the CoreDebug->DEMCR register with TRCENA and the DWT->CTRL register with CYCCNTENA.

So it seems to be a very easy code:

CoreDebug->DEMCR |= CoreDebug_DEMCR_TRCENA_Msk;
DWT->CYCCNT = 0;
DWT->CTRL |= DWT_CTRL_CYCCNTENA_Msk;

But with this code, nothing happens in the controllregisters (DEMCR and CTRL) all enable bits are 0 and the Cycle Counter doesn't run. I tested with and without a connected ULINKpro. With ULINKpro, the counter is running and my measurement works (CYCCNTENA=1).
But without ULINKpro despite with "DWT->CTRL |= 1" stays the CYCCNTENA bit 0 and the counter don't run...

Have anybody an idea, whats the reason for the missing write-access to the control register is? Also tests with "DWT->LAR = 0xC5ACCE55" don't change anything.

After the study of the ARMv7-ArchitectureRM and all the other referenced manuals I'm happy about any new ideas! Maybe I miss any bits in other modules like ITM...?

Thanks a lot!

Parents
  • This has worked for me on F7/CM7 platforms

    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
    
    ...
    
      *DWT_LAR = 0xC5ACCE55; // enable access
      *SCB_DEMCR |= 0x01000000;
      *DWT_CYCCNT = 0; // reset the counter
      *DWT_CONTROL |= 1 ; // enable the counter
    
    ...
    

Reply
  • This has worked for me on F7/CM7 platforms

    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
    
    ...
    
      *DWT_LAR = 0xC5ACCE55; // enable access
      *SCB_DEMCR |= 0x01000000;
      *DWT_CYCCNT = 0; // reset the counter
      *DWT_CONTROL |= 1 ; // enable the counter
    
    ...
    

Children