2020-10-23 01:09 PM
How to measure the time from __asm__("nop") on STM32F730 using 216 MHz clock? I did try to check it using osciloscope without success. The time is bigger than 1/216 MHz.
2020-10-23 01:44 PM
DWT->CYCCNT will measure ticks. You'll need to figure out and subtract off the overhead for accessing it.
The Cortex-M7 pipeline is not as straightforward as it is for Cortex-M4. NOP instruction isn't guaranteed to take any time at all.
2020-10-23 01:45 PM
Why would you do it this way? Seems highly prone to caching and superscalar issues, not to mention interrupts.
Can't you use a 32-bit TIM to account for passage of time, or use the DWT_CYCCNT to count cycles?
2020-10-23 01:55 PM
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, finish, delta;
start = *DWT_CYCCNT;
...
finish = *DWT_CYCCNT;
delta = (finish - start);