Week 2 Self Assessment Quiz Questions 1.[4] A pushbutton switch is known to have switching bounce that has a maximum duration of 10ms, with transient highs and lows of 10-100uS. You have devised a debounce routine of the counting variety. The routine must observe the switch input remaining the same for 16 samples to return a true or false indication. How often would you sample the switch with the routine to properly debounce it and so that the user was not to be annoyed by the delay of the debounce routine? 2.[4] Cross coupled NAND gates are sometimes used to debounce single pole, double throw switches. What two assumptions are made about the switches operation that ensures the circuit to work? 3.[4] Clean Hardware Inc. is using a uC to sample a switch closure. Due to a severe loss in company stock value however, the switch supplier has gone out of business. Clean Hardware Inc. now must use a cheaper switch that bounces for a longer time. A count based debouncer (Gansel's) is used to debounce the switch. The debounce routine is called by a periodic interrupt. What could you do to the debounce routine to compensate for the poorer switch? int8_t debounce_switch() { static uint16_t state = 0; state = (state << 1) | (! bit_is_clear(PIND, 2)) | 0xE000; if (state == 0xF000) return 1; return 0; } 4.[6] A student saves the following single line of text in a file called "my_file". "The big lazy cow tried to jump over the frighted red fox." (without quotes) Later, the file is opened with: > vi my_file Then the following vi commands are issued. Show what the file contains after the edits. When the file is opened by vi, the prompt is on the "T" of "The". i"I said " w r"t" w dw w r"D", 3w rb 3w dw w cw "line" :x Show what the file now contains: 5.[4] Write the resulting sentence produced when using vi: vi test This test is fun. 16h cw Learning w cw vi :%s/is/can be/g 6.[3] If a uC samples a bouncing switch too fast what is the effect on the software? 7.[3] How does a RC filter debounce a switch? Why is a RC filter alone insufficient? 8.[3] Why aren't interrupts used to sample switch closings? 9.[2] What is the maximum delay that a switch closure can exhibit until its irritating to humans? 10.[3] If we use Gansel's debouncer, how long does the function return true? 11.[4] Describe how does the oscilloscope triggers in: -a. Normal mode -b. Line mode -c. Single-shot mode 12.[3] Suppose you want to look at repetitive switching noise on the 5V supply line. The noise is on the order of tens of millivolts. Circle the best trigger settings: Trigger type : normal, line, single_shot Trigger coupling : AC, DC Trigger level : 1V, 0.1V, 0.01v 13.[3] Exactly what does "an asynchronous input" mean to the hardware of a uC? 14.[4] We start with .c code and download .hex code to our avr board. What are the tools used and what are the intermediate file types produced in getting the .hex code? input file tool output file myfile.c -> -> -> -> -> -> myfile.hex 15.[2] What does the compiler (avr-gcc) do? 16.[2] What does the linker (ld) do? 17.[2] Why is the initial .o file emitted from the compiler not executable by the uC? 18.[3] What is the "startup code" for? 19.[2] What is in the .text area of code? 20.[2] Why are the initialized variables copied from Flash to SRAM in the startup code? 21.[2] To successfully debug a system, two basic things are needed. What are they? (Hint: C...... and O.....) 22.[3] When using assembly language with gcc in the way described in class, explain what precautions must be taken in regards to register use.