Bill Greiman
Well-known member
I have been using digitalWrite() with a scope to time various operations in a new version of ChibiOS/RT. I first characterized digitalWrite() timing with this program:
The result is this asymmetric trace:
I am curious why the high pulse is about 35 ns wide and the low pulse is about 45 ns wide. On Teensy 3.6 the pulses are slower but symmetric.
I doesn't bother my timing since I measure between rising edges then between falling edges to insure I subtract the correct amount for digitalWrite.
Teensy 4.1 really performs with ChibiOS 20.3.3. Context switch in 150 ns. This makes it really simple to get all the advantages of async DMA transfers by hiding the complexity using a semaphore in the driver.
Calls like SPI.transfer(buf, count) will sleep on the semaphore while the transfer happens so the thread with that call uses almost no CPU time.
ChibiOS is a tickless system so replacing delay with sleep for an interval uses no CPU time. Timer interrupts only happen if required.
I will soon post the ChibiOS update.
Code:
void setup() {
pinMode(LED_BUILTIN, OUTPUT);
}
void loop() {
digitalWrite(LED_BUILTIN, HIGH);
digitalWrite(LED_BUILTIN, LOW);
digitalWrite(LED_BUILTIN, HIGH);
digitalWrite(LED_BUILTIN, LOW);
digitalWrite(LED_BUILTIN, HIGH);
delay(1);
digitalWrite(LED_BUILTIN, LOW);
}
The result is this asymmetric trace:
I am curious why the high pulse is about 35 ns wide and the low pulse is about 45 ns wide. On Teensy 3.6 the pulses are slower but symmetric.
I doesn't bother my timing since I measure between rising edges then between falling edges to insure I subtract the correct amount for digitalWrite.
Teensy 4.1 really performs with ChibiOS 20.3.3. Context switch in 150 ns. This makes it really simple to get all the advantages of async DMA transfers by hiding the complexity using a semaphore in the driver.
Calls like SPI.transfer(buf, count) will sleep on the semaphore while the transfer happens so the thread with that call uses almost no CPU time.
ChibiOS is a tickless system so replacing delay with sleep for an interval uses no CPU time. Timer interrupts only happen if required.
I will soon post the ChibiOS update.