Coder Social home page Coder Social logo

gatcode / nordicaudiowave Goto Github PK

View Code? Open in Web Editor NEW
8.0 1.0 4.0 250 KB

Generate and transmit a sine wave signal over I2S to a DAC (nrf5340 --> UDA1334A)

License: Apache License 2.0

CMake 5.30% C 94.70%
nordicsemi nordic zephyr nrf5340 i2s audio dac uda1334a

nordicaudiowave's Introduction

nrf5340 zephyr license

About

Since at this point in time, there is very little information available on how to use a nrf5340dk board in combination with an I2S DAC chip (Adafruit I2S Stereo Decoder - UDA1334A in my case), the code in this repository will give you a brief overview on how you can achieve this goal.

This sample is based on the Zephyr I2S testcases (copied sine wave data_frame table), as well as the I2S Echo sample. Please take a look at these samples if you want to get further information on how you can use the I2S driver itself.

Furthermore, the concrete API definitions can be found here.

Basic principle

To be able to talk to I2S devices, one has to follow (more or less) the following steps:

  • Step 1: Get the I2S device from the devicetree
  • Step 2: Allocate a memory slab
  • Step 3: Configure the I2S device
  • Step 4: Allocate memory blocks in the memory slab
  • Step 5: Trigger the start of the data transmission
  • Step 6: Fill the memory blocks with your data (e.g. sine wave)
  • Step 7: Use i2s_trigger(...) to write the data to the I2S device

All of these steps are explained in greater detail inside the main.c file itself!

Result of the sample code

If you flash the sample code to a bare nrf5340dk board and probe the pins P1.15 (47 in the overlay) and P1.13 (45 in the overlay), you can see that the chip generates a nice clock signal (blue trace) and the corresponsing the data signal (yellow trace).

If you now attach the DAC board to the nrf5340 board, you should see the corresponding analog output:

๐ŸŽ‰ we successfully created an analog signal on an I2S DAC chip!

Limitations

This Software is provided as-is!

Please feel free to adapt it to your needs and contribute to the project. I would be very grateful to include your improvements. Thanks for your support!

WARNING: Everyone is responsible for what he/she is doing! I am not responsible if you hurt yourself, torch your house or anything that kind trying to do build something new! You are doing everything at your own risk!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.