I need to interface SPI and I2c device to the same Microntroller, how do I go about doing this. There a 2 SPI digital pots and 3 I2c device like RTC,EEPROM,and PORT expander. I have done the I2c connection need to do the SPI connection.
I do not need simultaneous use of SPI and I2c. so how do I connect these devices.
I am using PIC16F887.
Yes I have used the SPI and I2C on same controller. using different pins. complete set of pin for one and a different set of pins for the other. and it works.
You can rewrite the library codes for the pins, cause the library works only with standard pins on the controller, and it does not work with other pins.
you will have to determine the CLK and generate it using a timer and have to set the data. go through the actual working of both and you'll understand.
Was going to suggest the same thing - use 5 separate pins (SPI MISO, SPI MOSI, SPI SCLK and I2C SDA, I2C SCL).
PICs tend to have one hardware peripheral that can be either SPI or I2C. Either of the buses can be implemented in software too (bit banged), however that has 2 limitations to keep in mind:
1. Software implementation has to be a master and can't be a slave.
2. Software implementation is slower than hardware peripheral.