This saves a cycle - and checks both values to avoid _isr change of either value based on code/executionteensy4-core
// TODO... | // TODO... | ||||
} | } | ||||
uint32_t micros(void) | |||||
{ | |||||
uint32_t ccdelta, usec, smc, scc; | |||||
do { | |||||
smc = systick_millis_count; | |||||
scc = systick_cycle_count; | |||||
} while ( smc != systick_millis_count || scc != systick_cycle_count ); // repeat if systick_isr | |||||
ccdelta = ARM_DWT_CYCCNT - scc; | |||||
usec = 1000*smc + (ccdelta/(F_CPU_ACTUAL/1000000)); | |||||
return usec; | |||||
} | |||||
uint32_t micros(void) | uint32_t micros(void) | ||||
{ | { | ||||
uint32_t ccdelta, usec, smc; | uint32_t ccdelta, usec, smc; |