Go Down

Topic: Problem while playing Wav files (SDcard & TLC7226 DAC) (Read 2051 times) previous topic - next topic


Oct 24, 2011, 08:24 pm Last Edit: Oct 24, 2011, 09:07 pm by Sn4ke Reason: 1
Hi all,
I need to play .wav files from a SD Card. I chose to use 22050Hz 8bits mono files.

I connected a TLC7226 parallel DAC to my Arduino Duemilanove. The datasheet is here : http://www.ti.com/lit/ds/symlink/tlc7226.pdf
I use the first DAC (it's name DACA in the datasheet), that's why I connected A0 and A1 to ground. The D0-D7 pins go to the Arduino, as /WR one. Voltage reference is 5V.

A speaker is connected between OUTA and ground, through a 100 ohm resistor and a 10µF capacitor.

The DAC works well, I can hear a square wave for instance. I also read data from my SD card. The problem is when I read a byte from the file and I write it on the DAC, I can't recognize the music. There's just "cracking sounds".

Here is my code, sorry for the French :

Code: [Select]
#include <SD.h>

 Connexion SD Card :
  ** MOSI (Violet) - pin 11
  ** MISO (Violet) - pin 12
  ** CLK (Gris) - pin 13
  ** SS (Blanc) - pin 4

File fichier;
byte octet;
int i;

int pin_D[8] = {A0, A1, A2, A3, A4, A5, 2, 3}; // Here is connected my DAC
int pin_Enable = 7;

void Ecrire_DAC(byte val) // Write a byte to the DAC
   int i;
   for(i = 0; i < 8; i++) // I know that way to write the byte is slow. It's just for debug.
       digitalWrite(pin_D[i], bitRead(val, i));
   digitalWrite(pin_Enable, LOW);
   digitalWrite(pin_Enable, HIGH);
   //Serial.print("Ecriture de ");
   //Serial.println(val, HEX);

void setup()
   int i;
   // Configuration du port série
   // Configuration du DAC
   pinMode(pin_Enable, OUTPUT);
   digitalWrite(pin_Enable, HIGH);
   for(i = 0; i < 8; i++)
       pinMode(pin_D[i], OUTPUT);
   pinMode(10, OUTPUT);
       Serial.println("Initialisation de la carte SD reussie.");
       Serial.println("Echec de l'initialisation de la carte SD.");
   fichier = SD.open("22khz8b.wav");
       Serial.println("Ouverture du fichier reussie.");
       Serial.println("Echec de l'ouverture du fichier.");
   fichier.seek(300); // make sure the pointer comes over the data

void loop()
   octet = fichier.read();

Even if the speed of the music will be very approximative, because I don't wait precisely 45µs between each byte, I thought I can hear something.

Can someone help ?

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131