chipKIT® Development Platform

Inspired by Arduino™

Two SPIs?

Created Wed, 18 Jan 2012 15:10:36 +0000 by slayer1991


slayer1991

Wed, 18 Jan 2012 15:10:36 +0000

Do we have 2 SPI interfaces on UNO32? In the excel pinout table there are 2 SS, SCK, SDI and SDO. If yes can we modify the libraries to work with one or the other SPI?

And how do you address pins? PORT a b c is clear, but how do you count the pins in the port? Maybe give me a couple of examples with reference to the excel tables or the schematic in PDF format.

Thanks!


majenko

Wed, 18 Jan 2012 15:21:51 +0000

how do you count the pins in the port?

Please elaborate on this question - I don't follow what you mean here.

The Uno32 user guide shows you the mapping between PIC32 port names/numbers and the IO pins on the board. Is this what you are after? [url]http://digilentinc.com/Data/Products/CHIPKIT-UNO32/chipKIT%20Uno32_rm.pdf[/url]

Also, all the ports are 16 bits in size. Not all ports have all pins available. You're best off looking at the data sheet for the specific PIC on the Uno32 for more detail about the internals. [url]http://www.microchip.com/wwwproducts/Devices.aspx?dDocName=en532434[/url]

There is also the Pic32 Family User Reference which has more detail about how the IO ports work. [url]http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=2612[/url]


slayer1991

Wed, 18 Jan 2012 15:45:58 +0000

Here is an example #define SCLK 0x40 #define SCLK_PORT PORTG and then you call this pin, which is pin 13 SCK2, pic pin 4, third one in PORTG.

What about using SPI1?


slayer1991

Wed, 18 Jan 2012 18:40:40 +0000

I'm not sure, but I think there aren't any libraries (spi_legacy) for SPI1. It would be great if we could use that one too.

LE: correction. SPI1 is in spi_legacy.h I'll try to use it to control a TLC5940


slayer1991

Wed, 18 Jan 2012 19:35:50 +0000

The pins to SPI2 are

10 ss2 11 mosi2 12 miso2 13 sck2

For SPI1 the pins are 14/A0 ss1 1 mosi1 U1TX/SDO1 0 miso1 U1RX/SDI1 38 SCK1

/** Chipkit Ports **/
#define VPRG 0x2
#define VPRG_PORT PORTF        /** pin 4, RF1, pic 59 **/

#define SOUT 0x100
#define SOUT_PORT PORTG        /** pin 11, SDO2/PMA3/CN10/RG8, pic 6 **/

#define SCLK 0x40
#define SCLK_PORT PORTG        /** pin 13, SCK2/PMA5/CN8/RG6, pic 4 **/

#define GSCLK 0x1
#define GSCLK_PORT PORTD       /** pin 3, OC1/RD0, pic 46 **/

#define BLANK 0x20
#define BLANK_PORT PORTD       /** pin 10, PMWR/OC5/IC5/CN13/RD4, pic 52 **/

#define XLAT 0x8
#define XLAT_PORT PORTD        /** pin 9, OC4/RD3, pic 51 **/

This is part of the TLC5940 library which holds the pins. How could I address the SPI1 pins? And are there any modifications needed to use the library with SPI1? That means changing the pins 10, 11, 13 to 14, 1, 38