Solved: I2s to Serial through DMA with bidirectional serial traffic
Above is my top level physical layer. In essence, I want to DMA 2 bytes of separate memory data + 31 samples of 16bit audio from the SGTL5000, push it to the serial bus at 1M Baud through differential transceiver from one teensy to the other, and then stop to wait for a response. Concurrently as the data shows up, the second teensy pulls off the 2 bytes of separate data to update a variable and pushes the 31 samples to I2S for the SGTL5000 to output as audio. Upon completion of the 64 bytes, it will send 4 bytes of data back. The first teensy then gets the go ahead from a short routine that it received back a value and starts streaming the 2 bytes and 31 samples to repeat the cycle. Below is what I hope the traffic to look like on the RS-485.
So my question is, is this feasible with Teensy 3.2 DMA controllers interfacing with I2S and serial? The two bytes and 4 bytes of info are values that get updated somewhere in loop(). I know this requires alot of special setup, which I am willing to learn, but I would like to know with reasonable confidence if its feasible before I start digging.
What I think I know:
1. I can increase the size of the serial buffer
2. I dont think I need flow control as I am sending a discrete amount of data and waiting for a psuedo handshake operation to complete, so my buffer should in theory never overrun if I set the size correctly.
3. DMA is a pain in the ass to setup, especially if I don't know what I am doing.
4. If I didn't use DMA, I would get 1uS serial interrupt delay and based upon baud rate and size of audio data that would eat up 6% of CPU plus any extra code inside of the serial interrupt. Approximately 10% as an estimate. Precious CPU time wasted!
5. Based on rudimentary knowledge of DMA, i'll need to use 3 or 4 controllers to do the start and stop handling for each teensy
Above is my top level physical layer. In essence, I want to DMA 2 bytes of separate memory data + 31 samples of 16bit audio from the SGTL5000, push it to the serial bus at 1M Baud through differential transceiver from one teensy to the other, and then stop to wait for a response. Concurrently as the data shows up, the second teensy pulls off the 2 bytes of separate data to update a variable and pushes the 31 samples to I2S for the SGTL5000 to output as audio. Upon completion of the 64 bytes, it will send 4 bytes of data back. The first teensy then gets the go ahead from a short routine that it received back a value and starts streaming the 2 bytes and 31 samples to repeat the cycle. Below is what I hope the traffic to look like on the RS-485.
So my question is, is this feasible with Teensy 3.2 DMA controllers interfacing with I2S and serial? The two bytes and 4 bytes of info are values that get updated somewhere in loop(). I know this requires alot of special setup, which I am willing to learn, but I would like to know with reasonable confidence if its feasible before I start digging.
What I think I know:
1. I can increase the size of the serial buffer
2. I dont think I need flow control as I am sending a discrete amount of data and waiting for a psuedo handshake operation to complete, so my buffer should in theory never overrun if I set the size correctly.
3. DMA is a pain in the ass to setup, especially if I don't know what I am doing.
4. If I didn't use DMA, I would get 1uS serial interrupt delay and based upon baud rate and size of audio data that would eat up 6% of CPU plus any extra code inside of the serial interrupt. Approximately 10% as an estimate. Precious CPU time wasted!
5. Based on rudimentary knowledge of DMA, i'll need to use 3 or 4 controllers to do the start and stop handling for each teensy
Last edited: