Created Fri, 21 Feb 2014 17:53:16 +0000 by GrahamM242
Fri, 21 Feb 2014 17:53:16 +0000
I'm using a UNO32, with MPIDE 20140121-test. I've been trying to do some SPI stuff using DSPI, but I'm having a number of issues. I've tried to strip my sketch down as small as I can to reproduce the issue, and the sketch below has the issues.
Basically, I can use SPI happily, as long as I don't call spi.setSpeed. As soon as I do call it, my code stops working! Remove the setSpeed method, and I've a blinking LED again.
#include <DSPI.h>
uint8_t ledState=HIGH;
DSPI0 spi;
void setup() {
pinMode(PIN_LED1, OUTPUT);
spi.begin();
spi.setSpeed(2500000);
}
void loop() {
digitalWrite(PIN_LED1,ledState);
if (ledState == LOW)
ledState = HIGH;
else
ledState = LOW;
delay(1000);
}
Fri, 21 Feb 2014 18:27:27 +0000
I don't know about the setSpeed method (I have never had an issue with it), but I can see one thing wrong with your sketch...
Think for a moment about which pins the SPI port is using. Then think as well about which pin the LED is connected to.
Fri, 21 Feb 2014 20:18:27 +0000
Guess I should swap the LED over to the second one then... ;) Thanks for that catch - I'll see how things work out.