2010/7/5 Ruben J=F6nsson : > As others have said you can handle the frame decoding in the ISR itself a= nd > only call the processing_thread when you have a complete frame in order to > increase efficiency. > > Another thing I havn't seen mentioned here yet is the potential problem w= ith > collitions which have to be addressed since you are planning on making a > multimaster protocol. A collition will happen if two masters tries to ini= tiate > a message at roughly the same time. If you are planning to use standard R= S485 > tranciever chips the masters themselves may not even notice the collition= even > if you read back the transmitted data since they actively drive the line = to > both polarities. > > This can be solved with a bus that is only actively driven to one polarit= y and > passively pulled to the other. This is how a CAN bus works. > > If you don't want a bus that is only actively driven to one polarity (it = will > be more succeptible to noise in the passive state) there are other method= s to > try to minimize the chance of a collition between masters to a low enough > probability that it can be acceptable. One such way is to wait a random t= ime > after the bus has become quiet until the master starts to transmitt the n= ext > frame. In the unlikely event that two masters still will transmitt at the= same > time and not notice each other, the message will be messed up anyway and = the > checksum/crc will catch the faulty message. Of course, you will need some= sort > of ACK mechanism so the master knows that the message has not been receiv= ed for > this to work. Instead of using a random backoff time, you could use a time > based on the unique identifier address (which most likely exists anyway) = for > the master. This could give masters with a lower address a higher priorit= y. Hi Ruben, I had another thread a while ago specifically addressing issues with multi-master protocols and collision detection/avoidance over RS485. I just have to go find it now and re-read it. I love these discussions. So much useful information. -- = http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist