Hello,
i am new to Arduino programming. I am trying to generate multiple PWM pulses (Synchronous) with 50% duty cycle (as close to square wave as possible) using the digitalWriteFast command in Teensy 4.1. I am able to get 4.96MHz as well 5.13MHz but not able to get exact 5.00MHz. Can you guide me through this issue? Also, if I use delayNanoseconds of 100, it is giving me around 4.1 MHz and not 5MHz. Can someone explain the reason behind this as well? I needed exact 5MHz so that I can operate the piezo crystal at its resonance frequency to generate optimum amplitude.
Thank you.
i am new to Arduino programming. I am trying to generate multiple PWM pulses (Synchronous) with 50% duty cycle (as close to square wave as possible) using the digitalWriteFast command in Teensy 4.1. I am able to get 4.96MHz as well 5.13MHz but not able to get exact 5.00MHz. Can you guide me through this issue? Also, if I use delayNanoseconds of 100, it is giving me around 4.1 MHz and not 5MHz. Can someone explain the reason behind this as well? I needed exact 5MHz so that I can operate the piezo crystal at its resonance frequency to generate optimum amplitude.
Thank you.