I need a bit of help. My software setup consists of a PIC18F4620 controlling an AIC3204 CODEC over I2C. From a terminal window on my PC, I talk over RS232 to my PIC. I have a menu that enables me to read/write to any of the registers on the CODEC. The CODEC itself is the one on the EVM board but I am not using the USB board - just the 3204 EVM board. That all works fine.
My hardware setup consists of an amplified microphone connected to J1 (IN1) on the EVM and a headset on J9 (HEADPHONE OUT). The microphone's audio is routed to DOUT (TP19). Then, DIN (TP20) goes to the CODEC and out on the headphones. To make sure that my entire setup is functional, I simply tied a piece of wire between DOUT and DIN and then, I hear the microphone's audio in my headset. I am using an external MCLK signal of 24.576Mhz which also feeds the BCLK (not sure if this is the right approach for BCLK, but it works). Through my console application, I can change any of the register settings and listen live to the changes through the headset. I currently have the MDAC/NDAC/MADC/NADC values set so that my WCLK output shows me 8kHz. I can "hear" that the audio is low-quality, which is fine.
Also, I tied an SD card to my PIC but it's not formatted in any way - it's just raw data over SPI. I want to hopefully be able to use this card to store the audio (buffer). The SD card is fully accessible through the first 32MB so that's quite a big buffer.
Now, where I need help is regarding the digitized audio... Since I now have the microphone's audio digitized and since I can also take the digitized audio and convert it back to analog (DOUT <==> DIN), what would I need to do/configure if I want simple 8bit / 8kHz audio that can be sampled from my PIC and stored to the SD card?
I believe that the default audio is like 16 bits. How would I sample the data in order to have only 8 bits? Should I sample every other bit of data (1 out of 2)?
Basically, I want my PIC to sample the DOUT pin, read the data and store it. But in order to do that, I must time the PIC with the WCLK signal to indicate when the left channel is ready and I guess I would time myself also with the BCLK pin to read each bit of data? I was thinking of using the right channels WCLK time frame to write the data to my SD card. I don't need high quality audio. I just want 8bit - 8K and store it.
I'm not sure exactly what approach to take for the timing of the BCLK and WCLK and how to maniuplate the data.
My PIC is running off a 20Mhz crystal.
Thanks,
Benoit