Maker Pro
Maker Pro

Linking 2 microcontrollers

M

Maurine O.

Jan 1, 1970
0
Hi there, iam new to microcontrollers and need to link 2
microcontrollers (Philips 89C668, 80C51: 8 Bit family) such that when
a Switch on a breadboard (connected to the first microcontroller) is
pressed, a corresponding LED (On a breadboard connected to the second
microcontroller)Lights accordingly. i currenly have three sets of
switches (On breadboard 1) and three LEDs (On breadboard 2).....a code
to achieve the above task would be appreciated.....Thanks.
 
P

peterken

Jan 1, 1970
0
Maurine O. said:
Hi there, iam new to microcontrollers and need to link 2
microcontrollers (Philips 89C668, 80C51: 8 Bit family) such that when
a Switch on a breadboard (connected to the first microcontroller) is
pressed, a corresponding LED (On a breadboard connected to the second
microcontroller)Lights accordingly. i currenly have three sets of
switches (On breadboard 1) and three LEDs (On breadboard 2).....a code
to achieve the above task would be appreciated.....Thanks.

Using dual-port ram might be a good idea, using part of it as "mailbox"
between both so data might be exchanged.
In this mailbox a flag might be set/cleared whereby the master informs the
slave it can take over.
If using tri-state tranceivers then you might even connect busses, however
take care one of them releases the common bus before the other takes over
 
C

CBarn24050

Jan 1, 1970
0
Subject: Linking 2 microcontrollers
From: [email protected] (Maurine O.)
Date: 01/12/2004 14:27 GMT Standard Time
Message-id: <[email protected]>

Hi there, iam new to microcontrollers and need to link 2
microcontrollers (Philips 89C668, 80C51: 8 Bit family) such that when
a Switch on a breadboard (connected to the first microcontroller) is
pressed, a corresponding LED (On a breadboard connected to the second
microcontroller)Lights accordingly. i currenly have three sets of
switches (On breadboard 1) and three LEDs (On breadboard 2).....a code
to achieve the above task would be appreciated.....Thanks.

I not familiar with this part, I assume it has a uart. connect the tx of 1 to
the rx of the other. Its trvial code to make it work after that.
 
W

Wong

Jan 1, 1970
0
Hi there, iam new to microcontrollers and need to link 2
microcontrollers (Philips 89C668, 80C51: 8 Bit family) such that when
a Switch on a breadboard (connected to the first microcontroller) is
pressed, a corresponding LED (On a breadboard connected to the second
microcontroller)Lights accordingly. i currenly have three sets of
switches (On breadboard 1) and three LEDs (On breadboard 2).....a code
to achieve the above task would be appreciated.....Thanks.

I think that a trigger/interrupt may works as well.
 
R

Rich Grise

Jan 1, 1970
0
Hi there, iam new to microcontrollers and need to link 2 microcontrollers
(Philips 89C668, 80C51: 8 Bit family) such that when a Switch on a
breadboard (connected to the first microcontroller) is pressed, a
corresponding LED (On a breadboard connected to the second
microcontroller)Lights accordingly. i currenly have three sets of switches
(On breadboard 1) and three LEDs (On breadboard 2).....a code to achieve
the above task would be appreciated.....Thanks.

Just use port pins and work out some kind of communications protocol.

Hell, use twelve pins - you've got 32 to work with.
At least according to the diagram at
http://www.semiconductors.philips.com/acrobat_download/datasheets/P89C660_662_664_668_4.pdf
page 5 has a pretty good block diagram.

Use port 1, uC # A to output the button pattern.
Use port 2, uC # A to tell uC #B that data is ready.
On uC B, be sitting polling port 2. When it says port 1 data is ready,
read it in from port one.
Use port 3, uC #B to tell uC #A that data has been accepted.
After uC #A has sent it's "Ready" signal on port 2, it waits and polls
port 3 until uC #B says, "Got it!"

With a little imagination, you could dramatically reduce the pin count,
but the purpose of the design is just to find out where the teacher needs
to start with the basics, right?

Hope This Helps!
Rich
 
Rich said:
Just use port pins and work out some kind of communications protocol.

Hell, use twelve pins - you've got 32 to work with.
At least according to the diagram at
http://www.semiconductors.philips.com/acrobat_download/datasheets/P89C660_662_664_668_4.pdf
page 5 has a pretty good block diagram.

