View previous topic :: View next topic |
Author |
Message |
beechler
Joined: 13 Feb 2004 Posts: 2
|
simple communication using PIC16F84A |
Posted: Fri Feb 13, 2004 12:34 pm |
|
|
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 )
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 ,
beechler |
|
|
Neutone
Joined: 08 Sep 2003 Posts: 839 Location: Houston
|
|
Posted: Fri Feb 13, 2004 12:57 pm |
|
|
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
|
|
Posted: Fri Feb 13, 2004 12:57 pm |
|
|
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
|
SPI supported? |
Posted: Fri Feb 13, 2004 2:43 pm |
|
|
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
|
|
Posted: Fri Feb 13, 2004 3:01 pm |
|
|
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
|
Re: SPI supported? |
Posted: Fri Feb 13, 2004 4:22 pm |
|
|
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 |
Posted: Fri Feb 13, 2004 5:20 pm |
|
|
Why not just stick a MAX232 on both PICs and use the RS232 serial I/O routines? Simple,cheap,easy to implement...
Jay |
|
|
|