Does anyone know of any example code to receive SAI/I2S audio data from an audio codec (SGTL5000), process it, and then transmit back to the audio codec, using KSDK 2.1? This is my first time working with the Kinetis SDK, and it seems like the documentation is a bit disjointed with the change from KSDK 1.x to 2.x.
I tried modifying the SAI_DEMO from the KSDK 2.1 Demo Applications, but I am just getting noise when trying to receive the data, load into a circular buffer, and transmit back to the codec (no processing yet). I know that the I2C and SAI/I2S communication work because the unmodified demo works properly (playing music stored in flash memory).
Thanks in advance for your help.
Perhaps you can help me find the SAI demo? I can't find it under demo apps for my SDK v2.1 (generated for FRDM-K22F).
Which board/MCU are you using that generated and SAI demo for SDK v2.1?
The demo is apparently only available for the SDK v2.1 when generated for certain boards. I generated an SDK for the MK64 processor (for boards FRDM-K64F and TWR-K64), and the demo is located in ..\Freescale\KSDK_2.1.0\boards\twrk64f120m\demo_apps\sai.
Thanks for that, just in the nick of time! I've got SAI/I2C working with DMA for wave playback to SGTL500 - awesome.
I'm new to Kinetis and thought to try SDK v2 rather that PE & SDK v1.x. PE looked like too much of a learning curve and I like the SDK v2 approach which provides functional and transactional layers. The transactional layer and middleware support has saved me so much time, so I'm pretty happy with SDK v2 (using with keil MDK). Finding demos and examples in the SDK is very useful. Its a bit of a trap when various demo are excluded from your generated SDK! Its also confusing when so much on the web relates to PE and SDK v1. User beware I guess.
Thanks again, Sebastian
If the unmodified music code is okay, but you hear noise after you modify the code and use the data from micphone or whatever, so the the received data has issue. I suggest you read the received data and save it to a buffer and check if the data in buffer is okay or not.
Hope it can help you
Thank you for getting back to me. This is how I am trying to save the data to a buffer (as you suggested). It similar to transmitting the data from the SAI demo. I think the issue I might be having is how to handle L/R data. Do you see an issue or a way to improve on this?
Rxfer.data = g_rxBuffer;
Rxfer.dataSize = BUFFER_SIZE * BUFFER_NUM; //1024*2
for (i = 0; i < (AUDIO_BUFFER_SIZE / BUFFER_SIZE - BUFFER_NUM); i++)
while (isFinishedRx != true)
memcpy(audioBuff [(i + 2) * BUFFER_SIZE], g_rxBuffer, BUFFER_SIZE);
SAI_TransferReceiveEDMA(DEMO_SAI, &rxHandle, &Rxfer);
isFinishedRx = false;