Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Any SPI code examples??
30-03-2015, 06:58 PM,
#1
Any SPI code examples??
Hello All,

I am working to get a RFID reader MFRC522 to talk with the PIC MICRO32.
Can't seem to find many examples of SPI pinquino code that is not for SD cards.
Also how to know where code is sending SPI to UEXT or SD card?
I would be happy for any help.

Best Regards
59Tech
Reply
30-03-2015, 07:43 PM, (This post was last modified: 30-03-2015, 07:51 PM by moreno.)
#2
RE: Any SPI code examples??
Hi

The UEXT and SD have the same SPI BUS, only change the CS signal.

I developed library for MCP23S17 IO device which use SPI BUS.
You can found a sample MCP23S17-SPI_IO_Expander.pde in \examples\04.Communication\SPI\ folder.

SPI is a very easy to use bus, it have only 2/3 commands, is more difficult develop library to interface this bus with devices but this is a different story.

[postedit]
There are a lot of material about MFRC522 especially for Arduino.
A good starting point is https://github.com/miguelbalboa/rfid
Is no so complex translate C++ code in C code
[/postedit]

Bye Bye, Moreno
Reply
30-03-2015, 07:48 PM,
#3
RE: Any SPI code examples??
Hello,
Did you look at : Examples\04.Communication\SPI\BarometricPressureSensor.pde ?
Here are the available statements for PIC32 :
SPI.init SPI_init#include <spi.c>

SPI.begin SPI_begin#include <spi.c>
SPI.close SPI_close#include <spi.c>
SPI.setMode SPI_setMode#include <spi.c>
SPI.setBitOrder SPI_setBitOrder#include <spi.c>#define SPISETBITORDER
SPI.setDataMode SPI_setDataMode#include <spi.c>
SPI.setClock SPI_setClock#include <spi.c>
SPI.setClockDivider SPI_setClockDivider#include <spi.c>
SPI.write SPI_write#include <spi.c>
SPI.transfer SPI_write#include <spi.c>
SPI.read SPI_read#include <spi.c>

In pinguino-11\p32\include\pinguino\core\spi.c you find the different functions in C Language.

The 4 Spi pins are located in the UEXT.

I successfully experimented the 8bit spi library which is very close to the 32bit one. The spi module  was an enc28j60 for ethernet communication.

Bye
André
Reply
31-03-2015, 02:55 AM,
#4
RE: Any SPI code examples??
(30-03-2015, 07:48 PM)gtcbreizh Wrote: I took the BarometricPressureSensor.pde and added #define SPIx 3
but get lots of errors pointing to SPI_close() in spi.c

C:\pinguino-11\p32\include\pinguino\core/spi.c: In function 'SPI_close':

C:\pinguino-11\p32\include\pinguino\core/spi.c:339:16: error: 'INTFAULT' undeclared (first use in this function)
IntDisable(INTFAULT);
^
C:\pinguino-11\p32\include\pinguino\core/spi.c:339:16: note: each undeclared identifier is reported only once for each function it appears in
C:\pinguino-11\p32\include\pinguino\core/spi.c:340:16: error: 'INTTXDONE' undeclared (first use in this function)
IntDisable(INTTXDONE);
^
C:\pinguino-11\p32\include\pinguino\core/spi.c:341:16: error: 'INTRXDONE' undeclared (first use in this function)
IntDisable(INTRXDONE);

any ideas?? 

Hello,
Did you look at : Examples\04.Communication\SPI\BarometricPressureSensor.pde ?
Here are the available statements for PIC32 :
SPI.init SPI_init#include <spi.c>

SPI.begin SPI_begin#include <spi.c>
SPI.close SPI_close#include <spi.c>
SPI.setMode SPI_setMode#include <spi.c>
SPI.setBitOrder SPI_setBitOrder#include <spi.c>#define SPISETBITORDER
SPI.setDataMode SPI_setDataMode#include <spi.c>
SPI.setClock SPI_setClock#include <spi.c>
SPI.setClockDivider SPI_setClockDivider#include <spi.c>
SPI.write SPI_write#include <spi.c>
SPI.transfer SPI_write#include <spi.c>
SPI.read SPI_read#include <spi.c>

In pinguino-11\p32\include\pinguino\core\spi.c you find the different functions in C Language.

The 4 Spi pins are located in the UEXT.

I successfully experimented the 8bit spi library which is very close to the 32bit one. The spi module  was an enc28j60 for ethernet communication.

Bye
André
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)