EC Microcontroller and Interfacing
EC Microcontroller and Interfacing
/Seat No_______________
1
OR
Q.5 (a) Explain I2C bus protocol. 03
(b) Draw and explain DC motor connection using Darlington transistor with AVR 04
microcontroller.
(c) Draw and explain LCD interfacing with AVR microcontroller. Also write 07
program to display “ Happy New Year” on LCD.
******************
2
Enrolment No./Seat No_______________
MARKS
Q.1 (a) What is the size of code and data memory in ATmega32 03
Microcontroller
(b) Explain the criteria for selecting a microcontroller. 04
(c) Explain various addressing modes of AVR microcontroller with 07
appropriate example
Q.4 (a) Write an AVR C program to toggle all the bits of Port C 50 times. 03
(b) Explain steps in executing interrupt in AVR ATmega32 04
microcontroller.
(c) For AVR ATmega32 microcontroller, assume that INT0 pin is 07
connected to a switch that is normally high. Write a C program that
toggles PORTC.3, whenever INT0 pin goes low. Use external
interrupt in level triggered mode. Explain your program with
necessary comments.
OR
1
Q.4 (a) How to enable and disable interrupt in AVR ATmega32 03
microcontroller.
(b) Which are the different timers are available in ATmega32. Explain 04
the times 1 with necessary diagram.
(c) Write an AVR ‘C’ program using Timer0 and Timer1 interrupt, 07
generate square wave on PB1 and PB7 respectively while
transferring data from port C to port D.
*************
2
Enrolment No./Seat No_____________
MARKS
Q.1 (a) List various AVR family microcontroller with their specifications. 03
(b) Explain the simplified view of an AVR microcontroller with necessary 04
diagrams.
Q.5 (a) Explain the use of PWM signal in AVR controller with an example. 03
(b) Explain SPI protocol of AVR microcontroller. 04
(c) Explain asynchronous serial communication and write a ‘C’ language 07
program to transfer letter ‘A’ serially at 9600 baud rates continuously.
Use 8-bit data, and 1-stop bit. Assume XTAL= 8 MHz
OR
Q.5 (a) Define the interrupts and types of interrupts available in the AVR 03
controller. What is the priority of it.
(b) Write a ‘C’ language program that gradually changes the speed of a DC 04
motor from 50% to 100%.
(c) Write short notes on I2C protocol with necessary diagrams. 07
*************
2
Seat No.: ________ Enrolment No.___________
Q.3 (a) Write an assembly language code to transfer value $30 on the location $105 03
and on the PORT B IO register.
(b) Describe JMP, RJMP, IJMP and Conditional JMP instructions of AVR. 04
(c) Write a ‘C’ program to read the keypad and send the result to Port D 07
PC0-PC3 connected to column
PC4-PC7 connected to rows
OR
Q.3 (a) Write an assembly language code to determine if RAM location 0x200 03
contains the value 0. If so, put 0x55 into it.
(b) Describe CALL, RET, RCALL and ICALL instruction of AVR. 04
(c) Explain the dual role of Port A, B, C and D of AVR also explain the role of 07
DDR register to inputting and outputting of data with an example.
Q.4 (a) Write a ‘C’ program to convert packed BCD 0x34 to ASCII and display the 03
bytes on PORT B and PORT C.
(b) Explain Timer/Counter Control and Interrupt flag register of AVR. 04
(c) Write a ‘C’ program to toggle only the PORTB.4 bit continuously every 70 07
uS. Use Timer 0, normal mode, and 1:8 pre-scaler to create the delay.
Assume XTAL = 8 MHz
OR
Q.4 (a) Write a ‘C’ program to convert ASCII digit of ‘7’ and ‘2’ to packed BCD 03
and display them on PORT B.
(b) Explain MCU Control Register and Status Register of AVR with necessary 04
diagram.
(c) Write a ‘C’ program using Timer 1 of AVR which toggles pin PORTB.5 07
every second, while at the same time transferring data from PORT C to
PORT D. Assume XTAL = 8 MHz.
1
Q.5 (a) With Vref = 1.28 V, find the Vin for following outputs 03
(a) D7-D0 = 11111111 (b) D7-D0 = 10011001
(c) D7-D0 = 01101100
(b) Assuming XTAL = 8MHz, using non-inverted mode, write an assembly or 04
‘C’ program that generate a wave with frequency of 31,250 Hz and duty
cycle of 75 %.
(c) Discuss I2C BUS protocol with necessary diagram 07
OR
Q.5 (a) Calculate the step size for following ADC if Vref is 5 V 03
(a) 8-bit (b) 10-bit (c) 12-bit (d) 16-bit
(b) Write a ‘C’ program that gradually changes the speed of DC motor from 04
50% to 100%
(c) Discuss SPI BUS protocol and its various modes with necessary diagram. 07
*************
2
Seat No.: ________ Enrolment No.___________
Marks
Q.1 (a) Differentiate Microprocessor and Microcontroller 03
(b) List down the number of ports available in ATmega32. 04
Mention the steps to configure them as input and output ports.
1
Q.4 (a) Write down the various data types with range used in 03
embedded C programming.
(b) Explain simplex, half and full duplex transfers of data 04
communication
(c) Interface 8 LEDs and a switch with AVR controller and write 07
a program to demonstrate up/down counter with mod control.
OR
Q.4 (a) Discuss how branch instructions are executed. 03
(b) Explain CALL and RET instructions. 04
(c) Write a C language program to monitor PB0 continuously an 07
soon as it goes high activate the buzzer connected on PB1 and
send a high to low pulse on PB2
2
Seat No.: ________ Enrolment No.___________
1
(c) Write an assembly language program to generate time delay of 10ms using 07
timer 1 in normal mode. Choose prescaler of 1024. Exclude the instruction
overhead due to the instructions in loop. Assume XTAL = 8MHz
OR
Q.3 (a) Assume XTAL=8 MHz.(a) Find the Clock Period fed to Timer0 if a prescaler 03
option of 1024 is chosen.(b) show what is the largest time delay we can get
using this prescaler.
(b) How the Timer0 can work as an Event counter? Explain in Brief. 04
(c) Write a program (in Assembly or C) that toggles pin PORTB.7 every 90 μs, 07
while at the same time transferring data from PORTC to PORTD. Assume
XTAL = 1MHz and use Timer0 with Interrupt.
Q.4 (a) Assume that the INT0 pin is connected to Switch. Write an assembly 03
language program in which, whenever it goes low the content of PORTC
increases by one.
(b) With diagram explain baud rate generation mechanism for serial 04
communication in AVR microcontroller.
(c) Write an assembly language program to transmit the message “GTU” 07
serially at 9600 baud, 8-bit data and 1 stop bit. Do this Forever.
OR
Q.4 (a) Explain what happens if both INT1F and INT2F are activated at the same 03
time?
(b) How does SPI bus protocol work? 04
(c) Discuss temperature sensor interfacing with ATmega32 and write a 07
program(in Assembly or C) to display temperature on PORT D.
Q.5 (a) Explain the controlling stepper motor via optoisolator. 03
(b) Indicate the step to identify the key pressed. 04
(c) Two strings are given in memory. String s1 = “Hello”, String s2 = “World”. 07
Write an assembly language program to display string s1 on 1st row of LCD
and string s2 on 2nd row of LCD.
OR
Q.5 (a) Write ATmega32 ADC Features. 03
(b) Assuming that clock pulses are fed into pin ICP1, write a program to read the 04
TCNT1 value on every rising edge. Place the result on PORTA and PORTB.
(c) Explain the connection of Stepper motor with AVR. And write a program to 07
rotate it continuously.
*************
2
Seat No.: ________ Enrolment No.___________
MARKS
Q.1 (a) What is an assembler directive? Explain .org, .set directives. 03
(b) Draw & Explain AVR status register. 04
(c) Draw & Explain Harvard architecture in the AVR 07
Q.4 (a) Draw and explain interfacing diagram of 4x4 keypad with AVR. 03
(b) Draw interfacing diagram of LCD with AVR. 04
(c) Write a program that (a) after 4 external clocks turns on an LED 07
connected to the OC0 pin, (b) toggles the OC0 pin every 4 pulses
OR
Q.4 (a) Explain following command code in LCD. 01, 08 and C0. 03
(b) Write different steps to transfer data serially in AVR. 04
(c) Write a program to transmit the message “YES” serially at 9600 07
baud, 8 bit data and 1 stop bit. Do this forever.
1
(c) A switch is connected to pin PA7. Write an assembly language 07
program to monitor the status of switch and perform the following
:
a. If Switch =0, the stepper motor moves clockwise
b. If Switch =1, the stepper motor moves counter clockwise
OR
Q.5 (a) Explain DS1307 control register. 03
(b) Explain multibyte read and write operation in SPI. 04
(c) Show how a master writes the value 11110000 to a slave with the 07
address 1001101 in I2C bus.
*************
2
Seat No.: ________ Enrolment No.___________
MARKS
Q.1 (a) List various AVR family microcontrollers with basic specification. 03
(b) Explain following AVR instructions : 04
a) JMP b) ORI
Q.2 (a) Give the name and the manufacturer of some of the widely used 8 bit 03
microcontrollers.
(b) Explain AVR assembler directives. 04
(c) Explain AVR MACROs in brief. 07
OR
(c) Explain how the I2C read and write operation works? 07
Q.3 (a) List all major interrupts of the AVR. 03
(b) Describe the normal and CTC modes of AVR timers. 04
(c) Explain how the SPI read and write operation works? 07
OR
Q.3 (a) Explain AVR instruction : SBI and CBI 03
(b) Explain BRANCH and CALL instruction in AVR microcontroller 04
with example.
(c) Explain PWM interfacing with AVR in C. 07
Q.4 (a) Explain the purpose of the status register. 03
(b) Describe the basic function of opto-isolator. 04
(c) Write a assembly program to toggle led after every 50 mili seconds. 07
OR
Q.4 (a) Write advantage of assembly language programming. 03
(b) Describe the basic operation of stepper motor with diagram. 04
(c) Write a assembly program to find biggest number from given 10 07
numbers.
Q.5 (a) Write down ATMEGA32 ADC features. 03
(b) Explain following AVR assembly instructions: 04
a) LDI b) IN
(c) Write a c program to blink two LED connected to output port with the 07
help of two different timers.
OR
Q.5 (a) Describe the function of the pins of the typical LCD. 03
(b) Explain the function of the DS1307 RTC registers. 04
(c) Write a c program to display input message from keyboard to 16 x2 07
LCD
*************
1
Seat No.: ________ Enrolment No.___________
MARKS
Q.1 (a) How microcontroller is different from microprocessor? 03
(b) What is role of flags in microcontroller? Explain AVR Status register 04
(c) Draw and explain architecture of AVR Microcontroller. Explain 07
Programming model.
Q.2 (a) Write assembly language program to check status switch connected to 03
port pin PC0 ad show status on port pin PA0
(b) Write assembly language program to read data from PORT A and PORT 04
B. Add these data and store answer at data memory location 0x0800
(c) What is interrupt? What are the interrupts available in AVR 07
microcontroller? Explain GICR (Global Interrupt Control Register) and
TIMSK (Timer Interrupt Mask Register)
OR
(c) Why look up table is important for real life applications? Prepare look up 07
table for common anode seven segment displays for digits 0 to 9. Write
assembly or C program to send all seven segment codes stored in look up
table one by one to PORTB at the interval of 1 second.
Q.3 (a) What will be content of register R16 after execution of following 03
instructions?
LDI R16,0x55
LDI R17,0x22
LSL R16
EOR R16,R17
(b) Write assembly or C language instructions to do following tasks: 04
(1) Toggle port pin PD0
(2) Enable External interrupts
(c) Explain following assembly language instructions with suitable examples 07
(1) BLD (2) STS (3) LPM (4) BRNE (5) LSL (6) BRCC (7) CBR
OR
Q.3 (a) Explain conditional branch instructions BREQ and BRNE with examples 03
(b) Write assembly or C language instructions to do following tasks: 04
(1) Set pins PD0-PD3 output and PD4-PD7 input
(2) Enable Timer interrupts
(c) Write program to read water level sensor connected at port pin PA0. 07
Turn ON the relay if water level sensor output is logic LOW and Turn
OFF the relay if water level sensor output logic is HIGH. Consider that
relay is controlled by the transistor whose base terminal is connected at
1
port pin PC7 via series resistor of 220 Ω. Draw interfacing circuit
diagram and write program in assembly or C language.
Q.4 (a) Explain unconditional branch instructions JMP and RJMP with examples 03
(b) Three color common cathode LED (RED, BLUE and GREEN) is 04
connected to port pin PA0, PA1 and PA2 respectively. Write program in
Assembly OR C language to glow LED for color RED, BLUE and
GREEN at the interval of 1 second.
(c) Draw and explain interfacing diagram of LCD with AVR 07
Microcontroller. Use PORTD to connect data lines, RS with PB0, RW
with PB1 and Enable with PB2. Write C language program to display
Message “WEAR MASK” on the first line of LCD and “SOCIAL
DISTANCE” on second line of LCD.
OR
Q.4 (a) Draw interfacing diagram to interface DC motor with AVR 03
microcontroller with help of motor driver IC L293D. Use port pins PD0,
PD1 and PD2 to control the motor
(b) Write assembly or C language program to rotate DC motor in clockwise 04
direction for 2 second and anticlockwise direction for 2 second. Consider
connections as per interfacing diagram of Q.4(a).
(c) How many timers are there in ATMega32 microcontroller? What is need 07
of timers in embedded systems? Explain programming steps to use
timers. Write program to generate 100 Hz square wave on port pin PD0
using timer 0.
*************
2
Seat No.: ________ Enrolment No.___________
Q.2 (a) What will be content of register R16 after executing following instructions? 03
LDI R16, 0xAA
LSL R16
SBR R16,3
Q.3 (a) Write C language program to toggle port pin PC6 continuously with highest 03
frequency without using any delay.
(b) What will be status of C,Z,V and H flag after execution of following 04
instructions ..
LDI R16,0xB6
LDI R17,0x4A
ADD R17,R18
Q.4 (a) Write assembly language program to read data from PORT A and PORT B. 03
Perform addition of these data and store answer at memory location 0x0AF9
(b) Push-button switch S is connected to port pin PA7 in such a way that when 04
switch S is pressed, pin PA7 is at logic “0” and when switch S is not pressed
pin PA7 is at logic “1”. Buzzer is connected to port pin PC5 with help of
NPN transistor driver circuit. Write assembly language program as per
following requirements.
“When push-button switch S is pressed, buzzer should sound and when
push-button switch S is released, buzzer sound should stop”. Use
unconditional loop to run this program continuously to check status of the
switch S and perform above task in infinite loop.
(c) Write C or assembly language program for object counter. Display count 07
value on output device connected with port A (send hexadecimal count value
on port A). Optical sensor is connected to port pin PD2 to sense the object.
Q.5 (a) Write assembly language program to toggle port pin PD7 200 times using 03
conditional branching instruction.
(b) Write assembly language instructions for the following task: 04
Read data from port A and store it in register R16, compare it with 0x7F. If
data in register R16 is greater than 0x7F, set port pin PD0 else clear port
pin PD0. Use unconditional loop to do above task continuously.
(c) Draw and explain interfacing diagram of LCD with AVR Microcontroller. 07
Use Port A to connect data lines, RS with PC0, RW with PC1 and Enable
with PC2. Write Assembly or C language program to display Message
“WELCOME TO GTU” on the first line and “Outcome based Education” on
second line of LCD.
Q.8 (a) What will be content of PORTC after executing following C Programming 03
instructions?
2
DDRC=0xFF;
PORTC=0x00;
PORTC=PORTC | (1<<2);
(b) 8 bit DAC is connected to port B of AVR microcontroller. Write assembly 04
or C language program to generate stair-step ramp output from DAC.
(c) Stepper motor is controlled by four port pins PB0 to PB3 in uni-polar mode. 07
Switch S1 is connected to port pin PD2(External interrupt 0) pin. Switch S2
is connected to port pin PD3(External interrupt 1) pin. Write assembly or C
language program to rotate motor clockwise if switch S1 is pressed and anti-
clockwise of switch S2 is pressed in full step mode. Draw interfacing
diagram and write assembly or C language program.
*************
3
Seat No.: ________ Enrolment No.___________
Q.2 (a) Write the difference between IN and LDS instruction of AVR 03
microcontroller
(b) Explain the feature of RISC architecture 04
(c) Assume that the data memory location 0x315 contains FD(hex). Write 07
an assembly language program to convert it into decimal and save the
result into the location 0x322,0x323 and 0x324 where least significant
digit store into 0x322.
OR
(c) Write an assembly language program to transfer the value 41H serially 07
(one bit at a time) via pin PB1. Put one high at start and end of the data.
Send the LSB first.
Q.3 (a) What is MACRO and how it is used? 03
(b) Explain the following instruction with example 04
1. NEG 2. LSL 3. SWAP 4. SBI
(c) Assuming XTAL = 8 MHz write an assembly language program to 07
toggle PB5 once per millisecond.
OR
Q.3 (a) What are assembler directives? Explain any three assembler directives. 03
(b) Explain the following instruction with example 04
1. SBIS 2. IJMP 3. RET 4. RCALL
(c) Discuss SPI bus protocol with reference to AVR microcontroller 07
Q.4 (a) Write an AVR ‘C’ program to toggle all bits of port B continuously with 03
a some delay. Use Timer0, normal mode and no prescaler option to
generate time delay.
(b) Which are the different timers are available in ATmega32. Explain the 04
times 0 with necessary diagram.
(c) Write an AVR ‘C’ program using Timer0 and Timer1 interrupt, generate 07
square wave on PB1 and PB7 respectively while transferring data from
port C to port D.
OR
Q.4 (a) Write an AVR ‘C’ program to get a byte of data from port ‘C’ if it is 03
less than 100 , send it to port B otherwise send it to port D.
(b) Explain the functionality of each bit of TCCR0 and TIFR with necessary 04
diagram.
(c) Explain the connection of ATmega32 with RS232. Write an AVR ‘C’ 07
program to receive character from the serial port if it is ‘a’ to ‘z’ change
1
it to capital letters and transmit it back. Use port A to receive data set
baud rate at 9600, 8-bit data and 1 stop bit.
Q.5 (a) Draw and explain DC motor connection using darlington transistor. 03
(b) Explain the functioning of DDRX, PORTX, and PINX registers with 04
necessary example.
(c) Explain ATmega32 ADC feature and write an AVR ‘C’ program using 07
interrupt and polling method to convert analog input into digital form.
Assume port A as input port and port B and port D as an output port
OR
Q.5 (a) Explain the different types of stepper motor and its interfacing diagram 03
with AVR microcontroller
(b) Draw the interfacing diagram of keyboard with AVR microcontroller 04
and explain its working.
(c) With neat diagram and appropriate programming example discuss the 07
Interfacing of LCD with AVR microcontroller.
*************
2
Seat No.: ________ Enrolment No.___________
1
(b) Write an AVR ALP to perform 253/10, store remainder in R20 register 04
and quotient in R21 register.
(c) Explain Look-up table concept in AVR with example. 07
OR
Q.5 (a) Compare: Macros and Subroutines. 03
(b) Write an AVR ALP for multiplication of two 8 bit data. 04
(c) Discuss I2C bus protocol with appropriate diagram. 07
*************
2
Seat No.: ________ Enrolment No.___________
GUJARAT TECHNOLOGICAL UNIVERSITY
BE - SEMESTER–V (NEW) - EXAMINATION – SUMMER 2018
Subject Code:2151001 Date:02/05/2018
Subject Name:Microcontroller and Interfacing (EC)
Time:02:30 PM to 05:00 PM Total Marks: 70
Instructions:
1. Attempt all questions.
2. Make suitable assumptions wherever necessary.
3. Figures to the right indicate full marks.
MARKS
Q.1 (a) Define the word microcontroller and compare it with the word 03
microprocessor.
(b) List the flags associated with AVR microcontroller and explain any three 04
flags with proper example.
(c) Draw the internal architectural block diagram of AVR microcontroller 07
and explain the function of each block in brief.
Q.2 (a) Write an ALP to toggle I/O register of port B continuously forever. 03
(b) Define addressing mode. Discuss Data Indirect addressing Mode for 04
AVR with proper example.
(c) Discuss the AVR data memory in detail. 07
OR
(c) Discuss SPI bus protocol with reference to AVR microcontroller. 07
Q.3 (a) Draw and explain Harvard Architecture. 03
(b) Draw the pin diagram of AVR microcontroller and explain the functions 04
of following pins.
1. MISO 2. RESET
3. RXD 4. TCK
OR
Q.3 (a) Draw and explain TCCR0 register for ATMega32. 03
(b) Explain the functioning of DDRX, PORTX, and PINX registers with 04
appropriate example.
(c) Discuss the steps for execution of branch instruction in AVR. 07
List different branch instructions and explain any two with proper
example.
Q.4 (a) List the features and advantages of RISC Architecture. 03
(b) Write an ALP for addition of two 16 bit data for AVR microcontroller. 04
(c) Assuming that XTAL=8MHz, Write a program to generate a square wave with 07
a period of 12.5 µsec on pin PORTB.3. Explain your algorithm with neat flow
chart and proper comments.
1
OR
Q.4 (a) Explain in brief the execution process of interrupts with reference to AVR 03
microcontroller.
(b) Write a brief technical note on serial data communication with reference 04
to AVR microcontroller.
(c) Write a program in assembly/embedded C to arrange the five different 07
data stored in memory in ascending order.
Q.5 (a) Explain with diagram, stepper motor interfacing with AVR. 03
(b) Write a brief technical note on ADC peripheral of AVR microcontroller. 04
(c) Assume that bit PB4 is an input and represents the condition of a door 07
alarm. If it goes LOW, it means that the door is open. Monitor the bit
continuously. Whenever it goes LOW, send a High-to-Low pulse to port
PC5 to turn ON a buzzer. Draw the flow chart and write an ALP for it.
OR
Q.5 (a) What is assembler directives? Explain any three assembler directives in 03
brief.
(b) Write an ALP/Embedded C program to create a square wave of 50% duty 04
cycle on pin PORTB.5 bit. Timer 0 is used to generate the time delay.
(c) With neat diagram and appropriate programming example discuss the 07
interfacing of LCD with AVR microcontroller.
*************