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

Thread: Teensy 4.0 and SPI chip select sadness

  1. #1

    Teensy 4.0 and SPI chip select sadness

    Hi,

    I've made a board under assumption that any digital pin can be used as chip select pin (my board uses 14 digital pins for 14 NOR flash modules). Unfortunately, it doesn't work at all. I've tried setting all 14 HIGH before SPI.begin(). But they refuse to work together. In the SPI library code there is only one CS pin for T4.0.

    I'm wondering what the problem is and if there is a way to use my 14 CS pins...

    Thanks.

  2. #2
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    7,142
    Again there are no details here on your setup. How are things hooked up, what IO pins are hooked up to what... What Arduino release, which Teensyduino? I think the current beta build has a delay built in that helps in some cases. A test sketch that shows what you are doing?

    What does "refuse to work together" mean? Is the code hanging in SPI.begin()? Or hanging elsewhere? Or not getting the right results or ???


    Have you tried it with just one of these chips? To see if it works at all? And then maybe a few chips...

    And yes there is only one hardware CS pin per SPI buss on the T4. The T4.1 has a few others possible, but in most cases that is not important.
    There are only a few places where hardware CS is important.

    a) SPI Slave device. You need to have this pin setup to be in hardware CS mode and the like...

    b) A few (very few) libraries may use the hardware CS pin to speed up some stuff. It is not as good of a gain as with the T3.x, but it can speed some things up.

    So again there are not enough details here to guess what is going on.

  3. #3
    Senior Member
    Join Date
    Nov 2012
    Posts
    1,376
    Post your code.

    Have you tried a stripped down version of your code which only uses one module?

    Pete

  4. #4
    Thanks for the response.

    I am now thinking the problem is in my setup...
    I use pins 2, 3, 4, 5, 6, 9, 10, 24, 25, 28, 29, 30, 31, 32 for CS. Seven S70FL01GSAGMFI013 chips (each chip has two parts with two CS pins).
    The code is modified SerialFlash library code, I've changed a bunch of props there from static class props to just instance props to allow separate CS for each instance. The code was working properly with T3.6 and one S70FL01GSAGMFI013 (so, with two CS pins). The result is just some random junk when I try to read the chip identification data.

    I suppose my main mistake was to solder the whole thing together at once — it was so much easier to solder it all at once with hot air... Now I tend to think that probably I've made a bad joint for some of the under pins (24, 25, 28, 29, 30, 31, 32)...

    And trying things I've just accidentally shorted and fried the board. Will start it over and chip by chip when new T4 arrives. Also thinking to try 74HC154 to drive CS and avoid using those tiny pads at the bottom of the board.

  5. #5
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    7,142
    Or use t41 when it ships

  6. #6
    Senior Member
    Join Date
    Feb 2018
    Location
    Corvallis, OR
    Posts
    123
    There was another thread about connecting to multiple SPI devices sometime in the last few months.:
    https://forum.pjrc.com/threads/59942...PI-peripherals

    One thing that came up is that having multiple devices all connected to the same SCK output can cause problems because of the interaction of the high-speed outputs on the T4.0 and the capacitive loading of the multiple chips.

    One thing to try is to slow down the SPI SCK speed by a factor of 4 or 8 and see what happens. You can also control the drive speed on the SCK pin. This is the kind of problem that really needs exploration with a good oscilloscope.

  7. #7
    I've just checked two chips (so, four CS pins) with new T4 arrived. And it seems to work. So something was definitely wrong in my setup. And thanks for the SCK speed tip. I'll be gradually adding chips to test the whole thing once 74HC154 arrives.

Posting Permissions

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