Sonsivri
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
April 20, 2024, 01:50:55 01:50


Login with username, password and session length


Pages: [1]
Print
Author Topic: can i use both I2c and SPI on 16f877  (Read 4200 times)
0 Members and 1 Guest are viewing this topic.
schlen
Newbie
*
Offline Offline

Posts: 11

Thank You
-Given: 2
-Receive: 0


« 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)
Logged
pickit2
Moderator
Hero Member
*****
Offline Offline

Posts: 4647

Thank You
-Given: 826
-Receive: 4207


There is no evidence that I muted SoNsIvRi


« Reply #1 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.
Logged

Note: I stoped Muteing bad members OK I now put thier account in sleep mode
frasenci
Translator
Active Member
***
Offline Offline

Posts: 171

Thank You
-Given: 142
-Receive: 84


« Reply #2 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
Logged
8K51
Junior Member
**
Offline Offline

Posts: 80

Thank You
-Given: 86
-Receive: 40


« Reply #3 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
Logged
schlen
Newbie
*
Offline Offline

Posts: 11

Thank You
-Given: 2
-Receive: 0


« Reply #4 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.
Logged
Pages: [1]
Print
Jump to:  


DISCLAIMER
WE DONT HOST ANY ILLEGAL FILES ON THE SERVER
USE CONTACT US TO REPORT ILLEGAL FILES
ADMINISTRATORS CANNOT BE HELD RESPONSIBLE FOR USERS POSTS AND LINKS

... Copyright © 2003-2999 Sonsivri.to ...
Powered by SMF 1.1.18 | SMF © 2006-2009, Simple Machines LLC | HarzeM Dilber MC