I2S help on nRF5340 Audio DK

Hi,

For my university masters group project I need to connect my nRF5340 Audio DK to another board (Ambiq Apollo 510B). I will need to send audio from the mic to the Apollo via I2S on the GPIO pins. The apollo will then send back processed audio via I2S. This will be output to the Nordic's headphone jack.

I have a basic understanding of nRF connect for VS code and I have got the nRF5340 audio applications working streaming bidirectional audio over bluetooth. 

My question is what is the best way to go about this? Is there some sample code I can modify? Can I use the nRF5340 audio applications and disable bluetooth? Should I start from scratch? Is there a course I can follow on I2S? The project ends in 2 weeks, is if feasible to get this working in that timeframe?

Many thanks,

Lawrence

  • Hi,

    We recommend starting from your working SPI example and adding the audio parts into it, rather than starting from unicast_server. The unicast_server app is complex because it includes a full Bluetooth LE Audio stack which you don't need.

    Mic input: The microphone data is captured in audio_datapath.c, function audio_datapath_i2s_blk_complete(). This is called automatically every 1ms when a new block of raw audio (PCM) from the mic is ready. It puts that audio into a queue, which is then picked up by encoder_thread() in audio_system.c. This is the exact place where you replace the BLE send with your SPI send to Apollo.

    Headphone output: Call hw_codec_default_conf_enable() from hw_codec.c once at startup to initialize the on-board CS47L63 codec chip. Then, when you receive processed PCM back from Apollo over SPI, feed it into audio_datapath_stream_out() in audio_datapath.c, this will automatically play it out through the headphone jack.

    You will also need to bring in audio_i2s.c and cs47l63_comm.c as these are required dependencies of the files above and Yes, it should be feasible if you keep the scope simple.You already have SPI working which is a great start, so focus next on getting the codec initialized and audio playing through the headphone jack before wiring in the SPI audio transfer.

    Best Regards,
    Syed Maysum

Related