I am using an Arduino Nano, ATmega328P with the old bootloader. When I call SPI.begin() anywhere in the program (either in a seperate callable function, the setup or inside main) the program freezes and the Arduino doesn't seem to budge. Any chance I am doing anything wrong?
It does not matter if I have periphery hooked up or if I don't.
Other libraries which use SPI like the nRFLite library work just fine. I know this because I can successfully communicate with the nRF chip through the library and the example sketches work.
#include <SPI.h>
int CEpin = 9;
int CSNpin = 10;
//the blinky function is used for debugging and just flashes the on-board LED
void blinky(int repeats, int pauseLength){
for(int i = 1; i <= repeats; i++){
digitalWrite(LED_BUILTIN, HIGH);
delay(pauseLength);
digitalWrite(LED_BUILTIN, LOW);
delay(pauseLength);
}
}
void setup() {
pinMode(CEpin, OUTPUT);
pinMode(CSNpin, OUTPUT);
pinMode(LED_BUILTIN, OUTPUT);
blinky(5, 100);
//de-select slave and set chip-enable of slave to 0
digitalWrite(CEpin, LOW);
digitalWrite(CSNpin, HIGH);
//begin SPI with normal settings
SPI.begin();
blinky(25, 50);
}
void loop(){
}
Is there anything I am not seeing?
EDIT: Wanted to apologize for not posting the code in the first place.