PDA

View Full Version : Interfacing two PIC micros



sajid
- 24th May 2007, 12:16
Hi all,

I ve already interfaced 16F870 to RTC chip DS1307. After a few problems, its running fine now.

Now, I am trying to interface to independently running PIC micros, both 16F870. But facing a few difficulties, like :

i) what should be the read/write address for the slave PIC

ii) How can we define variables in a particular memory location (in slave PIC), using Picbasic because DIM statement creates variables, but memory location is not known to the user.

iii) How to define SDA and SCL pins on the slave PIC.

I think, I need all the information for interfacing two PICs, using Picbasic.

Kindly help me and oblige.

Thanking you all in anticipation.
Regards,
Sajid

skimask
- 24th May 2007, 13:27
ii) How can we define variables in a particular memory location (in slave PIC), using Picbasic because DIM statement creates variables, but memory location is not known to the user.


Good luck DIM'ing anything in PicBasicPro.
Check Proton Basic forums instead.

Ron Marcus
- 24th May 2007, 14:12
Good luck DIM'ing anything in PicBasicPro.
Check Proton Basic forums instead.

I DIMmed a light using the X10 commands once!

skimask
- 24th May 2007, 14:15
Good luck DIM'ing anything in PicBasicPro.
Check Proton Basic forums instead.

I DIMmed a light using the X10 commands once!

:D Good one...
Come to think of it, I've DIMmed a whole load of LEDs using PBP too...

mister_e
- 24th May 2007, 14:26
Ah come on guys! This is his first post here and he need help... you can't help him, then just shut the ******

Sajid, are you using Melabs PICBasic, Melabs PicBasic PRO or Crownhill Proton (PDS) ?

If you're using Crownhill Proton (PDS) you'll need to go on their forum.
www.picbasic.org/forum

yeah.. both are known as PicBasic...

mackrackit
- 24th May 2007, 15:37
This might be of use.

Is there a way to do what sajid ask in PBP?

mister_e
- 24th May 2007, 20:51
Yes, everything is possible. I don't know if i would use the MSSP port and share everybody on the same bus, or use a serial communication so far.

mackrackit
- 24th May 2007, 21:35
Yes, everything is possible. I don't know if i would use the MSSP port and share everybody on the same bus, or use a serial communication so far.

I have never thought about MSSP. Looks like something fun to try some day.

Thank you

mister_e
- 24th May 2007, 21:38
Fun, fast and handy, that's for sure.

sajid
- 25th May 2007, 06:58
Thanks guys, for atleast replying to my query.

Sorry, for that DIM thing....its my first post, remember that. (Thanks, mister_e )

Im using Crownhill Proton, I wud ask them, about DIMming anything....

OK......lets forget that. Now I want to do it in PBP. Can anybody help me in my queries, for interfacing two PICs, like,

i) what should be the read/write address for the slave PIC

ii) How can we define variables in a particular memory location (in slave PIC), using PBP

iii) How to define SDA and SCL pins on the slave PIC.

Thanks all for the response (good or bad), I appreciate that. Now, experts, please help me with this.

Regards,
Sajid

skimask
- 25th May 2007, 07:19
i) what should be the read/write address for the slave PIC
It's whatever you program the slave PIC to respond to.


ii) How can we define variables in a particular memory location (in slave PIC), using PBP
PBP manual, Section 9.3, 'Interrupts in Assembler' has some good hints on how to set a specific variable to a specific location...but I wouldn't count on it. Easier (in my mind) to let PBP assign a location for you, then you program around it.


iii) How to define SDA and SCL pins on the slave PIC.
You realize PBP only supports I2C master modes, not slave modes. The PIC itself, if so equipped, can use I2C in a slave mode, but you have to program that manually, PBP won't help much in that respect. There is a few web pages out there with good PIC I2C slave code, don't remember where they are, don't have them bookmarked, but I've seen them.


Now, experts, please help me with this.
I know that's not some sort of DEMAND...like somebody owe's you something. You'd be much more likely to get some help if YOU wrote some code YOURSELF and pointed out where YOU are having trouble.

EDIT: Got this from a Google search for 'PIC I2C slave'
http://www.astrosurf.com/soubie/pic_as_an_i2c_slave.htm
1st link. Was that so hard?

mister_e
- 25th May 2007, 13:21
Directly from Melabs Website: http://www.melabs.com/resources/samples.htm

I2Cslave.bas: http://www.melabs.com/resources/samples/pbp/i2cslave.bas

I2cmast.bas: http://www.melabs.com/resources/samples/pbp/i2cmast.bas

HTH

sajid
- 26th May 2007, 06:58
Thanks, Skimask.
Thanks, Steve.

Skimask Sir, I am sorry about that 'expert' line. Since everyone took my query lightly, so I was bit frustrated. I sincerley apologize.

The links and tips provided by you and Steve, are really helpful.

I will certainly keep informing you all, as I work on it.

Thanks to you all, again. :)

Regards,
Sajid