multiple spi devices

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

Hi I have two spi devices on one mega1284, an sd card reader and a wireless nrf24L01+. If I dont initialize the sd card the nrf works, if I do initialize the sd card - it works fine but the nrf doesn't. Nothing is on the 1284's SS line, so they both have their own CS pins. I remember selecting an SPI device is something to do with this (I think) so is it that I set the relevent CS pin high when I dont want to use it?
Generally I will need to flip between the one I am communicating with - i.e read data from sd, send data via nrf...

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

Use SS pin for CS1 and any other GPIO pin for CS2.

You never have both CS pins low at any one time.

You can use separate GPIO pins for CS1 and CS2 if you want. Just make sure that SS is made an output even if you don't use it (or else the SPI goes haywire).

David.

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

Yeah cheers David, i know about SS pin, it sets avr to master or slave right...
Its the using two and swapping between them that confused me, so basically if I set on of the CS pins low, the other device will communicate with the AVR and vice versa?

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

Alex,

Sit down with your data sheet. SPI devices are always active-low /CS. So only ONE device can be low at any time.
Obviously both /CS1 and /CS2 can be high at the same time. Meaning that both devices are inactive.

David.