Close

Using the SD Card

A project log for ChibiOS on Teensy 3.6

Using a port of ChibiOS for the Teensy 3 series, my goal is to run it on Teensy 3.6.

doctekdoctek 12/03/2016 at 18:130 Comments

One of the cool features of the Teensy 3.6 is that it has an SD card slot. The slot is supported by the SD library which you can get here (add link to github). The ChibiOS demos for Arduino include a chFifoDataLogger program which uses a version of the SDfat library. The logical thing to do is to replace the SDfat library with the new SD library made for the Teensy 3.6.

So that's what I did.

First, I ran the CardInfo Example program from the SD package to be sure I could see my SD card on the Teensy. For the 3.6, I made sure that the chipSelect was set to BUILTIN_SDCARD. The program ran using two different 4Gig cards and a 32Gig card.

Since the SD library works a little differently than the SDfat library, I compared the Datalogger program from the SD package to the chFifoDataLogger program from SDfat in the ChibiOS package and made some appropriate changes. The main changes were:

The file t36chFifoDataLogger is the result of my efforts. It needs a bit of clean up, but the code works. In addition to showing how to use the SD library, it also shows how to use ChibiOS semaphores to solve the Reader-Writer problem using an RTOS. More on this later.

Discussions