Created Tue, 09 Sep 2014 22:56:54 +0000 by punk77
Tue, 09 Sep 2014 22:56:54 +0000
hello, I would like to know which are default pins for SPI in fubarino mini. I know, arduino pins are
SPI: 10 (SS), 11 (MOSI), 12 (MISO), 13 (SCK).
but I read on board_defs.h for MPIDE v0023 that
I need to check also in arduino_boards.h?
#if defined(AVR_ATmega1280) || defined(AVR_ATmega2560) const static uint8_t SS = 53; const static uint8_t MOSI = 51; const static uint8_t MISO = 50; const static uint8_t SCK = 52; #else const static uint8_t SS = 10; const static uint8_t MOSI = 11; const static uint8_t MISO = 12; const static uint8_t SCK = 13; #endif
I need to use mapPps() function? Is it enought to declare in my sketch:
#include <SPI.h>
#define DATAOUT 11//MOSI #define DATAIN 12//MISO #define SPICLOCK 13//SCK (orig-13)
void setup () {
pinMode(ss, OUTPUT); pinMode(DATAOUT, OUTPUT); pinMode(DATAIN, INPUT); pinMode(SPICLOCK,OUTPUT);
SPI.begin(); SPI.setDataMode(SPI_MODE0); SPI.setBitOrder(MSBFIRST); SPI.setClockDivider(SPI_CLOCK_DIV16); ...
let me know
thank you
best regards
Tue, 09 Sep 2014 23:13:51 +0000
I'm not sure the old SPI library supports PPS directly, so you would need to manually map the pins you want to use (referencing the data sheet for the main chip to find the allowable pins).
Better, use the DSPI library (included with MPIDE) which does support PPS.
At the bottom of Board_Defs.h for the Mini you have:
#define _DSPI0_MISO_IN PPS_IN_SDI1
#define _DSPI0_MISO_PIN 19
#define _DSPI0_MOSI_OUT PPS_OUT_SDO1
#define _DSPI0_MOSI_PIN 18
so the MOSI is by default pin 18, and the MISO pin 19, when using the DSPI library channel DSPI0. Not sure what the SCK pin is, but that's fixed and can't be changed, so you can look that one up in the manual easily enough.