SPI Master

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 4.
To post in this forum you must have a registered copy of Flowcode 4 or higher. To sign up for this forum topic please use the "Online Resources" link in the Flowcode Help Menu.

Moderator: Benj

Post Reply
Chris_Technik-Welt
Posts: 7
Joined: Thu Oct 07, 2010 11:35 am
Location: Austria
Contact:

SPI Master

Post by Chris_Technik-Welt »

Hello

In my actually project PIC18F87J11 with Flowcode V4.3.7.63 I need I2C and SPI.
SSP port 1 should be configured as an I2C port, one external EEPROM and RTC are connected to it.
SSP port 2 should be configured as a SPI port, one external Flash and SRAM and one FTDI V2dip1 are connected to it.
I have seen in /Components there is a SPI Master Component, but i cant used it in the system.

How can I configure this setup in Flowcode or what is with the SPI Master Component?

Thanks for answer
best regards
Chris

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: SPI Master

Post by Benj »

Hello Chris,

By default the I2c and SPI components both refer to the first MSSP peripheral.

You should be able to use the code customisation features to move the SPI component to the second peripheral.

Eg where you have the register name sspstat, sspcon and sspbuf simply change these to ssp2stat, ssp2con1 and ssp2buf.

Let me know how you get on.

Chris_Technik-Welt
Posts: 7
Joined: Thu Oct 07, 2010 11:35 am
Location: Austria
Contact:

Re: SPI Master

Post by Chris_Technik-Welt »

Hi Ben

Thanks for your Infos.
I have change follows in "PIC_SPI_Legacy.c"
All sspstat, sspcon sspcon1 and sspbuf to ssp2stat, ssp2con, ssp2con1 and ssp2buf.
Hope this is right.
OK, how I can now define my port D4 D5 D6 and as Enable H0,H1 or H2?
I am not shure where or with witch command you choose the port B or C.
I have seen this:
//initialise spi
#ifdef MX_SPI_B
......
#ifdef MX_SPI_C

Many thanks for your help!!!!

Chris

User avatar
petesmart
Valued Contributor
Valued Contributor
Posts: 395
Joined: Thu May 06, 2010 11:42 am
Location: Sydney, Australia
Has thanked: 187 times
Been thanked: 140 times
Contact:

Re: SPI Master simultaneous I2C and SPI

Post by petesmart »

Hey Ben,

I am working on a project with similar requirements using an ECIO (18F4455)... had a quick look thru the microchip datasheet and it was not obvious that that it had a second MSSP port peripheral capability. Is there any way to spoof this dual functionailty mode using another port other than port b for either SPI or I2C.

My use case is a magenetic compass / accelarometer using I2C and CAN bus to deliver data to a master node simultaneously....

may be I have to go to alternate silicon?

thanks

all the best

Pete
sorry about that Chief!

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: SPI Master

Post by Benj »

Hello Pete,

The Flowcode I2C component allows you to use it in hardware or software mode. The software mode does not require a MSSP peripheral so you can basically move the component anywhere you like on the chip.

SPI can also be bit banged quite easily but the SPI legacy component does not currently support this mode of operation.

Post Reply