A few more details - the main PIC communicates with a network of current, humidity and pressure sensors. Each of the remote sensors is built with an 18F2321. Every two seconds the main PIC sends three bytes - the address, a command, and a checksum to all the slaves using DEBUGOUT (since all the USARTS are already used). The appropriate slave sends back 4 bytes - the address of the slave, two bytes of data, and a checksum. Open-collector mode is used so that the outputs of the sensors can all be tied together on one wire (an 820 ohm pull-up is used). The slaves all respond to address 254 by default on programming. Whatever number is sent in the command byte to a slave at address 254 becomes the slave's new address and is stored in the '2321's EEPROM. This way a slave's address can be set without using jumpers. The slaves all run on their internal 8Mhz oscillators, and amazingly, communicate reliably at 19.2K baud with the master (which is running at 40Mhz).
I did have to modify PBPPIC18.LIB to allow DEBUGOUT (on the slaves) to run open-collector.
The slaves basically read their associated sensor(s) and then sit in a tight loop waiting for the main PIC to send their address and command. As soon as they recognize their address, command and checksum, they wait 10uSec and send the data back.
This is probably more than anyone wanted to read, but you asked...
Bookmarks