0% found this document useful (0 votes)
14 views

Fma Unit 5 Questions and Answers

The document discusses serial communication using an 8051 microcontroller. It provides steps to receive data serially, including initializing registers like TMOD and SCON. It also discusses transmitting data serially and the serial port structure of the 8051.

Uploaded by

Omkar Chede
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views

Fma Unit 5 Questions and Answers

The document discusses serial communication using an 8051 microcontroller. It provides steps to receive data serially, including initializing registers like TMOD and SCON. It also discusses transmitting data serially and the serial port structure of the 8051.

Uploaded by

Omkar Chede
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

Q1.

Write down the steps to be followed to receive a data serially using 8051
microcontroller?
Ans 1. The following steps are followed to receive a data serially using 8051
microcontroller :
1. TMOD register is loaded with value = 20 H, indicating the use of Timer 1
, mode 2 (8-bit auto reload) to set the baud rate.

2. TH1 is loaded with value to set the baud rate.


3. SCON register is loaded with value = 50 H, indicating serial mode 1, where 8-bit
data is framed with start and stop bits and receive enable is turned on.

5 0

0 1 0 1 0 0 0 0

SM0 SM1 SM2 REN TB8 RB8 TI RI

4. TR1 set to 1 to start timer 1.


5. RI is cleared by ‘CLR RI’ or ‘RI=0’ instruction
6) RI flag bit is monitored with the use of instruction ‘ JNB RI,XX’ (or in case of C
programming instruction ‘ while (RI==0)) to see if entire character has been
received completely.
7) when RI is raised , SBUF has the byte. Its contents are moved into a safe place.
8) To receive the next character , go to step 5.

Q2. Write down a short note on interfacing of a GSM module with 8051
microcontroller.
 GSM stands for Global System for Mobile Communication. It is a digital cellular
technology used for transmitting mobile voice and data services.
 The idea of GSM was developed at Bell Laboratories in 1970. It is a widely used
mobile communication system in the world. GSM is an open and digital cellular
technology used for transmitting mobile voice and data services operate at the
850MHz, 900MHz, 1800MHz, and 1900MHz frequency bands.
 GSM module is a device or chip that uses GSM network to establish communication
between electronic devices.
 GSM is a standard developed by standard developed by the European
Telecommunications Standards Institute (ETSI).
 To communicate with GSM modem, AT commands are required.
 Microcontroller sends these commands to the GSM modem, which is then
activated to perform the required operation.
 RXD pin of 8051 microcontroller is connected to TXD pin of GSM module and
TXD pin of 8051 microcontroller is connected to RXD pin of GSM module.

 AT commands with a GSM modem can be used to access following information and
services:
1. Information and configuration pertaining to MODEM and SIM card.
2. SMS services.
3. MMS services.
4. Fax services.
5. Data and Voice link over mobile network.
Q3. Write a program to transfer a character “P” serially at baud rate of 9600, Use
serial port in Mode 1. Crystal frequency is 11.0592 MHz

Q4. Draw the SCON register and explain use of individual bits of the register in
detail./Write a short note on SCON register.
Ans 4. SCON register is an 8-bit register used to program the start bit, stop bit, and
data bits of data framing , among other things.

SM0 SM1 SM2 REN TB8 RB8 TI RI

SM0 and SM1 are D7 and D6 of SCON register, respectively. These two bits
determine the framing of data by specifying the number of bits per character, and
the start and stop bits. They take the following combinations
Modes of serial communication
SM0 SM1
0 0 Serial Mode 0
0 1 Serial Mode 1, 8-bit data, 1 stop bit , 1 start bit
1 0 Serial Mode 2
1 1 Serial Mode 3
In serial mode 1, for each character a total of 10 bits are transferred , where the
first bit is the start bit , followed by 8 bits of data, and finally 1 stop bit.
SM2
It is the 5th bit of the SCON register. It enables the multiprocessing capability. It will
be set to 0, since it is not used.
REN
It is D4 bit of SCON register called as receive enable. When REN =1, 8051 receives
data on the RxD pin. If REN =0, the receiver is disabled. REN must be set to 1 , in
case of both receive and transfer data.
TB8
TB8(Transfer bit 8) is bit D3 of SCON. It is used for serial mode 2 and 3. It is not
used in our applications, hence it is made as 0.
RB8
RB8(receive bit 8) is bit D2 of SCON. It is used for serial mode 2 and 3. It is not used
in our applications, hence it is made as 0.
TI
TI(Transmit Interrupt) is bit D1 of SCON register, When 8051 finishes the transfer
of the 8-bit character, it raises the TI flag to indicate that it is ready to transfer
another byte. The TI bit is raised at the beginning of the stop bit.
RI
RI(receive interrupt) is bit D0 of SCON register, When 8051 receives data serially
via RxD, it get rid of the start and stop bits and places the byte in the SBUF register.
Then it raises the RI flag bit to indicate that a byte has been received and should be
picked up before it is lost. RI is raised hallway through the stop bit.

