View previous topic :: View next topic |
Author |
Message |
Guest
|
using both I2c and SPI |
Posted: Mon Nov 14, 2005 6:44 am |
|
|
hi,
I need to use the pic16c74 with i2c for memory 24cX and SPI for interfacing CAN controller.
The pin's for i2c and SPI are the same so a multiplex of some kind needs to be done.
What is recommened in Hardware and software to implimant it ? |
|
|
MikeValencia
Joined: 04 Aug 2004 Posts: 238 Location: Chicago
|
|
Posted: Mon Nov 14, 2005 8:31 am |
|
|
There is no easy way to multiplex i2c and spi communication if you plan to switch off between the two in the hardware module.
If this is okay with you, the easiest way would be to do SPI in hardware mode with the MSSP module, and to do software i2c with two other pins. |
|
|
Guest
|
|
Posted: Mon Nov 14, 2005 1:15 pm |
|
|
It is possible to do it.
why to do spi in Hw and i2c in software ?
what is more demanding in terms of code and speed ?
does the compiler nows to impliant the software i2c when other pins are used ? |
|
|
kender
Joined: 09 Aug 2004 Posts: 768 Location: Silicon Valley
|
|
Posted: Mon Nov 14, 2005 1:52 pm |
|
|
Anonymous wrote: | why to do spi in Hw and i2c in software ?
what is more demanding in terms of code and speed ? |
SPI is usually faster then I2C, and the SPI devices tend to generate more data (e.g. higher sample rates for D/A and A/D). There is a twist, though. If your PIC is an I2C or SPI slave, you pretty much have to have hardware I2C or SPI. |
|
|
Guest
|
|
Posted: Tue Nov 15, 2005 1:00 pm |
|
|
well,
The i2c is in master mode.
The microchip CAN controller is a slave so The SPI should be master too.
What is the Hw best configuration ??
Is there a simper way to do it ???
thanks, |
|
|
kender
Joined: 09 Aug 2004 Posts: 768 Location: Silicon Valley
|
|
Posted: Tue Nov 15, 2005 4:44 pm |
|
|
As you are describing it, the simplest way is to have the h/w SPI and s/w I2C. However, the utterly simple way is to use a PIC with a biult-in CAN controller (such as 18F258, 18F248 etc). |
|
|
asmallri
Joined: 12 Aug 2004 Posts: 1634 Location: Perth, Australia
|
|
Posted: Tue Nov 15, 2005 6:55 pm |
|
|
Anonymous wrote: | well,
The i2c is in master mode.
The microchip CAN controller is a slave so The SPI should be master too.
What is the Hw best configuration ??
Is there a simper way to do it ???, |
Replace the I2C 24cxx with a SPI version 25cxx. _________________ Regards, Andrew
http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!! |
|
|
|