ELEC 74 Worksheet 1 Logic Gate Review 1. Draw the truth table and schematic symbol for: a. An AND gate b. An OR gate c. An XOR gate d. A NOT gate
ELEC74 Worksheet 2 (Number Systems) 1. Convert the following binary numbers to octal, hexadecimal and decimal: Binary Octal Hexadecimal Decimal 0000 0001 0000 0010 0000 0100 0000 1000 0001 0000 0010 0000 0100 0000 1000 0000 0010 0011 0101 0110 0111 1001 1011 1100 1101 1110 1010 0101 0101 1010 0000 0000 1111 1111 1111 0000 0000 1111 2. Compute the following: a. 2 4 b. 16 2 c. 2 6 d. 8 2 e. 2 8 f. 16 4 g. 2 10 h. 2 20 3. How many unique values can be represented with an 8 bit, 16 bit and 32 bit binary numbers?
ELEC 74 Worksheet 3 Output Ports 1. Convert the following binary numbers to hex: 0101 1010 = 1101 1011 = 2. Write C code to set pins 10 as input and pin 20 as output. 3. Assuming we have a function called bytetopins (like nibbletopins from the labs but for 8 pins instead of four) that outputs one bit per bit of an input data word. bytetopins(uint8_t in, uint8_t p0, uint8_t p1, uint8_t p2, uint8_t p, uint8_t p, uint8_t p, uint8_t p, uint8_t p, uint8_t p) If pins 0-3 are configured as output and pins 4-7 as input, and pin 0-7 are hooked up to LED s, how many LED s will light up after this command: bytetopins(0x3c, 0,1,2,3,4,5,6,7);? 4. What are the C language reserved or stdint.h library words used to create an 8-bit unsigned variable? 5. In the pictured drawing, which side of the LED is connected to the microcontroller? anode or cathode 6. If the output voltage of the microcontroller is 3.3V and the forward bias voltage of the LED is 1.1V what is what is the required resistor value to have 22mA flowing through the LED?
ELEC 74 Worksheet 4 Inputs, Loops and Conditions 1. What is the logical AND operator? 2. What is the bitwise OR operator? 3. What is the result of a bitwise and (&) operation: 0 0 1 1 1 1 0 0 & 1 1 1 1 0 0 0 0 ------------------------- 4. What is the result of a bitwise or ( ) operation: 0xC3 0x0F? 5. What truth value does the following C language condition evaluate to? ( ( 0x05 & 0xF0 ) 0x01 ) 6. What value will x be when the following while loop exits? 7. How many times will have the loop been run? uint8_t i; uint8_t x; i = 1; while( i & 0x03 ) { i = i + 1; } x = i; 8. What is the steady state voltage potential at the BUTTON net if the button is not pushed?
ELEC 74 Worksheet 5 Subroutines 1. Write a prototype for a function called add that takes two uint8_t parameters a and b and returns a uint8_t value? 2. Write the function for the above prototype that returns the sum of a and b. 3. If the value 13 is passed to the following subroutine what value does it return? us8 foo(us8 x) { return (x - 3) / 2; } 4. What is the purpose of a subroutine? a. To hide complexity of sophisticated algorithms. b. The make a program easier to read. c. To break up complex problems in to smaller more manageable tasks. d. To hold the place of a non-existent function while developing a program. e. All of the above. Use the following function prototype to answer the next four questions: uint8_t foo(uint16_t bar, uint32_t baz); 5. How many parameters does the function expect to be passed to it? 6. What is the return type of the function? 7. What is the name of the second parameter? 8. What is the type of the first parameter passed to the function?
ELEC 74 Worksheet 6 Asynchronous Serial Comm. 1. How many bits are transmitted per frame with 9600, 8, N, 1 UART communications? 2. What is the width in seconds of a bit transmitted at 115,200bps? 3. What is the width in seconds of an 8-bit frame with one stop bit no parity? 4. If you only needed to transmit in a single direction at a time in both directions what duplex scheme or schemes could you use? 5. Write the line of code that can be used to setup serial communications at 9600 bits per second using the Arduino / Wiring abstractions. 6. What is the command to detect if any characters have been received by the target board? 7. What is the command to read a character out of the serial buffer? 8. If our desired bit rate is 115200 and our actual bit rate is 116312 using the following formula what is the percentage error from our desired bit rate? Error% = (Calculated Baud Rate - Desired Baud Rate)/Desired Baud Rate 100% 9. Will the error rate from the previous question be acceptable for most systems assuming 10 bits per frame?
ELEC 74 Worksheet 7 - Pointers 1. Declare an 8-bit unsigned variable x: 2. Declare a pointer to an 8-bit unsigned variable px: 3. What is the value of x after this program runs? void setup(void) { us8 x = 3; us8 y = 2; us8 *p; p = &y; x = x + *p; } 4. What is the value of c after this program runs? void setup(void) { char c; char string[] = ABCDEF ; char *p = string; p = p + 3; c = *p; } 5. How many bytes are allocated by the following declaration? char string[] = MtSAC ; 6. Data in a queue (circular buffer) is put into and pulled out of in what order? 7. What are the hexadecimal values for the ASCII characters 0 (zero) and A (capital A)? 8. What is the hexadecimal value for the ASCII characters \r?
ELEC 74 Worksheet 8 Strings and Parsing 1. What is difference between an A and an a in the ASCII table? 2. What is the <string.h> library function for getting the length of a string? 3. What is the <string.h> library function for comparing the values of two strings? 4. What is the purpose of implied null (zero) character at the end of a character string in the C programming language?
ELEC 74 Practical Exam Practice Create a program counts from 3 to 30 by 3's with a quarter second delay between each number. The output shall be displayed on the terminal window. When the count sequence if finished, it shall repeat. If a number is divisible by 5 print divisible by 5 next to it. At and above 20 print almost there at 30 print made it and do not print almost there. An example output put might look like this: