Wow That seems like an Awesome Protocol!
BrianT made a great Protocol! i have a project that could use this idea!
It depends in wheter you will use several or just one Slave, if you will use several you would have to make a Data Path Access Control (to avoid collision), this is what BrianT made with the Attention pin. If on the other hand your are using just one slave you can do so many things!! I have even done it with Serout and Serin Commands! But i will definitively recommend you using serial port and interrupts.
A nice protocol for communication is used in one of Microchips AppNotes, the one with the Serial Bootloader for 18F and 16F devices (dont remember the number right now, easy to find on their webpage), in that protocol you can find that they try to connect a uC with a PC in both ways, it uses CRC and even an autobaud function. Pay attention to the packet they form it is simple just 4 or 5 extrabytes.
From my point of view if you really have a "Master" the master can and should control all the communication, slave should just answer to the Masters Request, otherwise it could get tricky (or just trickier).:)
The simplest form i have used before was just sending 1byte data from Master to Slave, there you can have 255 orders ;), but you can get in trouble if the byte gets messed up and the slave ends up receiving garbage.
Whats i think is better is for you to give us one of your ideas, that way we can tell you pros and cons we find on it.
re PIC master slave howto
Thanks for the reply
Well as i'm only heving a remote slave and a local master i'm not using any
bus or adressing, so a 2 wire differential interface in halfduplex is fine
Here is what I want to do in detail
Slave site:
16F88 with 7 AN channels, I use 6 AN channels for voltage measuring 10bit
Outputs: 1 AN channel (AN6) and one PortB
Inputs: 4 input pins to read there status
Bidirectional: 1 1wire port with 1 DS1820 temperature sensor
RS422 with SP485 level converter using 3 PortB pins: TXD,RXD,TX or RX select
Master Site
RS422 with SP485 level converter using 3 PortB pins: TXD,RXD,TX or RX select
LCD
Keypad
The master polls the slave
and request 6 AN variables in 10bit, requests the status of the 4 input pins,
request the 1wire temperatur sensor raw value (2 words) or eventually a converted value
The keyboard allows to toggle both outputs which are "bits" (portb.x)
So my question is how can I handle this with serin2 at the slave side with the use of "WAIT" i guess ? and if possible with a CRC added
Can I read all variables in a row or variable by variable , and what if i want to toggle the 2 outputs ?
Do I need to use an interupt of the buildin uart ? (SP485 is connected to the hardware RXD/TXD)
Speed will be 9600 8N1
Thanks