CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Is it possible to run spi and i2c protocol with one uC?

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
The Puma



Joined: 23 Apr 2004
Posts: 227
Location: The Netherlands

View user's profile Send private message

Is it possible to run spi and i2c protocol with one uC?
PostPosted: Sun Jun 24, 2007 3:25 am     Reply with quote

I will drive with a pfc8583 (i2c interface) a dot matrix display
This matrix display has 10 Max7221 on it (spi interface)
(Will display the time on the dot matrix display)

The uC is an PIC18F4620

My question is now:
Is it possible to control the i2c and spi interface the same time
... and how do that?
Humberto



Joined: 08 Sep 2003
Posts: 1215
Location: Buenos Aires, La Reina del Plata

View user's profile Send private message

PostPosted: Sun Jun 24, 2007 10:45 am     Reply with quote

It is not possible to do it simultaneously. The main reason is that the built in
hardware module that control both operating modes (SPI & I2C) is the same.
This module, the MSSP (Master Synchronous Serial Port) can be configured
to operate in:

1) SPI Mode: Using this four registers:
SSPCON1 SSPSTAT SSPBUF SSPSR

2) I2C Mode: Using this six registers:
SSPCON1 SSPSTAT SSPBUF SSPSR SSPCON2 SSPADD

Looking at the dedicated pins for both operations, you will see that pins RC3
and RC4 share its functionalities in SPI or I2C modes. From the I2C and SPI
hardware levels point of view, there are no risk for any hardware damage,
but you will realize that the system behaviour would be unpredictable running
at the same "time shared" time.


Humberto
The Puma



Joined: 23 Apr 2004
Posts: 227
Location: The Netherlands

View user's profile Send private message

PostPosted: Sun Jun 24, 2007 10:59 am     Reply with quote

Then the only possible is that i then must use a Spi interface clock chip
Is that correct?

The pcf8583 is on a PIC development board.
The i2c pins are hardwired to the pic, thus i can not use diferent lines for soft i2c mode Sad
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Jun 24, 2007 12:40 pm     Reply with quote

Use software SPI for the Max7221 chips.
The Max7221 needs three signals: DIN, \CS, and CLK.
Use three free i/o pins for this, such as pins B0, B1, B2.
The PCF8583 can stay on pins C3 and C4.
The Puma



Joined: 23 Apr 2004
Posts: 227
Location: The Netherlands

View user's profile Send private message

PostPosted: Sun Jun 24, 2007 1:53 pm     Reply with quote

How to do software spi?
Are there standard libs for?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Jun 24, 2007 2:12 pm     Reply with quote

There are many examples in the CCS example and driver files.

According to the latest manual, version 4 of the compiler has a
#use spi() library which can create software (or hardware) SPI code.
I haven't tested this library.

Look in these directories:
c:\Program Files\Picc\Examples
c:\Program Files\Picc\Drivers


The write_isd() function in the isd4003.c driver will write 16 bits
using software SPI, in SPI mode 0.
c:\program files\picc\drivers\isd4003.c
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group