Arduino UNO with two SPI

Hi

I haven’t started this project fully yet only have the leds to work, however I thought I would double check to see if my idea is valid. I have an arduino uno connected to a few TLC5940 which I have programmed to turn certain leds on and off using an array, which works great. Now the thing I wanted to double check is storing the led array into an SPI flash memory

https://github.com/PaulStoffregen/SerialFlash

Like the one in this link. I know both use an SPI interface, I wanted to know if I could link the MISO, MOSI etc... Together and use both the TLC5940 and the SPI flash memory.

Would this work? If not would love to get a suggestion in how I can achieve what I’m trying to do

Thank you

You can have multiple SPI devices connected using common MISO, MOSI and SCK pins as long as you use different SS pins for each of them. The SS pin used determines which device is communicated with

Thank you for the reply

for the TLC5940 this is currently what im using
D13 - SCLK
D11 - SIN
D10 - BLANK
D9 - XLAT
D3 - GSCLK

TLC5940

i used this configuration to connect to the TLC5940 as the link above shows, i was just curious to know which pin i can use for SS as an example

The TLC5940 appears to use SPI in a non standard way as it does not have a Slave Select pin. There may be ways round this but it is not something that I have any knowledge of

See Can I use the TLC5940 LED Driver if I'm already using other SPI devices on my Arduino mega? - Arduino Stack Exchange for possible help

A known possible pitfall with SPI are devices that do not cut off their MISO outputs when deselected.

Hi

i have looked at the link and it says to use a mosfet to disable the clock pin (if there is no other choice), which pin out of the configuration i have would be ideal one to be used to disable the TLC5940 and write to the SPI flash

Thank you

Without further hardware only one of these can be wired for reading back on MISO. Can you do with disconnected serial output and without reading back data from the TLC?

Hi

I can do without reading back from the TLC as i only write, as for the serial i might need the output.

however a question i wanted to ask, is could i use two mosfets example if i have two mosfets from D11(SS) one connected to the track to the TLC and the other to the track for the flash memory, can I switch between them without interference. not sure if that would work but thought i would ask

Do not connect the TLC output, use a AND gate to block the TLC clock. Provided that the flash SS is active low the same signal can be used for the SS and AND gate to switch between both chips.

Hi

So you mean disconnect the MISO pin connected to the TLC and put a AND gate from the MISO pin from the arduino and the SS pin from the arduino. sorry could be the lack of sleep over this so getting a bit confused. i found a image of a basic AND gate using NPN transistors on this site

AND Gate

to imagine how im going to do this, could also be the reason of me getting confused

Thank you

Are you daisychaining the '5940s?
SOUT: serial data out from the TLC5940. Unless you wish to try to read the error bits you do not need this to come to the Arduino. If you have more than one TLC5940 this is the line you daisy chain to the SIN of the next package.

5.1 Waterfall

To be able to use several TLC5940 connected in cascade, you must modify the file tlc_config.h of the repository. Change the #define NUM_TLCS 1 line to #define NUM_TLCS 2 (or whatever number of TLC5940s you want to use).

Hi

Yes i am daisychaining the 5940 and so far i have put four together and modified the config file and all that works great. also i have not connected any of the SOUT pins to the arduino

If Sout is not being brought back to the Arduino, that will not interfere with MISO coming back from the memory device.
A simple AND gate to stop SCK from Arduino as discussed when the CS pin to the memory device is selected would work. The CS signal being high would allow SCK to the '5940 normally, and when low to enable the memory device would block SCK to the '5940 so they don't react to the memory device commands.
Here's what I mean. Top AND gate lets a single pin be used.
Bottom P-MOSFET requires unique pins for the '5940s and the memory device.