2 December 2009

SOMO-14D audio module

The Somo 14D is a cute little module from 4D - plays audio files you put on a micro SD card. Aside from some difficulties with the brand of card you use, it kind of worked... but wouldn't play the files I requested.

Now, bring in the Logic tool. Honestly, I can't believe I didn't buy this or something like this years ago.

Turns out this module is very particular also about the timing of commands you send it. The clock pulses have to be 200us. And that's exactly what I had in my code:

void somo_14d_send_data(uns16 data) {

// Signal start
clear_pin(somo_14d_clk_port, somo_14d_clk_pin);
delay_ms(2); // tSTART = 2ms

for (uns8 count = 0; count < 16; count++) {
if (data.15) {
set_pin(somo_14d_data_port, somo_14d_data_pin);
} else {
clear_pin(somo_14d_data_port, somo_14d_data_pin);
delay_us(1); // tDS = 1us
set_pin(somo_14d_clk_port, somo_14d_clk_pin);
delay_us(200); // tCH = 200us
clear_pin(somo_14d_clk_port, somo_14d_clk_pin);
delay_us(200); // tCL = 200us
data = data << 1;
// Signal end
set_pin(somo_14d_clk_port, somo_14d_clk_pin);
delay_ms(2); // tSTOP = 2ms

All looks perfectly okay, right?

Now look at what Logic says. The pulse is actually about 100us. Half the...hang on. In my config.h I had the clock rate of the chip at 20Mhz when in fact it's running at 40Mhz. Ha! Once again, Logic to the rescue.