We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Board: Teensy 4.1 Arduino: 1.8.19 Teensyduino: 1.56 All options default
When you call delayNanoseconds(x) where x > ~470000, it returns early. I suspect there's an overflow with this line:
delayNanoseconds(x)
uint32_t cycles = ((F_CPU_ACTUAL>>16) * nsec) / (1000000000UL>>16);
delayNanoseconds(460000) -> cycles = 276006 delayNanoseconds(470000) -> cycles = 516
Complete code that illustrates problem:
#include <stdint.h> void setup() { Serial.begin(9600); } static constexpr int n_loops = 10000; static int i = 0; static uint32_t start_time_micros, end_time_micros, delta_time_micros, delay_micros, delay_nanos; void loop() { if(i == 0){ Serial.printf("Start test...\n"); } if(i < n_loops){ delay_micros = max(i, 1); delay_nanos = delay_micros * 1000; start_time_micros = micros(); //delayMicroseconds(delay_micros); // This test passes delayNanoseconds(delay_nanos); // This test fails end_time_micros = micros(); delta_time_micros = end_time_micros - start_time_micros; if (delta_time_micros < (delay_micros - 1)){ Serial.printf("delay_micros = %d us\tdelta_time_micros = %lu us\n", delay_micros, delta_time_micros); } } if(i == n_loops){ Serial.printf("Done!\n"); } i++; }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Board: Teensy 4.1
Arduino: 1.8.19
Teensyduino: 1.56
All options default
When you call
delayNanoseconds(x)
where x > ~470000, it returns early. I suspect there's an overflow with this line:Complete code that illustrates problem:
The text was updated successfully, but these errors were encountered: