Browse Source

Merge pull request #308 from FrankBoesing/patch-2

optimized delayNanoseconds
teensy4-core
Paul Stoffregen 5 years ago
parent
commit
be8a8b9f4a
No account linked to committer's email address
1 changed files with 1 additions and 1 deletions
  1. +1
    -1
      teensy4/core_pins.h

+ 1
- 1
teensy4/core_pins.h View File

@@ -758,7 +758,7 @@ static inline void delayNanoseconds(uint32_t) __attribute__((always_inline, unus
static inline void delayNanoseconds(uint32_t nsec)
{
uint32_t begin = ARM_DWT_CYCCNT;
uint32_t cycles = ((uint64_t)F_CPU_ACTUAL * nsec) / 1000000000UL;
uint32_t cycles = ((F_CPU_ACTUAL>>16) * nsec) / (1000000000UL>>16);
while (ARM_DWT_CYCCNT - begin < cycles) ; // wait
}


Loading…
Cancel
Save