Pullups on SS for multiple SPI devices ?

Go To Last Post
27 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi,

 

I've got a project where I am going to have a SPI display, micro sd card, and a SPI real time clock all on the same SPI bus.  When running, I will have the SS/CS for each one set to output high to make sure they are disabled, but what about when the chip is in reset?  Is it a common practice to put pullups on each SPI devices SS/CS to keep any of them from trying to output to MISO?

 

Thanks,

 

Alan

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Its been a while since I had more than one device on an SPI bus, but, yes, pullups are a good idea. Clock pullup would also help to insure that there is no unplanned activity during reset. Clock pullup particularly fits with modes that idle high. If it uses a mode that idles low (CPOL = 0), then use pulldown.

 

Jim

Jim Wagner Oregon Research Electronics, Consulting Div. Tangent, OR, USA http://www.orelectronics.net

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Yes, have an external pullup on every CS. (or pulldown for active high devices)
There is no need to worry about SCK line.
Remember that three-state devices can only be three-state when powered. i.e. power all SPI devices and ensure all ChipSelects are inactive.
.
David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

alank2 wrote:
When running, I will have the SS/CS for each one set to output high to make sure they are disabled, but what about when the chip is in reset? Is it a common practice to put pullups on each SPI devices SS/CS to keep any of them from trying to output to MISO?

david.prentice wrote:
Yes, have an external pullup on every CS. (or pulldown for active high devices)

The state when not being used, as well as the external puller, need to go in the direction to keep the device de-selected.

 

alank2 wrote:
SPI display, micro sd card, and a SPI real time clock

And you are sure those are all active-high CS and none are active-low /SS?  My SD-card work has that select as active-low.

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I would put multiple beers on SPI display, micro sd card, and a SPI real time clock are all active-low  i.e. /CS.

 

Very few SPI devices are active-high.   But they do exist.  e.g. 93Cxxx memories.

 

David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

david.prentice wrote:
I would put multiple beers...

 

Send me one, I guess -- we've been using DS1305/6 RTC for many years, and they are active-high select CE.

 

 

 

 

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You win.   Do you ever come to Europe?

 

Yes,  I have used a DS1305 and 93Cxx.

 

David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I think all the devices I am using are active low.  Thanks guys!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

alank2 wrote:
I think all the devices I am using are active low.

Then why would you say

alank2 wrote:
Is it a common practice to put pullups on each SPI devices SS/CS

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

If it is active low, wouldn't you want a pullup to keep it inactive while the line isn't being driven somehow (AVR is in reset, etc.)?

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Pullup on SS for uSD card is more problematic when you have switched power for the card. You do not want SS being pulled up when the card is unpowered. That ends up demanding a bit of thought about the boot-up sequence of applying power and various signals (including soft pullups). This is further complicated if that pullup is a resistor. You MIGHT want to consider having the pullup connected to the switched uSD power, but again, you need to think through the consequences and what you want it to accomplish.

 

Jim

Jim Wagner Oregon Research Electronics, Consulting Div. Tangent, OR, USA http://www.orelectronics.net

Last Edited: Mon. Apr 17, 2017 - 06:01 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Another option I have used in the past is to put a 1K resistor in series with MISO so that ISP has priority over the peripherals, however in this case you may have MOSI pins fighting among themselves during reset or programming session and therefore the pullup/pull-downs would be best.

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

js wrote:
Another option I have used in the past is to put a 1K resistor in series with MISO so that ISP has priority over the peripherals, however in this case you may have MOSI pins fighting among themselves during reset or programming session and therefore the pullup/pull-downs would be best.

 

Besides the "priority" to accomplish ISP, IME keeping the peripheral devices deselected so they don't become "confused" when e.g. the AVR is in reset and ISP or noise or whatever is putting some stream of bits on MOSI.  [IME SD-cards are particularly susceptible]

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

keeping the peripheral devices deselected so they don't become "confused"

As soon as I wrote the above I knew I had to find the number of the chip I have used that doesn't have a data out disable feature. wink

 

MBI5039 has no SDO disable so the only option one has is to put a 1K resistor at the end of the chain of chips used http://www.fairchip.com/pdf/MACR...

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The ElmChan SD card library documentation recommends switched power for the microSD card AND a pull-up resistor on the select line to the local (switched) power. This insures that, if the SS pin is a floating input as it is after a reset, there will be no hardware pull-up when the card is unpowered AND it will immediately disable the card when power is turned on. Then, you need to turn on the select pin. With a standard Mega/Tiny, AFTER card power is turned on, while the pin is an input, enable the pullup on the SS pin. That does not change the pin state since the external resistor (with card power on) is also pulling up. Now, when you change the pin to output, the logic level will still be high with no switching transients.

 

