0% found this document useful (0 votes)
20 views7 pages

CSE391 - Batch 16

This document is an examination paper for the CSE 391 course on Embedded Systems and Interfacing at Bangladesh University of Engineering and Technology. It contains various questions related to microprocessor architecture, ADC configurations, interrupt handling, and interfacing with sensors, requiring students to demonstrate their understanding of embedded systems. The exam is structured into two sections, with specific instructions for answering questions and a focus on practical applications and coding tasks.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views7 pages

CSE391 - Batch 16

This document is an examination paper for the CSE 391 course on Embedded Systems and Interfacing at Bangladesh University of Engineering and Technology. It contains various questions related to microprocessor architecture, ADC configurations, interrupt handling, and interfacing with sensors, requiring students to demonstrate their understanding of embedded systems. The exam is structured into two sections, with specific instructions for answering questions and a focus on practical applications and coding tasks.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

L-3/T-lIBME Date: 29/10/2019

BANGLADESH UNIVERSITY OF ENGINEERING AND TECHNOLOGY, DHAKA


L-3/T -I B. Sc. Engineering Examinations 2018-2019
Sub: CSE 391 (Embedded Systems and Interfacing)
Full Marks: 210 Time: 3 Hours
The figures in the margin indicate full marks.
USE SEPARATE SCRlPTS FOR EACH SECTION
SECTION-A

There are FOUR questions in this section. Answer any THREE.


*Find the Pin Configuration of ATmega32 MCU and its different register configurations
at the end of the questions.
*If configuration for any of the required registers are missing, just assume configuration
and clearly mention your assumption. If you believe any control word/bit configuration is
missing in the question paper, just assume a pattern of your choice and clearly mention
..........yC)Llr<isslllllpti()!1,

1. (a) Suppose the Code Segment Register has a value 3100 and the Instruction Pointer
Register has a value 1208. What will be the address where the next instruction will be

fetched from? All the numbers are given in hexadecimal format. (5)
(b) Define Computer Bus. What do you understand by an n-bit microprocessor? In a
microprocessor system, the address bus 32-bit wide and the memory is byte addressable.

What is the maximum allowable address that can be addressed? (3+3+4=10)


(c) What does pre-fetching and pipe lining means in a microprocessor system? How

prefetching is done in 8086 architecture? (5+5=10)


(d) Define Harvard and Von Neumann Architecture. In case of 8086, which architecture

is used? Discuss its advantage(s) and disadvantage(s) over the other one. (3+3+4=10)

2. (a) What are the advantages of interrupt over polling? What are the steps does the CPU

follow to handle an interrupt? (4+8=12)


(b) Describe with example(s) the necessity of using "volatile" variables in a C program in

the context of ATmega32 interrupts. (5)


(c) Suppose for an 8086 architecture, we have the following instruction set.
- -------- - -
--

Instruction Type Description of Instruction lOp Code Now_c~.'!Si~ the fo~g_As;embly-~ode. -


.MOV A, 25H ._- ~--
ADD A, B A=A+B .
. 90
" •.• ADD A, B
ADD A, immediate A =A + immediate 91
ADD A, 36H
SUB B, [address] A == B - memory[address] 92
SUB B, [X]
.MOV A, immediate A = immediate 93
ORA, B
ORA,B A=AORB 94
JMP 1887H
JMP [address] The next instruction to be executed is 95
the one written at memory[address] I
MOV A, 255H
- --
ADD A, 5UH
~"

ADD A, B
. JMP 1996H
-Contd ~:.~~:~.P72--
=2=
CSE 391
Contd ..... Q. No. 3(c)
You have to write the machine code related to the above assembly code in the I MB main
memory of 8086 in tabular form as shown below. The Instruction (right) column should
contain the machine code to be written while the Address (left) column should contain
the address of the main memory where you are writing the corresponding code. Your
table should have row(s) for each of the given 10 assembly instructions. The values of
Code Segment Resister and Data Segment Register are 1800H and 9000H respectively
and both of the segments are 64KB of size. Remember that the memory of 8086 is byte
addressable and the data bus is 16-bit wide. Give a probable value of the variable 'X' of

the 4th assembly instruction and justify your value picking. (lOxl.S+3=18)
Address Instruction

3. (a) Consider that you have configured the ATmega32 ADC with a reference voltage of

4V and ADLAR = I. What is the step size when (3x3=9)


i) You are only reading ADCH?
ii) You are reading ADCL first and then ADCH?
iii) You are reading ADCH first and then ADCL?
(b) Suppose you are using an 8-bit ADC. The reference voltage is set to 3.56V. Calculate