Q5. Write the steps taken by CPU to transfer data serially.


Ans 5.
The following steps are followed to transfer data serially using 8051
microcontroller :
1. TMOD register is loaded with value = 20 H, indicating the use of Timer 1
, mode 2 (8-bit auto reload) to set the baud rate.
2. TH1 is loaded with value to set the baud rate.
3. SCON register is loaded with value = 50 H, indicating serial mode 1, where 8-bit
data is framed with start and stop bits .

5 0

0 1 0 1 0 0 0 0

SM0 SM1 SM2 REN TB8 RB8 TI RI

4. TR1 set to 1 to start timer 1.


5. TI is cleared by ‘CLR TI’ or ‘TI=0’ instruction
6. The character byte to be transferred serially is written into the SBUF register,
7. TI flag bit is monitored with the use of instruction ‘JNB TI,XX’ (or in case of C
programming instruction while (TI==0)) to see if character has been transferred
completely.
8. To receive the next character, go to step 5.
Q6. Program 8051 in C to receive bytes of data serially and put them in P1. Set the
baud rate at 4800, 8-bit data, and I stop bit
Q7. Write program to transfer letter ‘T’ serially 10 times at baud rate of 4800.
Use serial port in mode 1. XTAL=12MHz.

#include<reg51.h>
void main(void)
{
unsigned char z;
z=0;
TMOD = 0X20;
TH1=0XFA;
SCON = 0X50;
TR1=1;
while(z<10)
{
SBUF ='T';
while(TI==0);
TI=0;
z++;
}
}
Q8. Write short note AT commands required for GSM.

Ans 8. AT is the abbreviation for Attention. AT commands are instructions used to


control modems. ‘AT’ is prefix that informs modem about start of command line.
AT Command instructions are single-line instructions that need to be sent to the device
in sequential order while the user has to wait for the response (in most cases) before
sending the next command. Sending across the relevant AT Commands and receiving its
responses usually requires a host device such as a microcontroller that is connected to
the modem via a UART (Universal Asynchronous Receiver/Transmitter). A UART is a
two-wire communication protocol that allows two devices to communicate with each
other in a half-duplex fashion.
AT Commands can be broadly classified into two sets, Basic Commands, and Extended
Commands.
Basic AT Commands
These are cellular modem AT Commands that do not begin with the “+” symbol. Some of
the common AT commands under the basic set are D (Dial), A (Answer), H (Hook
control), and O (Return to online data state).
Extended AT Commands
Extended Commands are those that start with the “+” symbol. All AT Commands for GSM
fall under this category and a few of the common commands are +CMGS (Send SMS
message), +CMGL (List SMS messages), and +CMGR (Read SMS messages).
Further, the AT Commands are of 4 categories primarily - Test Commands, Read
Commands, Set & Execution Commands.

Classification of AT commands

AT commands with a GSM/GPRS MODEM or mobile phone can be used to access


following information and services:
1. Information and configuration pertaining to mobile device or MODEM and
SIM card.
2. SMS services.
3. MMS services.
4. Fax services.
5. Data and Voice link over mobile network.

Examples of AT commands

• AT – To check connection has been established between modem and host


system (computer or microcontroller)
• ATD – To dial phone number
• ATA – To answer incoming calls
• ATH – To disconnect a call
• ‘AT + CMGF =’ – It is used to select the operating mode of the GSM modem
It takes one parameter. The value of the parameter can either be 0 or 1. The
values 0 and 1 refer to SMS PDU mode and SMS text mode respectively.
‘AT + CMGF =1’ – This command is used to set SMS text mode.

• ‘AT+CMGW=’- Phone number” - This command is used to store message in


