Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 4 of 4

Thread: Code hangs when I try to access I2S registers

  1. #1
    Junior Member
    Join Date
    Jun 2016
    Posts
    12

    Code hangs when I try to access I2S registers

    I am developing a board that interfaces the Teensy 3.2 with the WM8782A dual-channel ADC via I2S interface. I was able to find plenty of example code online, but when I try to implement it myself, I am not even able to read or write to any of the I2S registers! Here is some simplified code I tried to run:

    ************************
    void setup() {
    delay(5000); //gives me time to open Serial Monitor
    Serial.begin(9600);
    Serial.println("Begin");
    I2S0_TCSR = 0;
    Serial.println("1");
    }

    void loop() {}
    *****************************

    The Arduino serial monitor will print "Begin" but not "1."

    If I can't perform simple read/write operations to SFR's, I'm stuck!

  2. #2
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany NRW
    Posts
    6,910
    You have to enable the I2S-Device first:
    Code:
        SIM_SCGC6 |= SIM_SCGC6_I2S;
    Maybe take a look at AudioOutputI2S::config_i2s in output_i2s.cpp

  3. #3
    Junior Member
    Join Date
    Jun 2016
    Posts
    12
    Wow, that's great, thanks!

    I originally had this line of code, but didn't include it until after I configured all of the I2S registers. I had no idea you had to do that first!

  4. #4
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    22,115
    You really should look at the already-working I2S code in the audio library.

    https://github.com/PaulStoffregen/Au...output_i2s.cpp

    This code took quite some time to develop. Do yourself a favor and leverage that prior work to save yourself quite a lot of time.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •