Roger Parkinson
Active member
Can we run multiple SPI devices on a Teensy++ 2.0? Here is what I'm doing:
1) an SD card with its CS on pin 20
2) a tiny LCD from Adafruit (http://www.adafruit.com/products/326) with its CS on pin 7
3) an RTC
4) a pulse detector, which is just a one wire thing on pin 0 (two other pins supply power)
The MISO, MOSI and SCLK are on 23, 22, 21
Now, when I run my code everything works except the LCD stays blank.
When I comment out the init of the SD card specifically:
Then the LCD works perfectly.
It feels like I can only have one of them but when I read about SPI it says this ought to work.
I set pinMode to OUTPUT for the two CS pins, but I don't know if I need that, it didn't help anyway.
My real goal is to get this running on a Teensy 2.0 which is slightly smaller, and small is good here, but I had problems that I put down to running out of memory but might have been similar to this.
So if there's a solution I hope it applies to Teensy 2.0 as well.
And I'd use a Teensy 3 but I have too many old Teensy boards lying around to not use them!
The code is in https://github.com/RogerParkinson/HeartMonitor.git
Just before the last commit I tried changing the SD SS to use pin 8 rather than pin 20. It made no difference, but that's what is there now.
Also, that's an Eclipse project rather than an Arduino one which might confuse people not expecting it, but the code is visible anyway.
Thanks for any help
Roger
1) an SD card with its CS on pin 20
2) a tiny LCD from Adafruit (http://www.adafruit.com/products/326) with its CS on pin 7
3) an RTC
4) a pulse detector, which is just a one wire thing on pin 0 (two other pins supply power)
The MISO, MOSI and SCLK are on 23, 22, 21
Now, when I run my code everything works except the LCD stays blank.
When I comment out the init of the SD card specifically:
Code:
if (!SD.begin(select)) {
Serial.println("Card failed, or not present");
// don't do anything more:
return;
}
Serial.println("card initialised.");
It feels like I can only have one of them but when I read about SPI it says this ought to work.
I set pinMode to OUTPUT for the two CS pins, but I don't know if I need that, it didn't help anyway.
My real goal is to get this running on a Teensy 2.0 which is slightly smaller, and small is good here, but I had problems that I put down to running out of memory but might have been similar to this.
So if there's a solution I hope it applies to Teensy 2.0 as well.
And I'd use a Teensy 3 but I have too many old Teensy boards lying around to not use them!
The code is in https://github.com/RogerParkinson/HeartMonitor.git
Just before the last commit I tried changing the SD SS to use pin 8 rather than pin 20. It made no difference, but that's what is there now.
Also, that's an Eclipse project rather than an Arduino one which might confuse people not expecting it, but the code is visible anyway.
Thanks for any help
Roger