Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

comm between 2 pics

Status
Not open for further replies.

TKS

New Member
Well offcourse it should be possible.

I have only one Line / Pin.
It Should be 2 way communication.
With out an clockline....
anyone ideas how to do the job??
One side is 4Mhz the other side is 20Mhz.
Speed isn't important.

Is it true that i just can hook up the pins to each other??

I'm debugging the 2 pics with both one debug pin connected to the comport of my pc...

but the problem i have is that how do i switch from sending to recieving on one pin.. because the other side will see this as one bit/byte not??

Tks
 
All you need is simple serial comms, simply connect the pins together and connect them to a pull-up resistor. Set both pins as inputs, the pull-up resistor will cause them both to read HIGH.

In order to send data make one PIC an output, and set the pin LOW, this is the start bit for the serial comms - carry on as normal sending the byte just like RS232, ending with a stop bit (setting the pin HIGH again, then TRIS'ing back to an input).

The receiving side simply waits until it gets a start bit, then does the normal serial receive routine.

To transmit the other way, simply reverse the process!.

There's no need for Manchester coding, it would provide no functionality whatsoever, and would slow things down.
 
mhh...

The true is nigel that i use

an compiler, would the hardware requirements change??

I now don't use the pullup, and it works sometimes, but not always..

also many times one of the devies keep reading the pin..(waiting for data,)

with as an result the other also start waiting because he just sended the data.

Will try the pull up.. (4K res to 5volt rails)

maybe i could do something witht he dallas 1 wire wich is also built in...

but serial is already ready..

when i dont use the wait for char command also the devices keep seeing bytes etc.. sow maybe the pins are then floating arround????



Tks
 
If you're using a high level compiler you're severely restricting your options - I'm presuming you're trying to use the in-built comms routines?. However, there's nothing to stop you writing your own routines in C (assuming it's a C compiler you're using?).
 
well

it works perfectly, its just this problem wich
every time comes up!

The crystal problem with the smartcard is now just like you said.
The mod i did was, i now use as clock source the same chip.
with a 4mhz external OSC.

Sow the impedance and every other param are more the same..

and the chips will be exactly doing the same.

TKs
 
Re: well

TKS said:
it works perfectly, its just this problem wich
every time comes up!

The crystal problem with the smartcard is now just like you said.
The mod i did was, i now use as clock source the same chip.
with a 4mhz external OSC.

Sow the impedance and every other param are more the same..

and the chips will be exactly doing the same.

TKs

So this is for communication between a PIC and a smartcard (which contains a PIC)?.

Why have you only got one pin available for the communication?, smartcards give at least three - MCLR, and the data and clock pins so that you can program it.
 
SmartCards

Have MCLR,Clock,Data pin..

(and VDD, VSS)

Clock you will need to startup the device in that matter that it works..and processes your programm.

MCLR you will need to put it high sow it starts processing to.(reset pin)..

And Data Pin is then the only one wich is free available for communication / verication purposes....

Because of the fact that it would be very insecure to not make it 2way comm. You will need to switch input / ouput many times.

The problem i had nigel was just the pullup resistor.
Big Fault/ Big consequences the problem was that it worked a few times...

But now its reliable.

Tks
 
You're missing a pin that has to be there!.

Assuming it's a PIC on the smartcard?.

To program the PIC it requires:

Vdd
Vss
MCLR
RB6 (programming clock)
RB7 (programming data)

For the smartcard to run a program it require:

Vdd
Vss
MCLR
Oscillator input (pin 16 on a 16x84)

This gives a total of six connections to the PIC on the card, two of which (RB6 and RB7) are general purpose I/O pins.

Are you perhaps confusing the programming clock input with the main oscillator input?.
 
ahhhh

sorry to mention!!!

but the RB6 is internally connected to the clock line.

So while programming you use the clock line for the RB6 pin..

while normally use you just use clock..

sow only RB7 is there for the outside world.

I was lucky that i had some PCB smartcards with the same pics sow i just made an serial debugpin on them..
etc..

Sow i could test with an unlimitted pic...and in real life i just use the wafer edition.
 

Attachments

  • waferpinoutiso7816pinout.gif
    waferpinoutiso7816pinout.gif
    11.4 KB · Views: 654
Clock Source!!

use same pic model for best performance..
 

Attachments

  • cardclock_699.gif
    cardclock_699.gif
    9.5 KB · Views: 664
Nigellll

I now have the situation

that i have 2 lines available and i wanted to do the same trick.

Sow i hooked u Rx with Tx and Tx with Rx this is correct i asume??

Is here also the need of the 4,7K pullups????

If sow wy not when using an MAX232???

Regards,

Tks
 
Re: Nigellll

TKS said:
I now have the situation

that i have 2 lines available and i wanted to do the same trick.

Sow i hooked u Rx with Tx and Tx with Rx this is correct i asume??

Yes.

Is here also the need of the 4,7K pullups????

If sow wy not when using an MAX232???

No, you don't need any pullups - because the inputs and outputs don't change over.
 
Nigel Goodwin said:
If you're using a high level compiler you're severely restricting your options - I'm presuming you're trying to use the in-built comms routines?. However, there's nothing to stop you writing your own routines in C (assuming it's a C compiler you're using?).

TKS, which compiler are you using? And does your PIC have a USART?

Most C programmers do not use built-in compiler routines and do not recommend them. They are not versatile or portable and it's simply more direct to write to the registers in a way similar to assembly. The difficulty is in time-critical bit-banged routines; that is, those not using hardware modules and not timed by timer interrupts. The problem is still resolvable.
 
I use a basic compiler

Don't want to waste my time in Assembler also didn't needed never for wat i maked with it.

Also i don't have the time to learn all the communication basics etc.
Its enough for me with the electronics wich of i learn every day more and more.

Both pics aren't using their UART and the card doesn't have one!

Sow its just timing, in my case i start the control sequence when the card is inserted...

It works perfectly!

Tks
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top