Re: SCON setting
Hi,
There is a lack of clarity regarding the usage of SM2 bit in my previous post, so I am posting below the same matter made more clear:
1. When you select in SCON register SM0 SM1 = 10 or 11, you get 9 bit UART modes 2 or 3. Basically these two modes are same except for the baud rates used and these modes are called Multiprocessor modes, and are useful for communicating with multiple processors. In these modes, each byte transmitted will contain one start bit, nine data bits and one stop bit (totally eleven bits as against ten bits in standard UART mode1).
2. The selection of any of the above two modes along with the setting or resetting of the SM2 bit is the key to establishing the multiprocessor communication scheme.
When SM2 is set High, the RI flag is not set and a receive interrupt is not generated if the the 9th data bit is low. When the 9th data bit is high, the receive interrupt will be generated irrespective of the state of SM2. So, in a multiprocessor system if a master sends out an address of a slave with 9th bit set, all processors irrespective of the state of their SM2 bit will get an interrupt. Now if only the addressed slave clears its SM2 bit, with other slaves setting their SM2 bit high, subsequent bytes sent by master/slave on the bus with 9th bit zero will not interrupt slaves whose SM2 bits are set high. After finishing the communication with the selected slave the master can again send another slave address with 9th bit set so that the attention of all the slaves in the network can be got by the master and selective communication with the newly selected slave can continue as discussed.
3. SM2 bit also affects Mode 1 operation. If SM2 bit is set in Mode1, the receive interrupt will happen only if the 9th bit, stop bit in this case, is received high, thus ensuring that mangled bytes with lost stop bits are not received. In Mode 0, SM2 bit is always kept cleared.
Regards,
Laktronics