Title: can i use both I2c and SPI on 16f877 Post by: schlen on January 01, 2008, 10:14:01 22:14 Hello friends,
i have a question about 16f877. i need 2 serial interface to communicate. Can i use spi pins( port c 18,23,24) to communicate with a IC and can i use I2C pins(port c 25,26 ) to communicate with pc? i give 12 bit data from IC to pic and send 8 bit data from pic to IC. i send 8 bit data from pc to pic and give 12 bit data from pic to pc. i input select for pc or manual. sel_0, sel_1 and sel_2 to select channel on adc (max186) Title: Re: can i use both I2c and SPI on 16f877 Post by: pickit2 on January 02, 2008, 12:28:41 00:28 Just a point on your Project if your using Proton. and want a quick easy setup.
You have swaped the LCD to portD from portB & the following LCD connections EN and RS over from standard layout. The default connections for a LCD IN 4 BIT MODE are as follows. LCD ------ PicPort DB7 - - - - RB7 DB6 - - - - RB6 DB5 - - - - RB5 DB4 - - - - RB4 EN - - - - RB2 RS - - - - RB3 R/W - - - Vss or Gnd. Title: Re: can i use both I2c and SPI on 16f877 Post by: frasenci on January 02, 2008, 03:40:13 03:40 Hi schlen , I would say yes , you can.
Unless you are invoking Hardware resources from the PIC itself.These ones use the pins in the way described on datasheet. If you are using a compiler like Proton , you can do I2C in/out on whatever pin of the PIC , provided you identify SCL and SCLK in the code. I have done so , for example accesing an 24lc512 eeprom with I2c from pins a0,a1 on a 18f252. Serout and Serin are another example of this. Yo can identify the pins that are used to Tx / Rx at the command line. I see you are using Proteus SIM , give it a try with different combinations. Greetings Title: Re: can i use both I2c and SPI on 16f877 Post by: 8K51 on January 02, 2008, 09:35:21 09:35 Hi
Pin 25 and 26 are not I2C pins !! I2C uses pin 23 for data and pin 18 for clock. Those two pins are shared between SPI and I2C modes of MSSP module. USART module uses is own pins : 25 and 26 So I dont see any conflict in your schematic and no reason to use software uart elsewere. Maybe the CK and DT names of pins 25 and 26 troubles you ? Dont worry (bee happy !!) theses names are for the synchonous mode of USART According to your schematic you use this module in asynchronous mode. So MSSP in 'master spi mode' and UART in 'synchonous mode' work perfectly together. Regards Title: Re: can i use both I2c and SPI on 16f877 Post by: schlen on January 02, 2008, 03:45:31 15:45 thank u for all ur interests.
i have a problem with reading data from adc. because of 12 bit data. must i define a new protocol to communicate by 12 bit. |