There are five examples. Three are small tests and two are serious data logging sketches.
I used timer 0 for the system timer so the OS tick time is 1024 usec or 976 Hz.
The fastest sketch for the Mega can log 976 samples per second to a csv file where each sample is the value of four analog pins.
Here is a description of the examples:
There are five examples in the ChibiOS/examples folder.
chBlinkPrint - A simple example of three threads. A high priority thread
blinks an LED, a medium priority thread prints a counter
every second, and the low priority idle loop increments the
counter.
chContextTime - Test to determine context switch time with a semaphore.
chFastLogger - Data logger optimized for 328 Arduino. Logs two analog pins
every tick (1024 usec tick).
chJitter - Test of jitter in sleep for one tick.
chMegaLogger - Data logger optimized for Mega. Logs four analog pins
every tick (976 samples per sec, four values per sample)
Great!
FYI - I am running ardu328p @7.37MHz, 57k6. When running chBlinkPrint the timing seems to be 2x slower (led blinks 2.5x per sec, each print 2secs) and the output is
0
490206
979938
1469669
1959827
..
When running chJitter I get constant 2286, 2322.
P.
..interesting, but it is a postmortem check..
BTW - I removed the ATOMIC_BLOCK(ATOMIC_FORCEON) around count++ in chBlinkPrint. I have a third thread making an average and diff on the count var, and it seems it works. It is really necessary to do it atomic way? P.
Edit: it seems it shall be atomic as it starts to print garbage after a minute..
Would it be possible to use timer2 for os_ticks and during os_idle to go into extended standby mode?
Timer2 runs during that mode from xtal clk, can wake up the cpu when os_tick fires and it takes only 6clock cykles to wake up. So when scheduler sees there is nothing to do it can sleep for a while.. p.