Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Help me up with settings of SCON

Status
Not open for further replies.

Help

Advanced Member level 2
Joined
Feb 15, 2005
Messages
617
Helped
7
Reputation
14
Reaction score
3
Trophy points
1,298
Activity points
7,065
Hi,

I have not so familiar with the SCON setting hope someone can help me.

Code:
SCON = 0xF0;
I already refer the datasheet of 80c51 instruction set (pg. 11).
- The SM0 and SM1 is SET mean Serial Port mode is 9-bit UART.
- SM2 and REN, i have not so understand what the datasheet have mean!!?
- The table 6. MODE-3 show SCON=F0H and SM2 Variation = Multiprocessor Environment (SM2=1). What does it mean?

When we have to use 9-bit UART? and when we have to use this MODE-3?

Please advice...

Thank you.
 

Re: SCON setting

Hi,

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. In this case, when SM2 is set High, a receive interrupt is generated only if the the 9th data bit is high. So, in multiprocessor system, if a master CPU sends out an address of a slave with 9th bit set, all processors with SM2 bit normally set will get an interrupt. Now if only the addressed slave clears its SM2 bit, subsequently all bytes sent by master with 9th bit zero will only interrupt the addressed slave and will not affect other slaves. 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 addressed slave can continue.

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
 

    Help

    Points: 2
    Helpful Answer Positive Rating
Re: SCON setting

Hi,

Thank you Laktronics. But i have abit confusing, can i conclude in this way:
SM2=1 & RB8(9th bit)=0 => no receive interrupt (no IR)
SM2=1 & RB8(9th bit)=1 => receive interrupt for address
SM2=0 & RB8(9th bit)=0 => receive interrupt for data

All the processor initial state, the SM2=1.
When the processor-A sent out the 9th-bit HI then all the other processor will ready to start recognize the Address would sent by processor-A. If the procssor-C is recognized the address then it will software clear the SM2=0 for ready to receive the Data from processor-A? am i right?
After processor-C finished receive the data. It should software set SM2=1. Is it the true?

May i know, can we using this SCON configuration on RS485 application? I never did RS485 before and multiprocessor befor. Please advice...

Do you have any simple sample coding for this SCON:Serial Port setting? Please can you share with me.

Thank You.
 

Re: SCON setting

Hi,
You are right, the slave which finished the communication should set its SM2 to high. Also with 9th bit set to high you can even send a frame of data having more than one bytes, depeding up on the application, one of the byte in such a frame can specify the slave address and others could be commands for the slave to initiate some actions.

For physical configuration of multiprocessors, infact, RS232 is not suitable and you need to use RS485 drivers along with RS232. Unlike RS232,RS485 drivers can drive long lines up to 1KM and has got facility to connect more than two devices on a pair of line. The TTL outputs of the UART can be connected to RS485 drivers and the enabling of the output of the driver on to the pair of wires is done by a separate port pin of the controller.

Software for such systems are always written as per the application, setting of SM2 bit and concept of 9 bit UART are mechanisms provided by the controlller to configure such systems.

Regards,
Laktronics
 

    Help

    Points: 2
    Helpful Answer Positive Rating
Re: SCON setting

Hi,

Also with 9th bit set to high you can even send a frame of data having more than one bytes,..
SM2=0 & RB8(9th bit)=0 => receive interrupt for data / commands
What did you mean that if 9th bit set to high then the slave can receive more then one bytes? I thought after the byte "address data + 9th bit set to high" the following data byte the 9th bit will set to Low as data or others commands for the slave to do some action?

Mean for physical configuration of multiprocessors, RS232/RS485 we need the serial driver? Yes, as i know we need to use RS485 driver to carrying our data through long distance. If we using the RS485 driver do we still need to take care the SM2 and RB8?

Thank You.
 

Re: SCON setting

Hi,
What I was trying to tell you is that there is no hard and fast rule saying only one byte should be transmitted with 9th bit set high. A multibyte message frame containing one address byte along with some command bytes with all bytes having 9th bit set, can be received by all slaves and only the addressed slave will respond to the message. So long as all slaves in the system understand the communication protocol, there is no problem and it is in hands of the system designer to implement whichever protocol he wants.

Even with RS485 drivers, you need either SM2 based selection or some other software based scheme of addressing to slectively communicate with slaves. The basic harware facilitates this process by providing Mode2/3 along with SM2 bit.

Regards,
Laktronics
 

    Help

    Points: 2
    Helpful Answer Positive Rating
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
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top