Can I use the SPI pins for two functions?

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

Hi Freaks,

I am building a board with ISP capability with SPI pins. I have a MAX306 16 channel MUX/DEMUX on the SCK,MISO and MOSI pins. I have a RESET switch which pulls the RESET pin to GND.

Can I connect the three SPI pins to the MUX and still use them for programming? Do I need pull ups on those lines? Also what about the RESET pin? Since I have a switch on it, do I have to manually keep it pressed when I am programming my AVR with the three SPI pins?

Also do I have to add anything to my code/ set any fuses to enable ISP programming? I am planning to use the AVRISP for future in system programming if needed.

Thanks.

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

Yes you can connect the SPI pins to the mux as long as you take the direction of the pins into account. You do not need pullups.

You should control the RESET pin from your ISP programmer. It is also controlled by the AVRISP.

Ole

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

I must be missing somehting if this is the MAX306 datasheet:

http://www.datasheetcatalog.org/...

Where in any of that does it say anything about an SPI interface.

I was going to make the point that it's "slave select" should be driven by the AVR and held in a none active state while the AVR is in _RESET by a pull-up/pull-down. But it has neither a slave select nor an SPI interface?

Cliff

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

Thanks, Ole.

Quote:

Yes you can connect the SPI pins to the mux as long as you take the direction of the pins into account

What do you mean by taking the direction of pins into account?

In this case I am using pins PB5,PB4 and PB3 of my M48 to select mux lines ie. as outputs. So, is it ok that when I am in ISP mode, I will have to use SCK and MOSI pins as inputs and MISO as output. Will this work if I am using all the three pins as outputs in the first place (when not in ISP mode)?

Cliff,
I don't want the MUX to use the SPI pins. I am using the same AVR pins for ISP and driving the MUX lines and want to know if this dual functionality is possible.

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

So your question really does not have anything to do with the SPI interface? You are just using the same pins as the SPI would, but you are using them to control the MUX address input pins?

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

npat_avr wrote:
Thanks, Ole.
What do you mean by taking the direction of pins into account?

I meant that during SPI programming the MOSI and SCK pins on the AVR are inputs and MISO output and when the same AVR is configured as SPI master the MOSI and SCK are outputs and MISO input.

Ole

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

AgwanII wrote:
So your question really does not have anything to do with the SPI interface? You are just using the same pins as the SPI would, but you are using them to control the MUX address input pins?

Right, so if the MAX306 remains chip selected while ISP pulses the 4 address lines it's going to rapidly switch one of 16 analog signals to be connected to an AVR pin. As the AVR is in _RESET this shouldn't matter but I guess you could loosely tie the enable pin on the MUX to keep it inactive then drive it active by an IO from the AVR.

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

Quote:
Right, so if the MAX306 remains chip selected while ISP pulses the 4 address lines it's going to rapidly switch one of 16 analog signals to be connected to an AVR pin.
There is no chip select on the MUX, you probably mean the enable pin. If this enable pin is controlled by the AVR, you can as clawson sais, pull it loosely to GND to hinder unwanted signals trough the MUX. It has to be controlled by the AVR since it will not tri-state otherwise when the AVR is under reset.

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

Thanks,guys. That makes sense. So when you want me to loosely tie to GND, should I use a jumper to actually tie to GND?

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

Quote:

So when you want me to loosely tie to GND, should I use a jumper to actually tie to GND?

That'd be one way to do it (always assuming you think it switching might affect ISP - not sure I'd worry). The other is to tie it with a 10K pull-up/down to the inactive state then connect it to an AVR IO line and drive it to the active state when it's being used. But I guess the jumper idea doesn't "cost" an AVR pin though it's a bit more "manual"