ECE 2984 Exam 1: Assembly & C Program for Button Debouncing & Serial Output, Exams of Microprocessors

Instructions for two programming tasks in the ece 2984 course. The first task requires writing an assembly language subroutine to serially output a 32-bit word using a memory-mapped register. The second task involves rewriting the c code for a button debouncing subroutine. The document also includes relevant prototypes and assumptions.

Typology: Exams

Pre 2010

Uploaded on 05/14/2009

angularmomentum
angularmomentum 🇺🇸

5

(2)

74 documents

1 / 3

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
ECE 2984 Exam #1: 11:15 March 20, 2009
1. Assume that a memory-mapped register named OUTPUT has been defined whose
least-significant bit is connected to an output pin and whose other bits are unused.
Write an assembly language subroutine that receives a 32-bit word from a C
program and outputs the word serially, most-significant bit first, in the following
manner. To output a zero bit, the output pin is set high for 1µsec and then set low
for 3µsec. To output a one bit, the output pin is set high for 3µsec and then set
low for 1µsec. The timing should be close, but does not have to be perfect. You
may assume that the output bit is zero upon entry to the subroutine. The
prototype for the subroutine in the calling program is:
extern “C” void send(unsigned int data);
2. Rewrite the code for the Button_Push subroutine in C. This subroutine is called
with a mask based on the switch of interest and should return a one if a debounced
0-1 transition has taken place on the switch and a zero otherwise. Assume that
the sleep routine you wrote for homework 4 is available and that the SWITCHES
register is located at memory address 0x8643000C. The relevant prototypes are:
extern “C” void sleep(unsigned int microseconds);
int Button_Push(unsigned int mask);
Each program should be on a separate sheet of paper. Readability and comments
are important. You do not need block header comments for this test.
pf3

Partial preview of the text

Download ECE 2984 Exam 1: Assembly & C Program for Button Debouncing & Serial Output and more Exams Microprocessors in PDF only on Docsity!

ECE 2984 Exam #1: 11:15 March 20, 2009

  1. Assume that a memory-mapped register named OUTPUT has been defined whose least-significant bit is connected to an output pin and whose other bits are unused. Write an assembly language subroutine that receives a 32-bit word from a C program and outputs the word serially, most-significant bit first, in the following manner. To output a zero bit, the output pin is set high for 1μsec and then set low for 3μsec. To output a one bit, the output pin is set high for 3μsec and then set low for 1μsec. The timing should be close, but does not have to be perfect. You may assume that the output bit is zero upon entry to the subroutine. The prototype for the subroutine in the calling program is: extern “C” void send(unsigned int data);
  2. Rewrite the code for the Button_Push subroutine in C. This subroutine is called with a mask based on the switch of interest and should return a one if a debounced 0 - 1 transition has taken place on the switch and a zero otherwise. Assume that the sleep routine you wrote for homework 4 is available and that the SWITCHES register is located at memory address 0x8643000C. The relevant prototypes are: extern “C” void sleep(unsigned int microseconds); int Button_Push(unsigned int mask); Each program should be on a separate sheet of paper. Readability and comments are important. You do not need block header comments for this test.