Use port 1, uC # A to output the button pattern.
Use port 2, uC # A to tell uC #B that data is ready.
On uC B, be sitting polling port 2. When it says port 1 data is ready,
read it in from port one.
Use port 3, uC #B to tell uC #A that data has been accepted.
After uC #A has sent it's "Ready" signal on port 2, it waits and polls
port 3 until uC #B says, "Got it!"

With a little imagination, you could dramatically reduce the pin count,
but the purpose of the design is just to find out where the teacher needs
to start with the basics, right?

Hope This Helps!
Rich




Well the problem is the communications protocol, at the moment i can
only read in a switch value After Moving some number to the Accumulator
something like "MOV A, 07H", and masking any unused Bits. but from
there i get stucked...a code to read in all three switches and enable
them light their corresponding LEDs would be appreciated...Thanks
 
R

Rich Grise

Jan 1, 1970
0
microcontrollers

[nice treatise about interprocessor communications snipped]
Well the problem is the communications protocol, at the moment i can only
read in a switch value After Moving some number to the Accumulator
something like "MOV A, 07H", and masking any unused Bits. but from there i
get stucked...a code to read in all three switches and enable them light
their corresponding LEDs would be appreciated...Thanks

What you're talking about isn't a communications protocol at all, it's
low-level programming.

If you don't know how to move the data from a port to A, then I'm afraid
my help will be useless until you've at least completed lesson 1 of
microprocessor programming.

Good Luck!
Rich
 
J

John Fields

Jan 1, 1970
0
Well the problem is the communications protocol, at the moment i can
only read in a switch value After Moving some number to the Accumulator
something like "MOV A, 07H", and masking any unused Bits. but from
there i get stucked...a code to read in all three switches and enable
them light their corresponding LEDs would be appreciated...Thanks

---
The hardware, all switches SPSTNO:

Vcc>------+-----+-----+
| | |
[10K] [10K] [10K]
S3___ | | |
+---O O--+ | |
| S2___ | | |
+---O O--------+ |
| S1___ | | |
+---O O--------------+
| | | |
GND +--+-----+-----+--+
|PRTA2 PRTA1 PRTA0|
| | TX
|PRTA5 PRTA4 PRTA3| MC68XX
+--+-----+-----+--+
| | |
. . .
. . .
. . .
. . .
. . . Vcc
. . . |
| | | +------+------+
+--+-----+-----+--+ | | |
|PRTA2 PRTA1 PRTA0| [150] [150] [150]
| | RX |A |A |A
|PRTA5 PRTA4 PRTA3| MC68XX [LED1] [LED2] [LED3]
+--+-----+-----+--+ | | |
| | | C | |
| | +-------[2200]---B NPN | |
| | E C |
| +-------------[2200]----|-----B NPN |
| | E C
+-------------------[2200]----|------|-----B NPN
| | E
| | |
+------+------+
|
GND


One example of code in Motorola (Freescale) 6800 assembler for the
transmitter:


start: lda #$f8 ;1111 1000
sta ddra ;set up the port a ddr
lda #$07 ;0000 0111
sta prta ;set up port a

loopa: jsr t100ms ;100ms timer
brclr 0,prta on1 ;branch if S1 is made
bclr 3,prta ;else clear port a bit 3 (prta3)
brclr 1,prta on2 ;branch if S2 is made
bclr 4,prta ;else clear prta4
brclr 2,prta on3 ;branch if S3 is made
bclr 5,prta ;else clear prta5
bra loopa ;loop back for another try

on1: bset 3,prta ;set prta3
bra loopa ;loop back for another try

on2: bset 4,prta ;set prta4
bra loopa ;loop back for another try

on3: bset 5,prta ;set prta5
bra loopa ;loop back for another try

t100ms: code for timer ;generate 100 millisecond delay
rts ;return



And for the receiver:

start: lda #$f8 ;1111 1000
sta ddra ;set up the port a ddr
clr prta ;set up port a

loopa: brset 0,prta on1 ;branch if prta0 is set
bclr 3,prta ;else clear prta3 to turn off LED1
brset 1,prta on2 ;branch if prta1 is set
bclr 3,prta ;else clear prta4 to turn off LED2
brset 2,prta on3 ;branch if prta2 is set
bclr 3,prta ;else clear prta5 to turn off LED2
bra loopa ;loop back for another try

on1: bset 3,prta ;set prta3 to turn on LED1
bra loopa ;loop back for another try

on2: bset 4,prta ;set prta4 to turn on LED2
bra loopa ;loop back for another try

on3: bset 5,prta ;set prta5 to turn on LED3
bra loopa ;loop back for another try


