TMRpcm port for Arduino 101 (Intel Curie)?

I need to read audio sample from an SD card and play them using PWM on Intel's Arduino 101 (Curie / Quark) processor. I love a good programming challenge, but I've learned it's wise to ask if it's already been written ;), therefore:

Has anyone done a port of the TMRpcm library (or something equivalent) for the Arduino 101?

I could use it right away, like tonight. Thanks in advance.

  • rdp

P.S.: 8Khz sampling rate, 8bit mono would suffice for this application.

Has anyone done a port of the TMRpcm library (or something equivalent) for the Arduino 101?

I think not. The problem is that the 101 is not a real Arduino but an emulator with an operating system and they are notorious for not running in real time. Also the hardware timers are not the same.

While I was waiting for a reply, I wrote a “writePCM()” method for the Arduino101. It uses two clocks: It uses CurieTImerOne as an interval timer, generating an interrupt once every sample period. And it uses one of the four Quark PWM timers to generate the PWM signal itself.

The technique is simple: in the sample interrupt method, it fetches the next sample (a user supplied method) and updates the PWM timer counts with that sample.

It works at 8KHz with unsigned 8bit samples, and it sounds surprisingly good because the PWM runs at 32MHz, giving it good resolution.

Unfortunately, we can’t use it since our application needs the Servo library which takes over the CurieTimerOne clock. (Now that took me a while to debug… :confused: )

This is inspiring me to create an “Arduino Head-Butt” wiki, which lists the I/O pins and computing resources used by each library. This way, you’ll know if there will be conflicts among various published libraries. Or has someone done this already?

has someone done this already?

Not that I know of, that sounds great. Yes the servo library interferes with the TMRpcm library on the Uno too. +1 :)