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 CCS Technical Support

Using I2C and SPI together

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







Using I2C and SPI together
PostPosted: Wed Mar 17, 2004 5:56 pm     Reply with quote

Hello,
I have a problem. I am trying to use a pic 18f452 in slave I2C mode as well as using it as a SPI master.
The SPI master works when I do not have the I2C enabled, but when I have the #use I2C in there, it hangs on the spi_write(command) command.
Does anyone know why?

Thanks,
Joseph
Guest








PostPosted: Wed Mar 17, 2004 6:10 pm     Reply with quote

Slave i2c needs the MSSP module hardware, so does SPI.
Can't use both at the same time.
HTH
Haplo



Joined: 06 Sep 2003
Posts: 659
Location: Sydney, Australia

View user's profile Send private message

PostPosted: Tue Mar 23, 2004 12:27 am     Reply with quote

Actually there is a way to do this:
Ditch the CCS #use statements altogether and set the SSPCON1 register manually. Bits 0-3 indicate if the MSSP is setup for SPI or I2C, so in your code you can juggle between these two modes. But remember you won't be able to use the CCS functions such as i2c_write() or spi_write() anymore, you'd have to handle the registers directly (SSPCON1, SSPCON2, SSPBUF and SSPADD). Refer to the device manual for more information.
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