This code will only allow one LED at a time to be lit, and that LED
will correspond to:


S3 S2 S1 LED3 LED2 LED1
 
J

John Fields

Jan 1, 1970
0
And for the receiver:

start: lda #$f8 ;1111 1000
sta ddra ;set up the port a ddr
clr prta ;set up port a

loopa: brset 0,prta on1 ;branch if prta0 is set
bclr 3,prta ;else clear prta3 to turn off LED1

brset 1,prta on2 ;branch if prta1 is set
Oops... bclr 3,prta ;else clear prta4 to turn off LED2
^
4
brset 2,prta on3 ;branch if prta2 is set
Oops... bclr 3,prta ;else clear prta5 to turn off LED2
^
5
 
M

Maurine O.

Jan 1, 1970
0
What you're talking about isn't a communications protocol at all, it's
low-level programming.

If you don't know how to move the data from a port to A, then I'm afraid
my help will be useless until you've at least completed lesson 1 of
microprocessor programming.

Good Luck!
Rich

Fair enough, any suggestions.? Like a "Complete Idiot's guide to
microprocessor programming". or something like that..suggestions.?

:)
 
P

peterken

Jan 1, 1970
0
http://www.semiconductors.philips.com/acrobat_download/datasheets/P89C660_662_664_668_4.pdf




Well the problem is the communications protocol, at the moment i can
only read in a switch value After Moving some number to the Accumulator
something like "MOV A, 07H", and masking any unused Bits. but from
there i get stucked...a code to read in all three switches and enable
them light their corresponding LEDs would be appreciated...Thanks

try a high level programming language (C, C++, pascal, even things like
basic....)
and the datasheet of the processor of course to know at what addresses the
ports are located
 
M

Maurine O.

Jan 1, 1970
0
---
The hardware, all switches SPSTNO:

Vcc>------+-----+-----+
| | |
[10K] [10K] [10K]
S3___ | | |
+---O O--+ | |
| S2___ | | |
+---O O--------+ |
| S1___ | | |
+---O O--------------+
| | | |
GND +--+-----+-----+--+
|PRTA2 PRTA1 PRTA0|
| | TX
|PRTA5 PRTA4 PRTA3| MC68XX
+--+-----+-----+--+
| | |
. . .
. . .
. . .
. . .
. . . Vcc
. . . |
| | | +------+------+
+--+-----+-----+--+ | | |
|PRTA2 PRTA1 PRTA0| [150] [150] [150]
| | RX |A |A |A
|PRTA5 PRTA4 PRTA3| MC68XX [LED1] [LED2] [LED3]
+--+-----+-----+--+ | | |
| | | C | |
| | +-------[2200]---B NPN | |
| | E C |
| +-------------[2200]----|-----B NPN |
| | E C
+-------------------[2200]----|------|-----B NPN
| | E
| | |
+------+------+
|
GND

Thanks John that was Brilliant!!, but do you have a proper schematic
(May be in Jpeg,gif or .doc), email it to the address above its still
active.....thanks alot that was really helpful.

M
 
J

John Fields

Jan 1, 1970
0
---
The hardware, all switches SPSTNO:

Vcc>------+-----+-----+
| | |
[10K] [10K] [10K]
S3___ | | |
+---O O--+ | |
| S2___ | | |
+---O O--------+ |
| S1___ | | |
+---O O--------------+
| | | |
GND +--+-----+-----+--+
|PRTA2 PRTA1 PRTA0|
| | TX
|PRTA5 PRTA4 PRTA3| MC68XX
+--+-----+-----+--+
| | |
. . .
. . .
. . .
. . .
. . . Vcc
. . . |
| | | +------+------+
+--+-----+-----+--+ | | |
|PRTA2 PRTA1 PRTA0| [150] [150] [150]
| | RX |A |A |A
|PRTA5 PRTA4 PRTA3| MC68XX [LED1] [LED2] [LED3]
+--+-----+-----+--+ | | |
| | | C | |
| | +-------[2200]---B NPN | |
| | E C |
| +-------------[2200]----|-----B NPN |
| | E C
+-------------------[2200]----|------|-----B NPN
| | E
| | |
+------+------+
|
GND

Thanks John that was Brilliant!!, but do you have a proper schematic
(May be in Jpeg,gif or .doc), email it to the address above its still
active.....thanks alot that was really helpful.

---
You're welcome :)

Sorry, I don't have a "proper" schematic, but if you'll post what you
don't understand about the one above, either I'll explain it to you or
someone else will if they get to it first.
 
Top