CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

simple communication using PIC16F84A

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
beechler



Joined: 13 Feb 2004
Posts: 2

View user's profile Send private message

simple communication using PIC16F84A
PostPosted: Fri Feb 13, 2004 12:34 pm     Reply with quote

Hello all,

I am a first time PIC programmer but long time coder trying to use the PIC16F84A chip to achieve a simple transmission goal.

In essence I am trying to allow for simple communication using two chips in a master/slave design. After much research concerning C coding for the chip and supported functions, it obviously seems that the i2c conventions would be the best way to go concerning any real implementations. I have analyzed a lot of sample code (including some samples from this very forum) and am wondering if anyone has any good sources of general information regarding said topic (especially when it comes to actually wiring this up, as I mentioned I am a long time coder - but admitedly first time circuit designer Embarassed )

My very first goal is to try and transmit from one chip to another a simple 8 bit binary number which, when received by the second (slave) chip will cause the second chip to display the number as a lit LED sequence (proof positive my actual desired number was sent).

Simple, I know, but I am hoping that with success on this first project I can take what I learn to more exciting arenas.

thanx in advance for any information you can offer this newbie Laughing ,
beechler
Neutone



Joined: 08 Sep 2003
Posts: 839
Location: Houston

View user's profile Send private message

PostPosted: Fri Feb 13, 2004 12:57 pm     Reply with quote

I2C is not the best method for only 2 devices. SPI is better for comunicating between only a few chips. I2C only starts to shine when there are several devices on a bus. SPI is easier to operate with as well as faster. The I2C and SPI protocols are both supported in hardware.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Feb 13, 2004 12:57 pm     Reply with quote

Your question is, how to connect an i2c Master to an i2c Slave ?

You need 3 wires.
Between the Master and Slave chips, connect:

1. SCL pin on Master, to SCL pin on Slave.
2. SDA pin on Master, to SDA pin on Slave.
3. a common ground between the two PICs.

You will also need one pullup resistor on
SDA, and one on SCL. A value of 4.7K
should work fine. The pullups should connect
to the same Vdd voltage that your PICs use.
(I assume +5v).
beechler



Joined: 13 Feb 2004
Posts: 2

View user's profile Send private message

SPI supported?
PostPosted: Fri Feb 13, 2004 2:43 pm     Reply with quote

The SPI tip was an interesting and after some research I decided to jump in and attempt a simple app which could illustrate its use...but my MPLAB IDE refuses to acknowledge the presence of the SPI commands (for instane the SPI setup command)

Are you sure that the PIC 16F84A supports the SPI functionality in its hardware?

thanx again,
beechler
MGP



Joined: 11 Sep 2003
Posts: 57

View user's profile Send private message

PostPosted: Fri Feb 13, 2004 3:01 pm     Reply with quote

The 16F84A does not support hardware SPI, but you could always "bit-bang" it with software.
Neutone



Joined: 08 Sep 2003
Posts: 839
Location: Houston

View user's profile Send private message

Re: SPI supported?
PostPosted: Fri Feb 13, 2004 4:22 pm     Reply with quote

beechler wrote:
The SPI tip was an interesting and after some research I decided to jump in and attempt a simple app which could illustrate its use...but my MPLAB IDE refuses to acknowledge the presence of the SPI commands (for instane the SPI setup command)

Are you sure that the PIC 16F84A supports the SPI functionality in its hardware?

thanx again,
beechler


My mistake there reguarding their use in hardware. That chip does not support either I2C or SPI in hardware. It does not have the hardware module.


I still think that the SPI protocol is perferable. Using Slave Select to sync data transfer has worked better for me. It's also easier to do in software. A full SPI implimentation requires 4 wires.
1 Slave Select
2 Master Out Slave In
3 Slave Out Master In
4 Clock
I2C only needs 2 wires but is more complex to program. The Dallas 1 wire standard is even more compex to program.
jay miller
Guest







communications
PostPosted: Fri Feb 13, 2004 5:20 pm     Reply with quote

Why not just stick a MAX232 on both PICs and use the RS232 serial I/O routines? Simple,cheap,easy to implement...

Jay
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group