Created Wed, 02 Apr 2014 15:01:28 +0000 by randomrichard
Wed, 02 Apr 2014 15:01:28 +0000
The 64pin PIC used has three hardware spi ports, with the SD card connected to spi2. I am trying to both use the SD card and connect an ADC to spi3 on the PIC's pins RD1, RD2, RD3, RD9, as per datasheet. But the pin reference table in the Fubarino SD manual has RD9=SDA1 (which doesn't exist) and RD1,2,3 having no spi function at all. Have the registers been set so that only one of the PIC's spi's can be used, as suggested in the short manual section entitled "Using the microSD". If so why, and what can be done about it?
Wed, 02 Apr 2014 15:21:49 +0000
The Fubarino SD's config files have 2 SPI ports set up:
DSPI0 = Hardware SPI 2 (SD card and labelled SPI port) DSPI1 = Hardware SPI 3 (RD1/2/3)
RD1/2/3 are pins 7 8 and 9 respectively on the Fubarino. That is,
7 = SCK3 (AKA DSPI1 Clock) 8 = SDI3 (AKA DSPI1 MISO) 9 = SDO3 (AKA DSPI1 MOSI)
Using the DSPI library should give you access to those pins (I have used them before, and they are fine):
#include <DSPI.h>
DSPI1 spi;
void setup() {
spi.begin();
}
void loop() {
int x = spi.transfer(0xFF);
}
Wed, 02 Apr 2014 15:42:51 +0000
majenko - many thanks. I can confirm that a second DSPI port works, gathering data using Fubarino pin 1 as the bar SS output, and both storing data in a file on the SD card and sending it to the PC. Now for the speed trials. All I need now is a chip with all that plus hardware digital signal processing programmable in mpide. R
ps The PC receives 16bit data from the AD977 at a maximum rate of 55ksps, limited by the USB link and just over half the ADC's maximum rate. Achieving error-free sends requires tuning: spi SCK at 3MHz, 9microsec delay after reading a word.