upload audio to PIC32mx and using I2S - Page 1
Forum section: electronics / general

author: nithiA
author_rank: Newbie
timestamp: July 12, 2016, 10:09:41 am
content: HiI am new to microcontroller.I am using PIC32MX1/2/5 Starter Kit with I/O expansion board.Also the software I am using is MPLAB X IDE 3.35, XC32 1.42, Harmony 1.08.What I want to do is1. I want to upload a few short audio files (2-4 seconds) to the MCU. How can I do this?2. I want to send these audio to external device via I2S. For example, If I press SW 1 on evaluation board, MCU will send a specific audio to external device by I2S. How can I do this?Can anyone advice any solution or examples.Thank you.

author: Buriedcode
author_rank: Super Contributor
timestamp: July 12, 2016, 09:09:47 pm
content: How large are these files? I assume they are raw, or *.wav files, in which case you won't get very long audio clips if their are 16-bit at 48kHz sample rate. Better to store the file in external memory.In answer to your second questionL break the problem down into parts, and work on each part one at a time. So first of all, as you're new to microcontrollers, google for 'blink code'. Then look for example code for the I2S port, and output say, a sine wave, from a table and check that with a scope to make sure the I2S part is working, then finally, you could store the wav file on external memory, like a serial EEPROM. Then all your microcontroller will have to do is read form the EEPROM, into a buffer, and output to the I2S port.

author: hans
author_rank: Super Contributor
timestamp: July 13, 2016, 07:25:06 am
content: Yep indeed, I would recommend first working on the basics, and then move on to transfer an audio stream via I2S reliably. That audio stream will need to be buffered in RAM; so it's source can be anything.. a software tone generator, USB audio device, or a WAV file.WAV files tend to be rather big thuogh, 48kHz x 16-bit x 2 = 192kB/s of data, so if you got 256kB of internal FLASH you can only store let's say 1 second of audio data.Connecting a button press to play of a WAV file is a matter of reading a GPIO and then commanding your playback code to start playing (e.g. filling audio buffers) that file.

author: nithiA
author_rank: Newbie
timestamp: July 15, 2016, 02:59:21 am
content: Thank you Buriedcode & hansI can work on basic LED already.Quote from: Buriedcode on July 12, 2016, 09:09:47 pmWhat type of audio file does MPLAB Harmony (written using C programming) is accept?I have 4 audio files which are 68kByte (*.wav file [1 channel-mono]) 16 bits Sampling at 22.05kHz each.Now I am using PIC32MX570F512L which has 512Kbyte, so I think it should be enough to keep these 4 audio files.I search online and could not file any examples for I2S in MPLAB Harmony.Hope anyone can help.

author: Howardlong
author_rank: Super Contributor
timestamp: July 15, 2016, 09:41:45 pm
content: I have done I2S on PIC32 and PIC24, but as an RX only, I can't remember though whether it was frame/bit clock master/slave.My first question, what is your codec, is there a requirement for who is master or slave for frame or clock? Sometimes it is easier to choose other protocols like LJ of you can.My application was at 48, 96 and 192kSa/s, 2ch, at 16 and 32 bits/sample (16 bits only at 192kSa/s).