Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
5 views8 pages

CMPE453 FinalQuestions

The document is a final exam for the course CMPE453: Embedded Systems, scheduled for April 1, 2025, with a duration of 120 minutes. It consists of four questions covering topics such as debouncing in embedded systems, GPIO configuration for ARM microcontrollers, PWM generation, and ADC with interrupts. The exam is closed-book, and strict rules regarding communication and electronic device usage are enforced.

Uploaded by

sadoran45
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views8 pages

CMPE453 FinalQuestions

The document is a final exam for the course CMPE453: Embedded Systems, scheduled for April 1, 2025, with a duration of 120 minutes. It consists of four questions covering topics such as debouncing in embedded systems, GPIO configuration for ARM microcontrollers, PWM generation, and ADC with interrupts. The exam is closed-book, and strict rules regarding communication and electronic device usage are enforced.

Uploaded by

sadoran45
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 8

CMPE453: Embedded Systems

Department of Computer Engineering


CMPE453: Embedded Systems, FINAL EXAM
Fall 2024-25, Date: 04/01/2025
Duration: 120 minutes

FULL NAME :

STUDENT ID :

SIGNATURE :

QUESTIONS POINTS
Q1 /25
Q2 /20
Q3 /30
Q4 /25

TOTAL /100

Please Read Carefully


 This is a closed-book exam.
 Talking is strictly forbidden during the exam.
 Use of electronic devices including mobile phones is forbidden during the exam.
 Students will not be allowed to enter 10 minutes after the exam starts and will not be able to
leave in the last 10 minutes of the exam.
 Exchange of items (erasers, pens, pencils, etc.) during the exam is strictly forbidden.
 There should be total of 4 questions. Check your exam paper at the beginning.
 Show your work clearly in the spaces provided.

1|Page
CMPE453: Embedded Systems

Q1. Debouncing is a critical and mostly encountered issue in embedded systems where one needs to ensure
that the device does not misinterpret a single button press as many (more than one click). Debouncing is
implemented by using timers/counters. Write the pieces (lines) of C code for debounce mechanism for a push-
button input using a timer on an AVR microcontroller using following steps:

a) The push-button is connected to pin 0, port C that generates a high level when pressed and a low level
when released. Define this port as input in void setup_button() where you enable pull up resistor and
define data direction, without disturbing rest of the pins (10 Points)

resistor on pin 0 of

b) For debounce, you need to a timer for 32 ms. Write the C code void timer_init(void) for timer
configuration where you should use a timer in normal mode with a precaler of 1024. You should count
starting from 0 (zero) and wait for roll-over, when timer0 has overflow just clear the overflow flag. The
necessary registers are also provided below. (10 Points)

2|Page
CMPE453: Embedded Systems

c) Assume that you would like to use external clock source, how would you change your C code? Indicate
whether you used falling or rising edge? (5 Points)

TIFR (Timer/Counter Interrupt Flag Register)

3|Page
CMPE453: Embedded Systems

Q2. Given the following embedded design and pin select function table for PINSEL registers for an ARM
microcontroller below: Write the C code which will:

a) Configure P0.0 to P0.15 as GPIO (General Purpose Input/Output) (5 points each)

b) Make P0.0 bit as output bit, P0.1 bit as an input pin using IODIR

4|Page
CMPE453: Embedded Systems

c) If switch is open (i.e if input) pin is HIGH turn on the LED

d) If switch is closed (i.e if input) pin is LOW turn off the LED

5|Page
CMPE453: Embedded Systems

Q3. The following C code should generate a PWM with 10% duty cycle and 100 msec period for an ARM
based microcontroller LPC 2148. Complete the code with all necessary parameters (where ever you see
underline) to generate a double edge controlled PWM on PWM3 (P0.1) including the lines with
comments. Read and observe parameters carefully (3x10 = 30 Points)

PWMTCR (PWM Timer Control Register)

PWMLER (PWM Latch Enable Register)

int main (void) {


VPBDIV = 0x00000002; /* Sets the peripheral clock to 30 MHz
PINSEL0 = ; /* Configure P0.1 and P0.7 as PWM3 and PWM2 respectively */
/* PINSEL0 = ; Configure P0.1 and P0.8 as PWM3 and PWM4 respectively */
// For PWM3 double edge
PWMTCR = ; /* Reset and disable counter for PWM */
PWMPR = ; /* Prescale value for 2usec */
PWMMR0 = ; /* Time period of PWM wave, 100msec */
PWMMR2 = 40000; /* Rising edge of double edge controlled PWM */
PWMMR3 = ; /* Falling edge of double edge controlled PWM for 10% Duty Cycle */
PWMMCR = 0x00000243; /* Reset and interrupt on MR0 match, interrupt on MR2 and MR3 match */
PWMLER = ; /* Latch enable for PWM3, PWM2 and PWM0 */
/* PWMLER = ; /* Latch enable for PWM3, PWM4 and PWM0 */
PWMPCR = 0x0C08; /* Enable PWM3, PWM2 and PWM0, double edge controlled PWM on PWM3 */
PWMTCR = ; /* Enable PWM and counter */
/* Generate PWM for ever */

6|Page
CMPE453: Embedded Systems

Q4: ADC and interrupts

a) Consider the following Successive Approximation algorithm for a n-bit ADC where n = 4. Complete the
table below to show the values of the variables/expression of four successive iterations of the execution if
the input voltage is vin = 10.8V. (0.5x22 = 11
Points)
Step 1: set index =n-1 (i.e. 3)
Step 2: set SAR = 1000
Step 3: read an input-voltage i.e. Vin
Step 4: if (Index > 0) set SAR[Index -1] =1
Step 5: if Vin > VDAC
SAR[Index]=1
else
SAR[Index]=0
Step 6: Index--
Step 7: Go to Step 4

Iteration 4-bit SAR VDAC (V) Vin > VDAC (T/F) Index Index-1
1

Final Result

b) Considering the following interrupt related registers of an AVR microcontroller, write a function named
initInterrupt1 to trigger INT1 on the raising edge of the signal from a hardware device. (6 Points)

7|Page
CMPE453: Embedded Systems

c) Write the interrupt service routine (ISR) for INT1 which will toggle all the pins of the output port B for five
times with a delay of 100 ms (using the library function _delay_ms). Assume that all the pins of port B are
already configured as output pins. (8 Points)

8|Page

You might also like