the SIM.
• ‘AT+CMGS=’-This command is used to send a SMS message to a phone
number.
• ‘AT+CMGR =’- This command is used to read a SMS message.
• ‘AT+CMGL=’ – This command is used to list SMS messages.
• ‘AT+IPR=’ – Fixed DTE rate. It is the rate at which modem communicates with
the GSM network.
• ‘AT+CMSS =’ – Send message from storage.
• ‘AT+CMGD =’ – Delete message.
• ‘ATM’ – Monitor Speaker Mode.

Q9. Explain Serial port structure of 8051 microcontroller.

Ans 9 . The serial port structure of 8051 consists of UART(Universal Asynchronous


Receiver Transmitter) module. 8051 has RXD (serial data receive pin) and TXD (serial
data transmit pin) on PORT3.0 and PORT3.1 respectively to receive and transmit data
serially. In serial communication, data is sent one bit at a time.
Serial data communication uses two methods : Asynchronous and Synchronous.
Synchronous method transfers a block of data (character) at a time.
Asynchronous method transfers a single byte at a time.
In the asynchronous method, each character is placed between start and stop bits, called
as framing. Since the data received or transmitted in serial communication is all 0s and
1s; it is difficult to make sense of data without any protocol. Hence the data is packed in a
way called as data framing. In data framing, each character is placed between start and
stop bit.
The start bit is always one bit but the stop bit can be one or two bits. The start bit is
represented by low(0) and the stop bit by high(1).
In an asynchronous serial communication frame, the first START bit goes first followed
by the data byte and at last STOP bit goes which forms a 10-bit frame.
Refer following example to transmit ASCII character ‘A’
Character ‘A’ is equivalent to : 0100 0001 which is framed between start bit and stop bit.
Framing ASCII ”A”
Following registers are used for serial communication in 8051:

SBUF register :

SBUF is an 8-bit register used for serial communication. For a byte of data to be
transferred via TxD line, it must be placed in the SBUF register. Similarly SBUF holds the
byte of data when it is received by the 8051’s RxD line.

SCON register:

Refer answer 4 for explanation

Timer registers

Serial Communication registers of 8051 are programmed to transfer and receive data
serially.

Q10. Explain how Baud Rate is set for serial communication in 8051
microcontroller.
Ans10. The rate of data transfer in serial data communication is stated in bits per
second(bps) and is also called as baud rate. Baud rate is programable and is done with
the help of timer 1 in mode 2, that is 8-bit auto reload. 8051 divides the crystal frequency
by 12 to get the machine cycle frequency. If XTAL = 11.0592 MHz, the machine cycle
frequency is 921.6 kHz (11.0592MHz/12). The 8051’s serial communication UART
circuitry divides the machine cycle frequency of 921.6 kHz by 32 once more before it is
used by Timer 1 to set the baud rate. Therefore, 921.6 kHz divided by 32 gives 28,800 Hz.

For e.g : To set the baud rate of 9600, following calculations need to be performed:

Assume XTAL = 11.0592 MHz,


The machine cycle frequency of 8051 = 11.0592MHz/12 = 921.6 kHz and
921.6 kHz/32 = 28,800 Hz.
28,800 Hz is the frequency provided by UART to Timer 1 to set baud rate.
Calculation to load the value in TH1 to set the baud rate:
1) 28,800/3 = 9600 , where -3=FD H is loaded into TH1

Q11. Write a program to transfer a character “A” serially at baud rate of 4800, Use
serial port in mode 1. Crystal frequency is 11.0592 MHz

Ans11. Refer Answer 3

Q12. Assuming crystal frequency of 11.0592 MHz, find the value to be loaded in
TH1 to set up the following baud rates 1) 9600 2) 2400 3) 1200

Ans12. Given XTAL = 11.0592 MHz,


The machine cycle frequency of 8051 = 11.0592MHz/12 = 921.6 kHz and
921.6 kHz/32 = 28,800 Hz.
28,800 Hz is the frequency provided by UART to Timer 1 to set baud rate.
Calculation to load the value in TH1 to set the baud rate:
2) 28,800/3 = 9600 , where -3=FD H is loaded into TH1
3) 28,800/12 = 2400 where -12=F4 H is loaded into TH1
4) 28,800/24=1200 where -24 = E8 H is loaded into TH1

You might also like