You are on page 1of 3

Mid-Spring Semester Examination 2015-16

Department of Electrical Engineering

Subject Number: EE30004 Subject Name: Embedded Systems

Slot G. Number of Students: 127 from EE, IE and QE

Time 2 hours. Maximum Marks: 60 Number of pages in the Question Paper: 2

INSTRUCTIONS:

1. Answer ALL questions. Distribution of marks is indicated alongside


2. Use AVR Instruction Set Mnemonics Summary provided at the end of this question
paper, to write all assembly language programs. Use appropriate comments and
flow-charts to explain the programs
3. For all questions assume the processor to have AVR architecture

Q1. (a) Fill in the blanks in the following statements. (1 X 5)


(i) ATmega32 microcontroller has a flash memory capacity of ____ kB.
(ii) Registers R28 and R29 when used together is called as the ___ register.
(iii) The status register bit storing the carry out of the 4th bit is known as ______.
(iv) After every PUSH instruction the Stack Pointer is ______________.
(v) After a reset, all the ports are configured as _________ ports.

Q1. (b) Mention whether the following statements are TRUE or FALSE. (1 X 5)
(i) The AVR microcontrollers use von-Neumann architecture.
(ii) The .DB directive can be used to store character strings in the flash memory.
(iii) All general purpose registers of the ATmega microcontroller are 8-bit wide.
(iv) The LDI instruction can be used to store a constant into any of the GPRs.
(v) The IN instruction is used to bring the content of any memory location to a GPR.

Q2. Consider the following program segments and determine the content of all the affected
registers/Input-output ports/memory location after each line/group of lines in a loop is
executed. Also mention if any relevant flag is affected. Assume that the stack pointer is
initialized to the highest RAM address in the data memory space. (2 X 5)

(a) (b) (c)


LDI R25, 0x44; LDI R17, 0b00001100; LDI R20, 0x3F;
LDI R26, 30; COM R17; OUT SPH, R20;
OR R25, R26; LDI R18, 0b01010101; LDI R20, 0xFF;
STS 0x052F, R26; EOR R17, R18; OUT SPL, R20;
STS 0x052E, R25; STS 0x052D; PUSH R20;
(d) (e)
LDI R21, 0x04; SBI DDRB, 5;
LDI R20, 11; LDI R17, 1<<5;
BACK: ADD R20, R20; LOOP: IN R5, PORTB;
DEC R21; EOR R5, R17;
BRNE BACK; OUT PORTB, R5;
PUSH R20; RJMP LOOP;

1
Q3. Analyze the following program segments and explain what functions they achieve (5X2)

(a) (b)
.ORG 0x0100; LDI R20, 0xEB;
LDI R25, 0x20; LDI R21, 10;
CALL FUNC; CALL SUBR;
| STS 0x300, R20;
.ORG 0x0200; MOV R20, R22;
FUNC : PUSH R26; CALL SUBR;
BACK1: LDI R26, 0x00; STS 0X301, R20;
BACK2: DEC R26; STS 0x302, R22;
BRNE BACK2; |
DEC R25; SUBR: LDI R22, 0;
BRNE BACK1; L1: INC R22;
POP R26; SUB R20, R21;
RET; BRCC L1;
DEC R22;
ADD R20, R21;
RET;

Q4. (a) Explain what are the various addressing modes of the AVR Instruction Set. Illustrate
your answer with examples. State any limitations of this instruction set. (5)

(b) Write an Assembly Language Program to search the range of data memory locations
from 0x100 to 0x1FF and count how many of them are positive, how many are negative and
how many are zeros. Store the counts in the memory locations 0x200 (positive), 0x201
(zeros) and 0x202 (negative) respectively. (10)

Q5. (a) Explain how the use of an interrupt mechanism can help free up processors time.
Illustrate your answer with an example in the context of the ATmega32 microcontroller. (5)

(b) Write an Interrupt Service Routine (ISR), which along with the standard tasks that any
ISR must carry out, monitors the 8 lines connected to the input port PORTB. It checks how
many of these lines is high (1) and if the number exceeds 4, then sets an alarm that is
connected to bit 7 of PORTC configured as an output port. Also write a small segment of the
MAIN program which will initialize the stack pointer and ports appropriately. (10)

Mnemonics for Instructions of AVR Microcontrollers


Data Transfer Branch Bit and Bit Test Arithmetic/Logic
MOV, MOVW, RJMP, IJMP, JMP, RCALL, SBI, CBI, ADD, ADC, ADIW,
LDI, LD, LDD, ICALL, CALL, RET, RETI, LSL, LSR, ROL, ROR, SUB, SUBI, SBC, SBCI,
LDS, ST, STD, CPSE, CP, CPC, CPI, ASR, SWAP, SBIW,
STS, SBRC, SBRS, SBIC, SBIS, BSET, BCLR, BST, BLD, AND, ANDI, OR, ORI, EOR,
LPM, SPM, BRBS, BRBC, BREQ, SEC, CLC, SEN, CLN, COM, NEG, SBR, CBR,
IN, OUT, BRNE, BRCS, BRCC, SEZ, CLZ, SEI, CLI, INC, DEC, TST, CLR, SER,
PUSH, POP BRSH, BRLO, BRMI, SES, CLS, SEV, CLV, MUL, MULS, MULSU,
MCU Control BRPL, BRGE, BRLT, SET, CLT, SEH, CLH FMUL, FMULS, FMULSU
BRHS, BRHC, BRTS,
NOP, SLEEP,
BRTC, BRVS, BRVC,
WDR, BREAK
BRIE, BRID

2
3

You might also like