SPI Problem

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

Hi Freaks

Want some advice on SPI connections.
DataFlash, AVR and ISP need to be connected.
Normally want to avoid using ISP pins.
This time there's no choice.
What to do with the red line??
Note that AVR run at 5V and DataFlash at 3V3.

Attachment(s): 

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

Your red line can be another 470R resistor.

Your two 1k0 resistors on the /SS line are WRONG. Just remove them. Then your SDCard will pull /SS high with its 4k7 pull-up.

With SPI, you have all the devices sharing the MISO, MOSI and SCK lines. But each SPI device has its own '/SS' ( active-low select signal) pin.

The AVR (as a Slave SPI device when it is being programmed) uses the /RESET pin as its active-low-select pin.

The SDCard uses /SS. And is thus never enabled by the ISP programmer.

So everything should be just fine.

David.

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

Hello David

Your answer lead to more questions...
First of all it's not an SD Card, it's a DataFlash from Atmel. Not that it matters for this discussion.

Regarding SS pin. It has a high level of 5V when DataFlash is not selected.
Maybe I should make that pin an input when not used to pull SS pin low?
If not, will it not feed 5V to 3V3 DataFlash input with no pull-down resistors?

Quote:
Your red line can be another 470R resistor.

Will it still have enough oomph to send a "1" to AVR?

I'm not worried that DataFlash will be corrupted when ISP is programming AVR. The pull-up resistor should prevent this. Maybe 10K is a better value. I need to be certain that SS is kept high during PWR ON and ISP programming.

I am worried that 5V signals from ISP will destroy SO pin of DataFlash with only .470 resistor.
Or is SO pin TOTALLY disconnected while SS pin is high?

Questions, questions...

Quote:
Your two 1k0 resistors on the /SS line are WRONG

I believe only one 1K resistor is connected to /SS pin.

Edit: Oh s**t! Now that I see my schematic again I notice that there ARE two pull-down resistors on /SS line.
One of them should be connected to AVR MOSI line. Sorry...

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

Lennart wrote:
Hello David

If not, will it not feed 5V to 3V3 DataFlash input with no pull-down resistors?


Run your AVR at 3.3V. I supect that this is a hobbyist project. Your AVR will run ok at the lower voltage.
Quote:

Quote:
Your red line can be another 470R resistor.

Will it still have enough oomph to send a "1" to AVR?
Yes.
Quote:

I'm not worried that DataFlash will be corrupted when ISP is programming AVR. The pull-up resistor should prevent this. Maybe 10K is a better value. I need to be certain that SS is kept high during PWR ON and ISP programming.
10k will be fine
Quote:

I am worried that 5V signals from ISP will destroy SO pin of DataFlash with only .470 resistor.
Or is SO pin TOTALLY disconnected while SS pin is high?
Use 3.3V

The AVRISP-2 or JTAG-mkII only read your Vcc. So they will quite happily program a 3.3V system.

If you use a STK500, this can (and I usually do) supply Vcc. So before you ever connect a Dataflash, you must set the STK500 Vtarget voltage to 3.3V.

p.s. you can fart about with level-translating buffer chips. Or with resistor voltage dividers. A single 3.3V is far simpler.

David.

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

Quote:
Run your AVR at 3.3V. I supect that this is a hobbyist project. Your AVR will run ok at the lower voltage.

No and no,
There are other devices that need 5V communicating with AVR. So that's not an option.
Actually I'm aiming to make this a product so it need to be done "by the book".

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

I would still consider a 3.3V system. Which devices need to be 5V?

You are going to end up with mixed levels somewhere on your board. So you will have a level-translater chip somewhere. Many pins are o/p only or i/p only. So they are easy to shift. A pin that changes direction is a pain.

David.

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

Trying to summarize advices given.

Use 10K as pull-up. Actually chose that value at first.
The DataFlash will be close to on-board relays and off-board relays and motors switching ON/OFF so I changed to 4K7 to avoid spikes turning /SS pin low. Better safe than sorry but 4K7 not needed then?

470R resistor on red line is enough to protect SO.

Use DDRx to make /SS pin input when not used

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

Your AVR will always be Master to the DataFlash. At Reset, the AVR /SS pin will be an input pulled-up by the 10k. (or 4k7 if you like)

I would suggest that the Master always sets and keeps it as an o/p when the AVR is not in Reset. e.g. /SS driven high when not using DataFlash. This should solve any EMI issues.

You do not need 470R at all. Your programmer will only drive MOSI when it is programming. The AVR is in Reset during programming. When the programer finishes it generally releases all the lines. So they go to whichever levels pull-up or pull-down resistors take them.

As soon as the AVR is running, any pins that it sets as o/p will override the puny resistors. The only pin that the DataFlash ever 'drives' is SO. Unless you program the AVR's MISO as an o/p there is no conflict.

If your AVR goes crazy and sets MISO as an o/p: the max current would be 7mA with the 470R. (if the DataFlash has zero output resistance). Look up the AT45 data sheet. I am sure that the current will be less (due to AT45 o/p resistance).

David.

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

Quote:
You are going to end up with mixed levels somewhere on your board. So you will have a level-translater chip somewhere. Many pins are o/p only or i/p only. So they are easy to shift. A pin that changes direction is a pain.

That's no real problem.
I have an LCD that run at @4MHz on 3V3 on another board that works like a charm with voltage dividers (470R/1K).
None of it's pins are bi-directional.

The big issue using 3V3 is I2C. I have a bus extender chip that send I2C to other devices through long cables (tens of meters). This is bi-directional and I'd rather not mees with that. Running 3V3 through these cables sound scary too.

I'm not a HW guy, but with lower voltages, does that not increase the possibility that transients get into my system?
I started this development at 3V3 and noticed that a incandescent lamp turned on nearby made AVR reset. This disappeared when I switched to 5V. And the spikes are expected to be nastier in the environment the product will live in.

Another issue is 6 relays on the board that need 5V for its coils.
So there's no way to avoid multiple voltage sources, is there?

Another issue is the board might be connected to a mobile phone used as a modem. Most phones want 5V.

Another issue is 8 NTC termistors connected with bias resistors to 5V. My guess is that lower voltage will make LSB of ADC more vulnerable to outer disturbances (NTC cables might be ten meter).

The dataFlash is a sort of last minute add to the project to be able to log data.
Don't want to start all over again.
The prototype has been tested for more than a year so I trust the HW.

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

Quote:
The only pin that the DataFlash ever 'drives' is SO. Unless you program the AVR's MISO as an o/p there is no conflict.

Not wooried that AVR will set MISO as o/p.
The conflict that worries me is that when ISP program AVR it will be driving the line shared by MISO and SO and that SO pin will receive the same signals as MOSI pin(5V), and also that driving voltages to an output pin (SO) might harm it.
Maybe that's not an issue if /SS pin is kept high. Don't know if SO is tri-stated in a safe way then.

Note that all resistors with exception of pull-up to /SS are level translators and not used to pull-up/pull-down any lines.

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

Quote:
If your AVR goes crazy and sets MISO as an o/p: the max current would be 7mA with the 470R. (if the DataFlash has zero output resistance). Look up the AT45 data sheet. I am sure that the current will be less (due to AT45 o/p resistance).

Copied from AT25DF161 datasheet:
Quote:
CHIP SELECT: Asserting the CS pin selects the device. When the CS pin is deasserted, the
device will be deselected and normally be placed in standby mode (not Deep Power-Down
mode), and the SO pin will be in a high-impedance state.

This suggests that SO will be high-impedant when /CS is deasserted so I guess it's safe with R470 replacing the red line?