the digital values is binary format when the analog input is (2x3=6)
1. 1.7V
2. 3.2V
(c) Consider the following scenario:
You are using a temperature sensor which produces an output voltage of OV to 4V for 0
degree to 100 degree Celsius linearly. The sensor is connected to the ADCO pin of
ATMega32 and you are using a pre scalar of 4. Your setup has two push buttons A and B
which are connected to INTI and INT2 pins, respectively.
Now write a C code to use ADC of ATmega32 MCU in interrupt mode so that when the
button A is pressed, the microcontroller will read the sensor value and determine the
temperature and then dump the temperature value on Port B. Upon pressing the button B,
port B will be reset to the room temperature value (assume to be 25 degree Celcius). keep
in mind that you have to choose the ADC reference voltage in a way so that the precision
is not compromised. The buttons bounce a lot. Do necessary steps in your code so that
debouncing is achieved.

Contd P/3
\

=3=
CSE 391
conk ... Gl. No :seC)
-------
The codes for external interrupt events of INTO and INTI are as following:

Code Interrupt Triggering Events


00 Low Level
01 Any Logical Change
10 Falling Edge
-11 Rising Edge

The codes for external interrupt events of external INT2 are as following:

Code -Interrupt Triggering Events


0 Falling Edge
1 Rising Edge

4. (a) Distinguish between a microprocessor and a microcontroller. (8)

(b) Discuss the following data addressing modes with their usage. (3x3=9)
(i) Base-plus-index addressing
(ii) Register relative addressing
(iii) Base-relative-plus-index addressing
(c) Suppose, 8086 is reading data bytes from a type writer through Port A of the 8255
using strobed input mode (mode I). The timing diagram for one byte of data transfer is
given below: -

.INTR
RD

DATAON-<-_ _ )_>- ~ _
PAo -PA7- -----------

4
Figure~25:Ti~i:g Dia:~m for ~lc)_
------------
Now redraw the same timing diagram in your answer script and mark the first occurrence
of each of the following events with the corresponding event ID surrounded by a circle
on the timing diagram. (2x9=18)
Contd P/3
CSE 391
Contd .... Q. No. 4(c)

Event ID Event Description


1 8255 loads data into its input latch
2 The typewriter indicates that data is no more valid
3 The typewriter sends data to port's data line
4 8255 forbids the typewriter to send next data
5 8255 lowers prevents a second interrupt for the same data
6 CP U starts reading the data
7 Data transfer complete
8 8255 informs CPU about the data by generating interrupt signal
9 . Read Complete

SECTION -B

There are FOUR questions in this section. Answer any THREE.

5. John Doe is passionate about embedded system. Currently he is working on a project


where he needs to interface LM35 (temperature sensor) with Arduino Uno. LM 35 is a
voltage-producing sensor. His circuit diagram for reading the ADC value is given in Fig.
for Q. 5. But he finds out that he is always reading a constant value. So he is thinking
about replacing the LM35 with a resistive sensor.
(a) What is the allowable reference voltage range for ADC in John's project? How John
can properly utilize this range? (2+3)
(b) Where is the problem in John's circuitry and how can it be solved? Write appropriate
code so that John's work is done. (3+4+8)
(c) "John can construct two different circuits if he switches to a resistive sensor"- do you

agree? Justify your answer with necessary diagrams. (10)


(d) After solving the problem with your suggestion, John finds out that the temperature
reading is 27°C. What value was read by the analogRead(ADC PIN) function? (5)

6. Steve Smith needs to design an alam1 to protect Bangladesh National Museum. He is


thinking about sonar sensors to detect unwanted presence of a person. These sensors will
be activated after closing the museum. The alarm(s) should be triggered when a person is
detected by the sonar-sensor(s). However, once an alarm starts, it should continue even
after the person moves away from the front of the sensor.

Contd P/4
.,:..

..

CSE 391
Contd ..... Q. NO.6
(a) In Smith's design, which switching element should be attached with the alarm? With
proper schematic diagram, discuss the self-repcating characteristics of his chosen

switching element. (2+8)


(b) Help Smith by constructing a circuit diagram to measure the distance of an obstacle
using Arduino Uno and HC-SR04 (sonar sensor).Write down the corresponding code to

implement this. (7+ 10)


(c) "The micr9controller of Arduino Uno has Harvard Architecture" - do you agree?

Justify your answer. (8)

. 7. Andrew Russell is using Raspberry Pi for smartly controlling his home. For this, he needs
to interface ADC0804 to his Pi. ADC0804 is an 8-bit, single channel, parallel output
ADC. But he has only 2 digital I/O pins left for interfacing ADC0804. He is also facing
difficulty to execute his program at startup. He is also annoyed to see a RUl1lime-
Warning, saying something along the lines "channels already in use" whenever he runs
his program more than once.
(a) How can Russell ensure execution of his program at startup? (7)
(b) What is the simple mechanism that Russell can use to interface ADC0804 with his Pi?

Discuss with connecting diagram. (10)


(c) Explain the concept of Priority-Inversion and chain-blocking and how these problems

