Teensy 3.2 + Audio Board + MCP23S27

Status
Not open for further replies.

Koerby

Member
Hello
I am working on a mixer with built in WAV-Recorder, therefore I use the AudioShield + the Lib.
Due to a lot of LEDs and Switches I decided to use as Port-Expanders several MCP23S17. Unfortunately i do not get how to run the Expanders and the Board on the same on SPI, especially- in Recording and playback situations.
I use the MOSI,MISO,CLK Pins given by the audio-shield and for sure separate CS-Pins.
As far as I understood it is not possible to use the alternate SPI PINs because they are already in use for the Audio-Chip.

Sorry for the noob question, but I am running out of ideas.
The alternative solution would be a lot of 74HC595 / 74HC164 (not prefered)
Or, does someone know a MCP23s17 lib based on a SW-emulated SPI.

Cheers
Marcus
 
Hello,
Does the i2C version MCP23017 work in this case?

I don't think, because SCL and SDA are already in use for the SGTL5000.
I could re-assign the I2c to Pin 17 and 16 but nor sure how the Audio board behaves if i do this during runtime.
 
3.2 has 2 i2c.
Are those pins used?

Edit: When I used these on a teensy 3.2 I settled on 1.2Mhz as the max I could get out. Wire.setClock(1200000); (not sure what audio i2c is set at)
 
Last edited:
I don't think, because SCL and SDA are already in use for the SGTL5000.

Actually, the I2C chip should be much simpler. It has a different I2C address. All 8 possible MCP23017 addresses are different than the address used by SGTL5000. You can indeed use it.

Using the SPI version will be tricky. At a bare minimum, you *must* surround your usage with SPI.beginTransaction() and SPI.endTransaction(). You must also be careful to not take too much time away from the audio library.

Bitband SPI might also be a good option.
 
Last edited:
I don't think, because SCL and SDA are already in use for the SGTL5000.
I could re-assign the I2c to Pin 17 and 16 but nor sure how the Audio board behaves if i do this during runtime.

Note, i2c is a shared port. You can attach multiple devices on to an i2c port. The audio shield provides the necessary pull-up resistors to enable i2c on Teensy.

For SPI devices, you need a separate CS pin for each device that is not otherwise used. Note, the Audio library needs to redefine MOSI (pin 11) to pin 7, and SCK (pin 13) to pin 14. This is due to I2S using those pins. It also uses pin 6 as the CS pin if you have soldered flash memory to the audio board, and pin 10 for the micro SD card on the audio board.

<edit>
And as Paul says, you have to also use SPI.beginTransaction () and SPI.endTransaction ().
 
After wasting a lot of time with a sporadic working MCP23017 everthing runs now like a charm.
i use the second Ic2 Port on the Pins 16 / 17 .

Thank you very much.
 
Note, i2c is a shared port. You can attach multiple devices on to an i2c port. The audio shield provides the necessary pull-up resistors to enable i2c on Teensy.

For SPI devices, you need a separate CS pin for each device that is not otherwise used. Note, the Audio library needs to redefine MOSI (pin 11) to pin 7, and SCK (pin 13) to pin 14. This is due to I2S using those pins. It also uses pin 6 as the CS pin if you have soldered flash memory to the audio board, and pin 10 for the micro SD card on the audio board.

<edit>
And as Paul says, you have to also use SPI.beginTransaction () and SPI.endTransaction ().

Hi,

Can you help me change the spi pins for the audio board in the library?
Would SPI.setMOSI(pin), SPI.setMISO(pin), and SPI.setSCK(pin) be enough?

I tried to change them to mosi1-0,miso1-1 and sck1-32 on teensy 3.6 , but it doesnt work yet.

Where can i change the pins in the library?
 
Would SPI.setMOSI(pin), SPI.setMISO(pin), and SPI.setSCK(pin) be enough?

Yes, that is enough when you are using the first SPI port, called "SPI".


I tried to change them to mosi1-0,miso1-1 and sck1-32 on teensy 3.6 , but it doesnt work yet.

Those pins are for the 2nd SPI port, called "SPI1".

To configure them, you would use SPI1.setMOSI(pin), SPI1.setMISO(pin), and SPI1.setSCK(pin).

Likewise, you actually communicate on SPI1, you must use SPI1.beginTransaction(), SPI1.transfer(), and so on. If using a library where "SPI" is written within the lib (no provision to configure which SPI port it really uses - many libs are designed this way), then you would need to edit all of the "SPI" to "SPI1".
 
Thank you Paul.
Is it possible to use audioboard on spi1 so i can use other device on spi0 ? where do i have to change this in the audio library code?
 
Is it possible to use audioboard on spi1 so i can use other device on spi0 ?

The audio shield uses SPI only for the SD card and optional memory chip. The audio codec chip doesn't connect to those pins at all. If you do not solder a memory chip and you do not put a SD card into the socket, then those pins aren't used. No conflict. Easy, right?


where do i have to change this in the audio library code?

Most likely you've misunderstood, perhaps believing the audio chip uses SPI? It doesn't use SPI at all, so there isn't anywhere in the code to edit.

If you're using the memory chip, then please be more specific in your question.

Likewise, if using the SD card. But since you have Teensy 3.6, the simplest solution is the put the SD card into the socket on Teensy 3.6. It does not use SPI at all, but rather (much faster) 4-bit SDIO which is completely separate from SPI.

When it comes to which code to edit, the answers depend on very specific details of exactly how you are really using the hardware and what you are really trying to accomplish. Nobody can answer those questions when they do not have this info.
 
Yes i think i miss understood indeed.
I connected a rfm69 unit to spi0 and than the audioboard stopped working.

So thats why i thought audioboard interfered with the rfm69 chip.

Thanks for the help.

Maybe the rfm uses some other pins that are used by audioboard.
I will take a better look.
 
I connected a rfm69 unit to spi0 and than the audioboard stopped working.

Details matter, specifically which pins!

You need to use the SPI pins which are not taken for the audio (pins 7 & 14). See the audio shield page for details.

In setup, you would use SPI.setCLK() and SPI.setMOSI() to configure the SPI library to use the alternate pins.
 
Details matter, specifically which pins!

You need to use the SPI pins which are not taken for the audio (pins 7 & 14). See the audio shield page for details.

In setup, you would use SPI.setCLK() and SPI.setMOSI() to configure the SPI library to use the alternate pins.

Thanks a lot. It worked and everything is under control.
I cant believe you give support to everyone like this!
Teensy rocks.
 
Status
Not open for further replies.
Back
Top