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

Thread: nordic radio + tlc5940 + t2/t3 = possible?

  1. #1
    Senior Member
    Join Date
    Nov 2012
    Location
    Los Angeles
    Posts
    100

    nordic radio + tlc5940 + t2/t3 = possible?

    Hi all,
    Need some pointers, or at least an acknowledgment that what I'm trying to do isn't possible.

    I'm currently developing this on the t2 to make sure everything works as expected before I port everything to the t3 (or perhaps everything works swimmingly on the t2 and won't need to port to the t3...tbd!)

    my set-up:

    1. I have two teensy 2's talking to each other wirelessly via the lovely nRF24L01 nordic radios using the rf24 library (i.e. https://github.com/maniacbug/RF24). Communication is working great. In particular I have button presses on one teensy turning on LEDs on the other (LEDs attached to few open digital pins on the teensy)

    2. On the teensy with the LEDs I've also have a tlc5940 IC. This also works fine by itself (i.e. no radio), controlling 48 sets of LEDs independently. I'm using the "teensy modified" tlc5940 library for this (http://www.pjrc.com/teensy/td_libs_Tlc5940.htm)


    my problem:

    both the nordic radios and the tlc5940 communicate via SPI. I'm not that familiar with SPI communication, and so I am a lemming and just connect everything up the way the libraries tell me to. That means pins 1 (SCK on both), 2 (MOSI on the nordic/SIN on the tlc5940), and 9 (CE on nordic/GSCLK on the 5940) are shared between the libraries and therefore the radios and tlc5940 share those pins. Hoping that all would work fine I went ahead and physically connected everything and loaded both libraries and code and unfortunately I get random flashes from the LEDs attached to the tlc5940, and no sign that messages sent to the radio on the same board actually do what they are suppose to. I didn't expect it to work, but thought I would try.

    questions:

    is there a way to get both the radio and tlc5940 to play nicely on the same SPI bus on the t2?
    is this something that the t3 can handle given that it might handle more than one spi bus?

    If anyone has any pointers on where I can look for more information, even related to how the arduino library handles SPI, would be greatly appreciated.

    Thanks in advance!
    David

    P. S. my problem seems somewhat related to this which I've been following closely:
    http://forum.pjrc.com/threads/123-Ne...ps-SPI-problem

  2. #2
    Senior Member
    Join Date
    Oct 2012
    Location
    Portland OR
    Posts
    677
    IN general, for SPI communications, you can share three of the four lines (MISO, MOSI and SCK) but CE ("chip enable"?) or CS/ (chip select) cannot be shared, you need one chip select line per device. Many libraries let you specify which line you use for the chip select, but if neither of yours do, you'll have to select a second GPIO pin for the second chip select, and modify the library yourself to enable use of both devices at once.

  3. #3
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,821
    The RF24 library lets you specify a CS pin. The Tlc5940 library has it hard-coded, but you can edit the pin number in "pinouts/Teensy_xxU4.h".

    Both of these libraries have a lot of AVR-specific stuff, so Teensy 2.0 is probably a much easier path than trying on 3.0.

  4. #4
    Senior Member
    Join Date
    Nov 2012
    Location
    Los Angeles
    Posts
    100
    Thank you both for your help. Trying this as soon as I get to the studio this morning. Can any pin work as a CS pin? Hoping down the road some kind soul will port the RF24 lib to the t3.0...I've been drooling over the fastSPI/LED/t3 control options (with a different LED driver IC). Or maybe I make this my chance to actually learn how to build a library.

    Thanks again!

  5. #5
    Senior Member
    Join Date
    Nov 2012
    Location
    Los Angeles
    Posts
    100
    OK, in the studio and feeling more like a noob than ever

    Looking at pinouts/Teensy_xxU4.h options. I believe SS is another name for CS, however I currently don't have anything on pin 0 (what is currently defined as the SS pin), nor do I see where to connect it to the tlc5940. on the RF24 this looks like the CSN pin (currently on pin 10 on the teensy 2), but again not a shared pin between the libraries since it looks like the tlc5940 has no CS pin? I must be reading that wrong.

  6. #6
    Senior Member
    Join Date
    Oct 2012
    Location
    Portland OR
    Posts
    677
    SS = Slave Select, same as Chip Select. The Teensy is the SPI master, and the attached SPI device is functioning as the slave. (It is actually possible to use the Teensy as the SPI slave device, eg. driven from another Teensy as master, although this is a less common configuration.)

  7. #7
    Senior Member
    Join Date
    Nov 2012
    Location
    Los Angeles
    Posts
    100
    Thanks again for the help. I think the problem I'm running into with the tlc5940 is that there is no ss/cs pin on the ic. trying to figure out if there is another method I should use here to control the tlc5940's, or look into a different chip.

  8. #8
    Any updates about get it working on teensy 3?

Posting Permissions

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