Sending and receiving data through 2 SPI ports

General discussion on mikroPascal.
Post Reply
Author
Message
GVHecke
Posts: 77
Joined: 28 May 2005 09:42
Location: Belgium

Sending and receiving data through 2 SPI ports

#1 Post by GVHecke » 13 Dec 2006 15:07

Hello,

Is there an example available, or can anyone tell me how I need to configure and use 2 SPI ports of the PIC microcntroller? Each example I find is always for 1 SPI port.

piort
Posts: 1379
Joined: 28 Dec 2005 16:42
Location: Laval,Québec,Canada,Earth... :-)
Contact:

#2 Post by piort » 13 Dec 2006 15:12

hi

Code: Select all

spi1_init(param...)
spi2_init(param...)

happy coding  8) 

GVHecke
Posts: 77
Joined: 28 May 2005 09:42
Location: Belgium

#3 Post by GVHecke » 13 Dec 2006 15:25

Thanks,

I will try this. Seems very easy. I asked because documentation stated procedure Spi_Init();
and not spi1_init, spi2_ini

GVHecke
Posts: 77
Joined: 28 May 2005 09:42
Location: Belgium

#4 Post by GVHecke » 13 Dec 2006 15:30

SPI1_init() or SPI2_init() does not compile, it gives a compiler error:
Identifier SPI1_init() was not declared.

I have tested this in the SPI example that comes together with micropascal.

So this does not work, any idea how I can make it work?

jpc
Posts: 1986
Joined: 22 Apr 2005 17:40
Location: France 87

#5 Post by jpc » 13 Dec 2006 17:23

which PIC are you working with ? It has to have 2 SPI-ports so you must be working on BigPic devboard right?

piort
Posts: 1379
Joined: 28 Dec 2005 16:42
Location: Laval,Québec,Canada,Earth... :-)
Contact:

#6 Post by piort » 13 Dec 2006 19:46

hi,
Like JPC say.... which pic do you use ? at the begining i was thinking you want to use one of those pic with 2 spi ... like the 18f8722... this chip have 2 usart, 2 MSSP so one i2c and one spi OR 2 spi OR 2 i2c ...
The best place to chk if your pic have the hardware you want to use is in the thing call a datasheet :lol:

happy coding 8)

xor
Posts: 5465
Joined: 18 May 2005 00:59
Location: NYC
Contact:

#7 Post by xor » 13 Dec 2006 23:43

2 SPI's still seems strange to me. Is there an advantage over a single SPI port? I can understand having multiple I2C and a second MSSP module can help in that case. :?
[color=darkred][b]xor[/b][/color]
[url=http://circuit-ed.com]CircuitED -[/url]

piort
Posts: 1379
Joined: 28 Dec 2005 16:42
Location: Laval,Québec,Canada,Earth... :-)
Contact:

#8 Post by piort » 14 Dec 2006 00:39

hi ,

2 spi port = 16 MCP23S17 so 256 more I/O :shock:

or 16 of anything in SPI with 3 bit for addressing mode so imagine all the possibility...expander,dac,adc,temp sensor and so on :wink:


happy coding 8)

xor
Posts: 5465
Joined: 18 May 2005 00:59
Location: NYC
Contact:

#9 Post by xor » 14 Dec 2006 01:21

That is also accomplished by simply adding single CS lines, whereas a second SPI uses 3 or more pins.
[color=darkred][b]xor[/b][/color]
[url=http://circuit-ed.com]CircuitED -[/url]

piort
Posts: 1379
Joined: 28 Dec 2005 16:42
Location: Laval,Québec,Canada,Earth... :-)
Contact:

#10 Post by piort » 14 Dec 2006 05:25

hi xor,
that true :oops:

btw gratz on your 3000 post :wink:

FRM
Posts: 381
Joined: 20 May 2005 18:58
Location: UK

#11 Post by FRM » 14 Dec 2006 08:59

Hi,
The only reason I can think of to justify having more than one SPI port is when you have devices that have wildly different SPI configurations
that will not function with the same SPI_Init paramaters (or compromised with hardware), and you cannot afford lost time in re-initialising
the SPI port between device selects.

Even if you have two devices on two SPI ports, you can still only read one at a time, and lets face it - if you are concerned with real-time data-aquisition
of more than one input with no phase delays (and PIC18F/10MHz SPI data speed is not fast enough) then you'd be better off with multiple PIC's or dsPIC...

LGR
Posts: 3204
Joined: 23 Sep 2004 20:07

#12 Post by LGR » 14 Dec 2006 18:58

FRM wrote:if you are concerned with real-time data-aquisition
of more than one input with no phase delays (and PIC18F/10MHz SPI data speed is not fast enough) then you'd be better off with multiple PIC's or dsPIC...
Quite. Which is why I hope they fix the bug on multiple SPI ports with the new release for dsPIC. Last time I tried it, it used SPI 1 regardless of which SPI port was addressed.

Since pretty much all dsPICs and PIC24s have 2 SPI ports, it will become a matter of convenience to use them both. Particularly if you're using SD/MMC or SPI ethernet, you're going to want to dedicate a port to those.
If you know what you're doing, you're not learning anything.

fryrmnd
Posts: 1
Joined: 28 Apr 2011 13:32

Re: Sending and receiving data through 2 SPI ports

#13 Post by fryrmnd » 02 May 2011 06:57

hi. i have also had the problem SPI1_Init() was not declared... i look datasheet and i think that pic24xxx series have 2 SPI modüles... not Pic 18Fxxx... then i want to use pic18... what must be the solution... i will be happy if you can reply... sorry for my bad english...

jpc
Posts: 1986
Joined: 22 Apr 2005 17:40
Location: France 87

Re: Sending and receiving data through 2 SPI ports

#14 Post by jpc » 04 May 2011 08:23

a simple parametric search at http://www.microchip.com/ParamChartSear ... &pageId=74 will return 82 different p18 chips with 2 SPI modules.
Last post in this thread was allmost 5 years ago, a few things have changed since ...
Au royaume des aveugles, les borgnes sont rois.

Post Reply

Return to “mikroPascal General”