RB8 bit in serial mode 1 of 8051Started by 4 years ago●2 replies●latest reply 4 years ago●109 views
I primarily refer to the following source for the 8051 programming information:
But it says nothing about the operation of the RB8 bit in serial mode 1. I look here:
and it states:
"RB8 – in mode 2/3 it is the 9th bit that was received in mode 1 if SM2 =0, RB8 is the stop bit that was received in mode it is not used."
I think what people are telling me is that I can use mode 1, and set SM2=0 to always get the actual stop bit value of the current byte once RI is set. Can someone confirm if such a feature officially exists in the 8051? I'm currently working with AT89C4051 and AT89S52 micros and I don't know if such a feature exists in any of them or certain ones?
I'm missing something -- a Stop Bit has No "value". It's the data end marker. Now if you mean a Parity Bit - that's easy: it is set (or not) to make the data an even (or odd) number of Ones. Modulation techniques in the last 20+ years have largely made it obsolete. Data integrity checking using it is straightforward, but inefficient versus CRC.
It looks like mode 1 will work for you (normal UART case), but I did not look at the chip datasheet.
The 9th bit is used for multi-drop RS485 serial networks. Each slave only listens to the master. The master sends an address for a particular slave + the 9th bit set. That slave "wakes up", activates its TX, and does an ACK. The other slaves still "sleep". The addressed slave and master mumble, when done, the slave goes back to "sleep".
UARTs that support a 9th bit are setup with an address register. When the address + 9th bit are sent, the slave UART compares the address register to the sent address. If there is a match, the slave asserts an interrupt to alert the rest of the slave code. Please note "sleep" - used in my first paragraph - is sleep only to the RS485 bus. The slave is generally alive and well, typically monitoring and/or controlling something.
Most (all?) Atmel UARTs support the 9th bit. Get a datasheet and read the UART section.
google "rs485 protocol tutorial". MODBUS uses a number of physical links, including RS485 and ethernet. If you are wanting to do an RS485 network (common for industrial control systems) take a look at MODBUS for a good starting point.
When possible, use 4-wire full duplex. 2 wires for TX; 2 for RX. If you do half-duplex (only 2 wires), both sides (master and addressed slave) must "flip" the direction of the line, which is fiddly and slow.