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

Final Exam Microprocessor Fundamentals 2020 Part 2

This document appears to be a final exam for a microprocessor fundamentals course. It contains 7 questions assessing various concepts related to microprocessors, including: 1) taking the Laplace transform of a function, 2) taking the inverse Laplace transform of a function, 3) reducing block diagrams, 4) modifying code to implement a timer interrupt, 5) inserting code to generate a square wave using inline assembly, and 6) using provided code to enable interrupts on an Arduino board to generate pulses on different pins at specified frequencies. The document provides space for students to show their work and solutions.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
169 views

Final Exam Microprocessor Fundamentals 2020 Part 2

This document appears to be a final exam for a microprocessor fundamentals course. It contains 7 questions assessing various concepts related to microprocessors, including: 1) taking the Laplace transform of a function, 2) taking the inverse Laplace transform of a function, 3) reducing block diagrams, 4) modifying code to implement a timer interrupt, 5) inserting code to generate a square wave using inline assembly, and 6) using provided code to enable interrupts on an Arduino board to generate pulses on different pins at specified frequencies. The document provides space for students to show their work and solutions.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

Final Exam 4/28/2020

EET306 Microprocessor Fundamentals


Grambling State University 1|Page

Student Name:________________________________________

Outcome Assessment

Section Outcome/ Concept Score


1 1
2 1
3 1
4 1
5 2
6 2
7 2

1|Page
Final Exam 4/28/2020
EET306 Microprocessor Fundamentals
Grambling State University 2|Page