In an earlier design, I omitted the card power switch and it has cost battery life. Now, I have included it and follow the procedure just described.

 

Jim

Jim Wagner Oregon Research Electronics, Consulting Div. Tangent, OR, USA http://www.orelectronics.net

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Jim,   I did not find the recommendation on the ElmChan website you mentioned, could you post a link or better a schematic of this setup.

Thanks

Jim

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Just checked the web site and that schematic is no longer there! It talks about hot insertion but not power switching. I will post a schematic in a few hours.

 

Jim

Jim Wagner Oregon Research Electronics, Consulting Div. Tangent, OR, USA http://www.orelectronics.net

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

ka7ehk wrote:
It talks about hot insertion but not power switching.

must not go there...must not go there...must not go there...

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

ka7ehk wrote:
Just checked the web site and that schematic is no longer there!
Not this then??...

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Here is the schematic I remember:

The memory card is on the right, the system is on the left. I recall C1 being moderately small (maybe 1nf to 10nf, but not sure). Note that when 3V3_SW is off, there is no pullup on the /SS line to parasitically drive the card (if the /SS logic source is equivalent to open-drain). But, as soon as power is turned on, /SS is pulled to the supply rail (again, IF the /SS logic source is equivalent to open-drain at this point) and the card is held in the disabled state until the /SS logic source is turned into an active output. Thus, there is no glitch on that line between switched power turn on and the proper configuration of the /SS logic source pin.

 

The current schematic considers transient conditions when a card is plugged into a live socket.

 

Jim

Jim Wagner Oregon Research Electronics, Consulting Div. Tangent, OR, USA http://www.orelectronics.net

Last Edited: Tue. Apr 18, 2017 - 08:26 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I am going to have a display, rtc, and a pair of microsd cards on one bus.  I saw in the data sheet that I can configure MISO to have its pullup enabled, but externally I plan to put a pullup on the SS line for each of the 4 devices in case the AVR is in reset, they will stay high.  When the AVR is running, all 4 pins will be output high unless they are being accessed.  Given that MOSI and SCK are driven from the uc, I wouldn't think they would need a pullup/pulldown, right?  Also, I don't think it is an issue if the MISO pullup isn't enabled because the AVR is in reset either because all the SS lines will be pulled high.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

There are several points that you want to watch out for:

 

1) What is the sequence of events as the system powers up? Factors that impact this include

     a) Is the uSD powered from system power or does it have its own switched power? If switched, what defines the state of the switch during power-up?

     b) How does the uSD chip select behave during reset?

     c) Is there any possibility of glitches as the MCU port pins are enabled?

 

2) If the uSD operates with switched power, can any of the logic pins of the uSD be logic high when it is not powerd? Even as a transient? This includes pull-ups!

 

Jim

Jim Wagner Oregon Research Electronics, Consulting Div. Tangent, OR, USA http://www.orelectronics.net

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I hadn't planned on switching the uSD power - and I am out of pins or the AVR I am using, so I'd rather not.

 

#1a - system power.

#1b - pullup should keep uSD CS high during AVR reset.

#1c - the CS pins should all be pulled high, the other pins are probably undefined until setup, but since the CS is high, should that matter?

#2 - no switched power.

 

Thanks Jim!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Since you are not switching power, its much easier. There should never be a case where the chip is not powered while the rest of the system is. So, your simple pull-up on chip select should work just fine.

 

Jim

Jim Wagner Oregon Research Electronics, Consulting Div. Tangent, OR, USA http://www.orelectronics.net

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Jim, isn't the Drain swapped with the Source in your schematic ?

 

George.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thought that I rotated and mirrored correctly, but might not have. Not exactly sure what the symbol conventions are for NMOS and PMOS. Ugg, guess the parasitic diode shows that it is backward. Will try to correct it for future visitors.

 

Jim

Jim Wagner Oregon Research Electronics, Consulting Div. Tangent, OR, USA http://www.orelectronics.net

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks everyone; I've got FATFS working with 2 sdcards - I even copied a file from one to the other successfully.