are solved in RTOS with proper diagram. (10)


(d) Explain the concept of dual-kernels showing the diagram of its implementation. (8)

8. (a) Briefly describe the concept of channels and pipes in NRF24LOI module. (6)
(b) Is asynchronous communication really asynchronous as the name suggests? If not,
then write down some basic mechanisms that can be undertaken to co-ordinate such

communication among devices. (5)


(c) "SPI communication can be conceptually modeled as the interaction between two

shift registers" - do you agree with this statement. Justify your answer. (10)

(d) Briefly explain the repeated start condition and clock stretching of TWI protocol. (7+7)
(XCKlTO) PBO 1 40 PAD (ADCO)
(T1) PB1 2 39 PA1 (ADC1)
(INT2/AINO) PB2 3 38 PA2 (ADC2)
(OCO/AIN1) PB3 4 37 PA3 (ADC3)
(SS) PB4 5 36 PM (ADC4)
(MOSI) PB5 6 35 PA5 (ADC5)
(MISO) PB6 7 34 PA6 (ADC6)
(SCK) PB7 8 33 PA7 (ADC7)
RESET 9 32 AREF
VCC 10 31 GND
GND 11 30 AVCC
XTAL2 12 29 PC7 (TOSC2)
XTAL1 13 28 PC6 (TOSC1)
(RXD) PDO 14 27 PC5 (TDI)
(TXD) PD1 15 26 PC4 (TDO)
(INTO) PD2 16 25 PC3 (TMS)
(INT1) PD3 17 24 PC2 (TCK)
(OC1B) PD4 18 23 PC1 (SDA)
(OC1A) PD5 19 22 PCO (SCL)
(ICP1) PD6 20 21 PD7 (OC2)

, I
ATMega32 Pin Out for Section i iA
- U

Register
Configuration
Name .

'GICR I INTFI I INTFO INTF2 - I - I - I - - I


GIFR I INTFI I INTFO INTF2 - I - I - I - - I
MCUCR I SE I SM2 SMI SMO I ISC11 I ISClO
I lSCOl lSCOO I
MCUCSR I JTD I ISC2 - JTRF I WDRF I BORF I EXTRF PORF I
TCCRIA I COMlA~ COMlAq COMlEl COMIBOI FOCIA I FOClE I WGM11 WGMIO I
TCCRIB I lCNCl I ICESI 1 - WGM13 I WGM12 I CS12 I CS11 CSlO I
TIMSK I OCIE2 I TOIE2 I TICIEI OCIEIA I OCIEIB TOlE 1 I OCIEO TOIEO I
1 TOV2 I' ICFl OCFlA I OCFlE
TIFR l.oCF2 TOVI OCFO TOVO I
UCSRA I RXC I TXC / UDRE I FE DOR PE U2X MPCM
UCSRB I RXCIE' / TXCIE I UDRIE RXEN TXEN UCSZ2 RXB8 TXB8
UCSRC I URSEL I UMSEL UPMl UPMO USBS UCSZl UCSZO I UCP.OL
SPCR I SPIE I SPE DORD MSTR CPOL I CPHA I SPRI I SPRI
SPSR I SPIF I WCOL - - I - /. - 1 - SPI2X
ADMUX I REFSI I REFSO ADLAR MUX4 MUX3 MUX2 I MUXI MUXO I
ADCCSRA I ADEN I ADSC ADATE ADIF. ADIE ADPS2 I ADPSI ADPSO I
EEARH I - I - - - - - EEAR9 EEARS I
EEARL I EEARD I I EEARO I
EEDR I MSB I I I / LSB I
EECR I - .1 - I - - EERIE I EEMWEI EEWE I EERE I
. I
List of Regist~rs of ATMega32 for Section" ! A
~/
----,------
- ._- --~---~--

Part1
,
~ ., .. .i
"

"!:l,' :'~,' z-:.


';('I'l": ~>'
~EsE'f i.'po,ffii
1:1' . ~ES~ )01.1'1')(
, ~-
.. ,..'
. " .•<"
MEF'
::.;. ,. ., III
'. iorei: 03 ffl~;
"l: ..'Dji

:".; , .. .
'LM35 "r
Ab , 'OS.I'WM
VoiJt
"

Temperature. ":" ","'. "


sensor' ~1
Aidulno
O.l"NM

',,,.l:)~- .•. c .... KJ.' :"Uno:


'Q :07

:
..
.

:(',i','"
~.. (Rev3)'
~'. . ,,' oa -

.,
~ !'4(S.O~ ,D!lPWM _.

:',':; : I;SISW ','010'~PWMISS..

:oi) :~W/:ii~I05r
[)12IMISO ..
!'t3i~K

Nic
~' .
. ,!I.:)

.,

Figurf J'fui~circuit
A.:.....

._--- --_. ---- --=----- - - ---

You might also like