Instructions: Work all problems in the space provided. Please show your steps for full credit. (Please see
assignment solutions posted on canvas.

1. Find ℒ{𝑓(𝑡)} = 10 + 𝑒−𝑡

4
2. Find ℒ -1 [s2 +16

3. Reduce the block diagram using the techniques disused in this course

Ein + Ein
70 0.4 35
-

25

4. Reduce the block diagram using the techniques disused in this course

+ + 5 Ein
Ein
10
- -
20

0.7

2|Page
Final Exam 4/28/2020
EET306 Microprocessor Fundamentals
Grambling State University 3|Page

5. For the following design, modify the code to implement the timer interrupt for Timer 2 for 20ms.
Implement code in the ISR to toggle output pin 13 is the input pin 2 is low. The attached code1 is an
example that uses all three timers of the Arduino
VCC
5.0V
R1
S1
P2 10kΩ

Key = Space

P13 R2
LED1
330Ω

Insert your Timer setup code and Interrupt Service Routine code below

3|Page
Final Exam 4/28/2020
EET306 Microprocessor Fundamentals
Grambling State University 4|Page

6. Use inline assembly to generate a square wave with a 75% duty cycle. (75% of period on and 25% of
period on). The frequency of this square wave should be the number of letters in your first name
multiplied by 10KHz. For example for lane, the square wave frequency should be 40KHz. The sample
program is presented below for approximately 1Hz square wave (one cycle per second). For your code
you need to have two separate delay functions, one for on and one for off. (Remember period= 1/freq,
On time = 0.75 x period, offdelay =0.25 x period)

• delay: is used as a label. The instructions that follow are used to implement a on
second delay.
• dec r8 is used to subtract 1 form r8. brne delay implements the following:
branch if r8 is not equal to zero. (subtracting 1 from 0 results in the following, 0,
254, 253,...1 ,0) go to delay label. After this is repeated 255 times and r8 becomes
equal to 0, then
• dec r9 decrements r9 by one. brne delay then directs the pointer to go to label
delay is r9 is not equal to zero.
• The process is repeated for r16 which has been preloaded with 40 so it takes
less cycles t get to zero.
• The delay function uses three nested loops to implement a one second delay.
dec r8 takes one clock cycle to execute. brne delay takes 2 clock cycles to execute.
This results in 255x255x40 = 2601000 iterations of 3 clock cycles. If a clock
frequency of 16MHz is assumed, we can calculate the delay. 2601000 x 3 x
(1/16MHz) = 0.487 seconds.
• ret is used to return the subroutine.

Please write your code below

4|Page
Final Exam 4/28/2020
EET306 Microprocessor Fundamentals
Grambling State University 5|Page

Attached Code 1.(Using timers to generate square waves)

//timer interrupts
//by Amanda Ghassaei
//June 2012
//https://www.instructables.com/id/Arduino-Timer-Interrupts/
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
*/
//timer setup for timer0, timer1, and timer2.
//For arduino uno or any board with ATMEL 328/168.. diecimila, duemilanove, lilypad, nano, mini...

//this code will enable all three arduino timer interrupts.


//timer0 will interrupt at 2kHz
//timer1 will interrupt at 1Hz
//timer2 will interrupt at 8kHz

//storage variables
boolean toggle0 = 0;
boolean toggle1 = 0;
boolean toggle2 = 0;

void setup(){
//set pins as outputs
pinMode(8, OUTPUT);
pinMode(9, OUTPUT);
pinMode(13, OUTPUT);

cli();//stop interrupts

//set timer0 interrupt at 2kHz


TCCR0A = 0;// set entire TCCR2A register to 0
TCCR0B = 0;// same for TCCR2B
TCNT0 = 0;//initialize counter value to 0
// set compare match register for 2khz increments
OCR0A = 124;// = (16*10^6) / (2000*64) - 1 (must be <256)
// turn on CTC mode
TCCR0A |= (1 << WGM01);
// Set CS01 and CS00 bits for 64 prescaler
5|Page
Final Exam 4/28/2020
EET306 Microprocessor Fundamentals
Grambling State University 6|Page

TCCR0B |= (1 << CS01) | (1 << CS00);


// enable timer compare interrupt
TIMSK0 |= (1 << OCIE0A);

//set timer1 interrupt at 1Hz


TCCR1A = 0;// set entire TCCR1A register to 0
TCCR1B = 0;// same for TCCR1B
TCNT1 = 0;//initialize counter value to 0
// set compare match register for 1hz increments
OCR1A = 15624;// = (16*10^6) / (1*1024) - 1 (must be <65536)
// turn on CTC mode
TCCR1B |= (1 << WGM12);
// Set CS12 and CS10 bits for 1024 prescaler
TCCR1B |= (1 << CS12) | (1 << CS10);
// enable timer compare interrupt
TIMSK1 |= (1 << OCIE1A);

//set timer2 interrupt at 8kHz


TCCR2A = 0;// set entire TCCR2A register to 0
TCCR2B = 0;// same for TCCR2B
TCNT2 = 0;//initialize counter value to 0
// set compare match register for 8khz increments
OCR2A = 249;// = (16*10^6) / (8000*8) - 1 (must be <256)
// turn on CTC mode
TCCR2A |= (1 << WGM21);
// Set CS21 bit for 8 prescaler
TCCR2B |= (1 << CS21);
// enable timer compare interrupt
TIMSK2 |= (1 << OCIE2A);

sei();//allow interrupts

}//end setup

ISR(TIMER0_COMPA_vect){//timer0 interrupt 2kHz toggles pin 8


//generates pulse wave of frequency 2kHz/2 = 1kHz (takes two cycles for full wave- toggle high then toggle low)
if (toggle0){
digitalWrite(8,HIGH);
toggle0 = 0;
}
else{
digitalWrite(8,LOW);
toggle0 = 1;
}
}

6|Page
Final Exam 4/28/2020
EET306 Microprocessor Fundamentals
Grambling State University 7|Page

ISR(TIMER1_COMPA_vect){//timer1 interrupt 1Hz toggles pin 13 (LED)


//generates pulse wave of frequency 1Hz/2 = 0.5kHz (takes two cycles for full wave- toggle high then toggle low)
if (toggle1){
digitalWrite(13,HIGH);
toggle1 = 0;
}
else{
digitalWrite(13,LOW);
toggle1 = 1;
}
}

ISR(TIMER2_COMPA_vect){//timer1 interrupt 8kHz toggles pin 9


//generates pulse wave of frequency 8kHz/2 = 4kHz (takes two cycles for full wave- toggle high then toggle low)
if (toggle2){
digitalWrite(9,HIGH);
toggle2 = 0;
}
else{
digitalWrite(9,LOW);
toggle2 = 1;
}
}

void loop(){
//do other things here
}

7|Page

You might also like