ISP - SPI resistors

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

Hello Gentlemen and Gentlewomen,

 

I am using the SPI bus to load data to an external device that uses the MOSI and SCK pins, and I am using the 6 ISP pins for my programmer.  App notes show placing 330 Ohm resistors on the MOSI and SCK pins so the external device does not interfere with the programming.  I have built circuits both with and without 4.7 k resistors and they both seem to work.  I have also read that in some cases I don't really need the resistors.  Can someone clue me in to when I need these resistors and when I don't, and what size they should be.

 

Thanks,

mark

Last Edited: Sat. Dec 17, 2016 - 08:27 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The resistors are helpful when you have one or more devices connected to teh SPI lines as they provide a certain level of isolation provided you connect your programming interface directly to the MCU SPI pins.  The resistors will prevent loading from two outputs being connected together.

 

I myself have used 220 ohms and been fine.  I would not use 4.7k as it will lover the bus drive capabilities severely.

 

Jim

I would rather attempt something great and fail, than attempt nothing and succeed - Fortune Cookie

 

"The critical shortage here is not stuff, but time." - Johan Ekdahl

 

"Step N is required before you can do step N+1!" - ka7ehk

 

"If you want a career with a known path - become an undertaker. Dead people don't sue!" - Kartman

"Why is there a "Highway to Hell" and only a "Stairway to Heaven"? A prediction of the expected traffic load?"  - Lee "theusch"

 

Speak sweetly. It makes your words easier to digest when at a later date you have to eat them ;-)  - Source Unknown

Please Read: Code-of-Conduct

Atmel Studio6.2/AS7, DipTrace, Quartus, MPLAB, RSLogix user

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

jgmdesign wrote:

The resistors are helpful when you have one or more devices connected to teh SPI lines as they provide a certain level of isolation provided you connect your programming interface directly to the MCU SPI pins.  The resistors will prevent loading from two outputs being connected together.

 

I myself have used 220 ohms and been fine.  I would not use 4.7k as it will lover the bus drive capabilities severely.

 

Jim

jgmdesign wrote:
The resistors will prevent loading from two outputs being connected together.

As always, "it depends", right?

 

If you have true ISP slave devices, then IMO/IME there is no need for any isolation for ISP purposes -- as long as you use a weak pulling resistor on the chip-select to keep the device de-selected when the AVR is in reset.  And that is when ISP is done.  Think about it -- if this is indeed the case, then there cannot be "outputs connected"; if that would exist then SPI wouldn't work.

 

Now, where we >>do<< have an isolation resistor is on Mega128 family on the shared RXD line used in ISP.  There, the transceiver will be driving the signal during ISP.

 

 

 

 

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

theusch wrote:
As always, "it depends", right

Correct, as you note here:

theusch wrote:
as long as you use a weak pulling resistor on the chip-select to keep the device de-selected when the AVR is in reset.

 

JIm

I would rather attempt something great and fail, than attempt nothing and succeed - Fortune Cookie

 

"The critical shortage here is not stuff, but time." - Johan Ekdahl

 

"Step N is required before you can do step N+1!" - ka7ehk

 

"If you want a career with a known path - become an undertaker. Dead people don't sue!" - Kartman

"Why is there a "Highway to Hell" and only a "Stairway to Heaven"? A prediction of the expected traffic load?"  - Lee "theusch"

 

Speak sweetly. It makes your words easier to digest when at a later date you have to eat them ;-)  - Source Unknown

Please Read: Code-of-Conduct

Atmel Studio6.2/AS7, DipTrace, Quartus, MPLAB, RSLogix user

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

And, more importantly, that "weak pullup" MUST be external. You cannot count on an internal pullup. Here is why: during programming, the MCU is held in reset. No program is executed (until after the programming is all finished). In reset, all GPIO pins are inputs with no pullup on. So, to prevent response by any other device sharing the SPI port, all SPI chip select lines should have a weak pullup resistors (I use 100K, you mileage may vary) to hold those devices in unselected mode while programming is happening. With THIS isolation scheme, you can run your SPI bus at maximum appropriate speed.

 

Jim

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

Last Edited: Sun. Dec 18, 2016 - 07:08 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Does someone remember the App note number?

Ross McKenzie ValuSoft Melbourne Australia

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

 

ka7ehk wrote:
all SPI chip select lines should have a weak pullup resistors

Not exactly -- each should have weak pulling resistors in the direction to keep the SPI slave device unselected.  This could be pullup or pulldown depending on the device.

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

Correct. Many are active low but that is not specifically required by SPI rules.

 

Jim

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

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

valusoft wrote:

Does someone remember the App note number?

 

AVR910 - Page 4, section 2.2

 

AVR042 - Page 8 Section 4.1.1

 

AVR151 - Page 6

 

I would have posted links but that gets the post deleted with the spam filter acting wonky lately.

Jim

I would rather attempt something great and fail, than attempt nothing and succeed - Fortune Cookie

 

"The critical shortage here is not stuff, but time." - Johan Ekdahl

 

"Step N is required before you can do step N+1!" - ka7ehk

 

"If you want a career with a known path - become an undertaker. Dead people don't sue!" - Kartman

"Why is there a "Highway to Hell" and only a "Stairway to Heaven"? A prediction of the expected traffic load?"  - Lee "theusch"

 

Speak sweetly. It makes your words easier to digest when at a later date you have to eat them ;-)  - Source Unknown

Please Read: Code-of-Conduct

Atmel Studio6.2/AS7, DipTrace, Quartus, MPLAB, RSLogix user

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

App note AVR 042 suggests 330 Ohms.  I didn't see any specific values in the other two app notes.  I guess I am going to go with 330 Ohms.

 

Thanks guys,

mark

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

And in pictorial summary...

 

Ross McKenzie ValuSoft Melbourne Australia

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

The Note 1 says these are typical values to limit input current to 10mA for Vcc of 3.3V.  I'm wondering if that means I should use 510 Ohm for a 5V SPI bus.

 

mark

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

BTW, does anybody know why I am not getting a notice to my email when a reply is posted and I have the box below checked to notify me?  That used to work fine.

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

Email notifications are kaput, for now. Lots of reports of no operation. See recent threads about email notifications.

 

Ah, yes, the other case: DEBUGGING. DebugWire uses the reset line as a one-wire serial link so THAT does not cause contention wth other SPI users. But, some of the debug protocols may produce contention. If you use an M48/88/168/328, debugging is via DebugWire and you don't need those resistors. You DO want a pull (up or down) resistor on the chip select to hold the peripheral unselected while in reset. Other AVRs may be, and probably are, different.

 

Jim

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

Last Edited: Sun. Dec 18, 2016 - 11:36 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Ohm man, so much good stuff in this thread.  Any more I should know about?

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

I guess it's fine to continue in here as it's not years old topic?

theusch wrote:
Now, where we >>do<< have an isolation resistor is on Mega128 family on the shared RXD line used in ISP.  There, the transceiver will be driving the signal during ISP.

So, did I get this right, if I wanted to use USART and SPI(programming only) from the same pins, I should have series resistors in the RX/TX lines? On mega328pb the SPI/USART periephals shares pins and I need both, even if it's SPI only once to get bootloader.

This might have saved me quite many euros.

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

This is a very useful document...

 

https://www.kanda.com/files/isp_...

#1 This forum helps those that help themselves

#2 All grounds are not created equal

#3 How have you proved that your chip is running at xxMHz?

#4 "If you think you need floating point to solve the problem then you don't understand the problem. If you really do need floating point then you have a problem you do not understand." - Heater's ex-boss