mimxrt: Fix cycle counter for time.ticks_cpu() and machine.bitstream().
Prior to this commit mp_hal_ticks_cpu() was not started properly. It only started when the code was executed with a debugger attached, except for the Teensy (i.MXRT1062) boards. As an additional fix, the CYYCNT timer is now started at boot time. Also rename mp_hal_ticks_cpu_init() to mp_hal_ticks_cpu_enable().
This commit is contained in:
parent
06d1b02014
commit
99221cd118
|
@ -48,7 +48,7 @@ void machine_bitstream_high_low(mp_hal_pin_obj_t pin, uint32_t *timing_ns, const
|
|||
}
|
||||
}
|
||||
// Enable the CPU cycle counter, which is not always enabled.
|
||||
mp_hal_ticks_cpu_init();
|
||||
mp_hal_ticks_cpu_enable();
|
||||
|
||||
uint32_t irq_state = mp_hal_quiet_timing_enter();
|
||||
|
||||
|
|
|
@ -75,7 +75,10 @@ static inline void mp_hal_delay_us(mp_uint_t us) {
|
|||
|
||||
#define mp_hal_delay_us_fast(us) mp_hal_delay_us(us)
|
||||
|
||||
static inline void mp_hal_ticks_cpu_init(void) {
|
||||
static inline void mp_hal_ticks_cpu_enable(void) {
|
||||
CoreDebug->DEMCR |= CoreDebug_DEMCR_TRCENA_Msk;
|
||||
DWT->LAR = 0xc5acce55;
|
||||
DWT->CYCCNT = 0;
|
||||
DWT->CTRL |= DWT_CTRL_CYCCNTENA_Msk;
|
||||
}
|
||||
|
||||
|
|
|
@ -56,6 +56,7 @@ void ticks_init(void) {
|
|||
NVIC_EnableIRQ(GPTx_IRQn);
|
||||
|
||||
GPT_StartTimer(GPTx);
|
||||
mp_hal_ticks_cpu_enable();
|
||||
}
|
||||
|
||||
void GPTx_IRQHandler(void) {
|
||||
|
|
Loading…
Reference in New Issue