Hello Jcee,
L>>Well I think that it would work fine with one master and the other to be slave. Can you have several slaves? Not that I need it but it can be good to know in the future. What is the main difference between the programs if one or both is master?<<
You can easily have several chips being slaves. the master "initiates" the communication, and then the communication starts.
With only one master, all the other chips are "listening" . With Two masters, both chips must be listening, and be able to transmit too.
masterchip. Psuedocode.
TRISA = "%00000001"
Tx Var Porta.0
Rx Var Porta.1
Loop:
Tx=High 'initiate transmittion
Pauseus 10 'give time for receiver to switch to receive mode
Serout Tx, 2400, ["Slave1","T"] 'make sure only Slave1 chip recevies the "T"
if Rx <> High then Loop 'Slave did not receive the "T";
Serout Tx,2400,"Transmit all my data here"
Tx=Low
end of routine.
Receiver.
Same variable setup.
RxData var byte
Loop:
while Rx <> "High" goto Loop;
Serin Rx,2400,["Slave1",RxData];
if RxData<>"T" then Loop;
Serin Rx,2400,receive your data here.
end routine.
I am at work, so I can't write the "exact code" but this can give you a idea how to start it. I believe you only have to put the correct format and be running.
If you notice, this was made for *many* slaves.
Dwayne
Ability to Fly:
Hurling yourself towards the ground, and missing.
Engineers that Contribute to flying:
Both optimists and pessimists contribute to the society. The optimist invents the aeroplane, the pessimist the parachute
Pilots that are Flying:
Those who know their limitations, and respect the green side of the grass...
Bookmarks