View previous topic :: View next topic |
Author |
Message |
Tanaka Guest
|
Using I2C and SPI together |
Posted: Wed Mar 17, 2004 5:56 pm |
|
|
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
|
|
Posted: Wed Mar 17, 2004 6:10 pm |
|
|
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
|
|
Posted: Tue Mar 23, 2004 12:27 am |
|
|
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. |
|
|
|