Sonsivri

Electronics => Hardware and Tools => Topic started by: pajaro on July 13, 2008, 06:03:15 18:03



Title: PIC16F877A protocol I2C & SPI
Post by: pajaro on July 13, 2008, 06:03:15 18:03
hello,

Somebody knows if, it is possible that we can use the protocol i2c and spi at the same time with oneself pic(PIC16F877A).

Devices to use with these two protocols

write/read a card SD or MMC --> Protocol SPI
ds1307, ISD51xx , ...           --> Protocol I2C


see you


Title: Re: PIC16F877A protocol I2C & SPI
Post by: mbandala on July 13, 2008, 06:14:40 18:14
Sure it is possible! Just make sure that you close one module before opening the other. For instant use CloseSPI(); then configure the i2c module, then use OpenI2C(); and do the i2c communication. When you are done with the i2c module use CloseI2C(); then configure the SPI module, then use OpenSPI(); and do the SPI communication. When you are done use CloseSPI(); and loop the sequence from the beginning.


Title: Re: PIC16F877A protocol I2C & SPI
Post by: pajaro on July 13, 2008, 07:43:45 19:43
hello

if I have a pic16F877A with a LCD 2x20, a ds1307 clock of real time which shows me the hour in it lines her first, but in it lines her 2 it shows me the frequency of a to receive FM from the radio,
this will produce retards with the lcd and the pic or with some of the devices?

see you


Title: Re: PIC16F877A protocol I2C & SPI
Post by: mbandala on July 14, 2008, 02:54:14 14:54
I don't really know what your application is. However if you are using an LCD with the DS1307 and some other device then you can use the timings to your advantage. The LCD needs delays to allow the device to display characters correctly. So instead of wasting time between character writings you can do the communications with the external devices.

However, most LCDs require something like 1ms or more to allow for the next character to be written. 1 ms is way more that the times handled by i2c and spi devices because you can read/write to such devices in matter of few microseconds. In your application, you can read sec/min/hrs/day/date/month/year/&RAM in less time than you need to refresh the LCD (which presumably should be about once a second). So I don’t think you will have timing issues.


Title: Re: PIC16F877A protocol I2C & SPI
Post by: gem1144aaa on November 17, 2008, 07:43:48 19:43
Sure it is possible! Just make sure that you close one module before opening the other. For instant use CloseSPI(); then configure the i2c module, then use OpenI2C(); and do the i2c communication. When you are done with the i2c module use CloseI2C(); then configure the SPI module, then use OpenSPI(); and do the SPI communication. When you are done use CloseSPI(); and loop the sequence from the beginning.

Hi mbandala


how can i close i2c or spi in Mikrobasic or mikroc?


Title: Re: PIC16F877A protocol I2C & SPI
Post by: Biggles on November 18, 2008, 05:30:55 17:30
Somebody knows if, it is possible that we can use the protocol i2c and spi at the same time with oneself pic(PIC16F877A).

Yes. Both can appear to work together. SPI can be very fast! For SPI I recommend you do it in software, a little slower than hardware, but it will work first time!


Title: Re: PIC16F877A protocol I2C & SPI
Post by: gem1144aaa on November 19, 2008, 10:47:40 10:47
hi

in mikrobasic they support both h/w i2c & softi2c

as they support h/w spi & softspi

but if you attend to use the spi with mmc/sd cards the softspi will not work for you & you should youse the h/w spi

so i i connected the ds1307 to the softi2c and the mmc to the h/w spi and it works fine


but my question is can i tie them both to the h/w i2c and h/w spi both at the same time?


Title: Re: PIC16F877A protocol I2C & SPI
Post by: caveman508 on January 10, 2009, 06:35:53 06:35
hello,

Somebody knows if, it is possible that we can use the protocol i2c and spi at the same time with oneself pic(PIC16F877A).

Devices to use with these two protocols

write/read a card SD or MMC --> Protocol SPI
ds1307, ISD51xx , ...           --> Protocol I2C


see you

This is a job for multi-tasking.  Set up two tasks that when busy, give up and allow the other task to execute.

Caveman