SPI bus (SCK) and ISP.. am i going to have problems? Mega128

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

Hi,

I have two questions about the SPI bus

1)
let's say i have the SCK pin on the mage128 set as an output.. and let's say it's doing it's thing.. clocking other devices on the SPI.. now.. remember it's an output.. let's say.. while it's doing it's thing.. i decide to reprogram to try out some new code.. i plug the programmer into the ISP header, and process to program.. while the AVR is runing some code and working the SPI bus..

the SCK pin is used by the programmer to program the AVR.. so.. what happens? wouldn't there be a collision?? the AVR is trying to clock stuff on the SPI bus (just doing its thing).. but the programmer wants to program.. so basically.. i'm connect two outputs together... :shock:

so... yeah... what do you do here??

2)
so.. say i have a device on the SPI bus (that is.. the Mega128 as master, and the other device as slave).. when i wnat to program using ISP.. the SCK that is going to program the Mega128 is also clocking the other device on the SPI bus.. is that a problem?? and then when it's done programming the mega 128 changes it's SCK pin from an input to an output to start clocking the otehr device on the ISP bus...

is this a problem?? As long as I reconfigure the device everytime i run my AVR code.. it shoudl be okay right?? or do you guys recommened i do something in hardware...

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

1) ISP programming on AVRs is done with the AVR held in reset, so no, SCK is not an output at that time and will not be outputting anything.

2) First, see #1. Next, use a weak pulldown or pullup on the chip select line of your AVR slave device to keep it in the "not selected" state. Then when doing ISP the AVR's pins are floating inputs and the pullup/down keeps the slave device in the not-selected state so ISP won't bother it.

Lee

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:
1) ISP programming on AVRs is done with the AVR held in reset, so no, SCK is not an output at that time and will not be outputting anything.

2) First, see #1. Next, use a weak pulldown or pullup on the chip select line of your AVR slave device to keep it in the "not selected" state. Then when doing ISP the AVR's pins are floating inputs and the pullup/down keeps the slave device in the not-selected state so ISP won't bother it.

Lee

hehe cool man.. thanks..

this means i should use a pull up resistor...

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

Quote:

this means i should use a pull up resistor...

It depends on the device. Some have CS; some have /CS.

Lee

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:
Quote:

this means i should use a pull up resistor...

It depends on the device. Some have CS; some have /CS.

Lee

right.. the device has a CSN line.. which is Chip select not.. it's active low.. so i would pull up...

thanks though