Categories

PLUME – Mastering the codec

Hi,

It’s been a long time since I posted for the last time.

Since last time, I have continued the calculation on the Kalman filter to see if using one with only a position measure would be useful (it is called alpha-beta-gamma filtering). It brings almost nothing to the system as we have it today (200 mesures per seconds – 1 centimeter standard deviation on measure – 10 m/s^2 input acceleration noise). It improves the precision by less than one percent. So we won’t use it.

Then I worked with the codec evaluation we received. (http://www.ti.com/tool/tlv320aic3254evm-k) In our system the codec will be commanded in SPI and the data will be retrieved using I2S. I had to write a program on an stm32f4 discovery to configure the codec and retrieve the data using I2S,  DMA and ChibiOS.
I had some troubles setting up the SPI, I2S and DMA. I solved the ones with SPI and I2S using the logic analyzer.
One of the most annoying problem was that I was not using the right DMA channel for I2S. I was using a channel called something like DMA_I2S2_ext, which is useful only when the full duplex mode of I2S is set up. The right one is called something like DMA_SPI2_RX (I2S uses SPI pins on STM32F4). Once the right channel was set up, the DMA run  nicely, with double buffering.

Once the the communication with the codec was set, I needed to configure it. The software given by TI to make tests with the the codec evaluation board uses a script language which looks like this to configure the codec : # Select Page 1
w 30 00 01
#
# Powerup MIC BIAS
w 30 33 40
#
# Route IN3L to LEFT_P with 10K input impedance
w 30 34 04
#
# Route IN3R to LEFT_M with 10K input impedance
w 30 36 04
#
# Unmute Left MICPGA
w 30 3b 00
In the first line, 0x30 is the I2C address of the codec (because we use SPI, we don’t need this value), 0x00 is the register in which the value is written and 0x01 is the value. I wrote I small program to convert a script in a binary file (removing the 0x30’s) to be able to use objcopy and make to link the configuration with the discovery program. I used the default script which records from the inboard microphone and it didn’t work. So I launched the TI software and used the logic analizer to see what was sent by the TI program given the script (I set up the program to use SPI).  I didn’t send what was in the script. In the register address byte, the address is only 7-bit and there is bit used to tell if the value will be read or written. I thought this bit was the MSB because the register addresses go from 0 to 127, but in fact the bit used is the LSB. So for example the line “w 30 34 04” sends “0x68 0x04” on the SPI (the register address is shifted one bit left). So i corected my program. But now it still does not work and i don’t know why so I will continue to search to get it working. My next test is to send the configuration using the TI software and the to give the I2S clocks using the discovey to see what happens.