PV198 – One-chip Controllers, Music Player / Dávid Danaj, Juraj Ondruška 1 PV198 – One-chip Controllers Music Player PV198 – One-chip Controllers, Music Player / Dávid Danaj, Juraj Ondruška 2 Content 1. Audio Codec 2. I2S 3. WAV file format 4. Application PV198 – One-chip Controllers, Music Player / Dávid Danaj, Juraj Ondruška 3 Audio Codec ▪ Dialog Semiconductor – DA7212 – link ▪ 24-bit audio ▪ Low-power ▪ Beep generator – 2 Sine wave generators ▪ Bidirectional I2S I2S Overview PV198 – One-chip Controllers, Music Player / Dávid Danaj, Juraj Ondruška 4 ▪ I2S – Inter-IC Sound – link to specification, Application Note ▪ Serial bus for digital audio data in PCM format ▪ 3 signals: ▪ Serial clock (SCK) ▪ Word select (WS) / Frame sync (FS) – left/right channel select – toggled after each sample ▪ Serial data (SD) – the data samples I2S Overview PV198 – One-chip Controllers, Music Player / Dávid Danaj, Juraj Ondruška 5 erial Clock C ord elect erial Data D i ht Channel e t Channel i ht Channel M M By wdwd - Own work, CC BY 3.0, https://commons.wikimedia.org/w/index.php?curid=16579640 WAV file format PV198 – One-chip Controllers, Music Player / Dávid Danaj, Juraj Ondruška 6 ▪ http://soundfile.sapp.org/doc/WaveFormat/ Application – Overview PV198 – One-chip Controllers, Music Player / Dávid Danaj, Juraj Ondruška 7 ▪ The application reads .wav files from the root folder of Micro SD card and plays them via 3.5mm audio jack. ▪ Input: ▪ .wav file(s) in the root folder of Micro SD card ▪ Output: ▪ Analog sound via 3.5mm audio jack ▪ Limitations: ▪ Micro SD card must use FAT file system ▪ PCM format of .wav files is supported only Application PV198 – One-chip Controllers, Music Player / Dávid Danaj, Juraj Ondruška 8 ▪ Peripherals used: ▪ I2S – for audio data transfer to audio codec ▪ SDHC – for SD card operations, e.g., .wav files read operation ▪ I2C – for audio codec configuration, e.g., sound bit-width, etc. ▪ PIT – for timing of tone generation ▪ Schematics: MCU CODEC SD Headphones SDHC I2C I2S (digital audio) Application – Pins configuration PV198 – One-chip Controllers, Music Player / Dávid Danaj, Juraj Ondruška 9 SD card Console CODEC Application – Peripherals configuration PV198 – One-chip Controllers, Music Player / Dávid Danaj, Juraj Ondruška 10 ▪ SDHC – board example reused ▪ I2S – configured via Peripherals tool however the peripheral properites (channels number, sample rate, data width, and interrupts) are configured in the application based on the .wav iles‘ properties ▪ PIT – configured via Peripherals tool Application – Source Code PV198 – One-chip Controllers, Music Player / Dávid Danaj, Juraj Ondruška 11 ▪ Main loop: ▪ Configure the devices ▪ Start PIT to play tones sequence via I2C ▪ Start file reading, repeat the following sequence: Fill the data read buffers Wait until a buffer becomes empty after it is transmitted via I2S ▪ Interrupts: ▪ Used board demo I2C communication interrupts ▪ PIT uses interrupts for tones playing ▪ I2S uses interrupts for FIFO status notifications Application ▪ Parse WAV file header and setup SAI and Codec format correctly by implementing function: ▪ uint8_t processWavHeader(FIL* file) PV198 – One-chip Controllers, Music Player / Dávid Danaj, Juraj Ondruška 12 Homework  Update the project such: when all songs have been played, it will start playing all again on repeat PV198 – One-chip Controllers, LCD Display / Dávid Danaj, Marek Neužil 15