NYU Tandon School of Engineering Take Home Quiz 2 ECE6483 – Real Time Embedded Systems PROBLEM 1 (20 Points): Suppose you are required to retrieve the temperature from the Analog Devices AD5933 chip, which is a chip used to make very precise impedance measurements. The interface is I2C and the relevant portions of the datasheet for this chip are attached. Also assume you have access to several I2C functions as follows: a. int Start_I2C() i. Initializes all of the I2C hardware pins etc. Returns 1 if successful, 0 otherwise b. int I2C_Write_Byte(uint8_t data) i. Writes ‘data’ on the I2C Bus. Returns 1 if slave ACK, 0 is slave NAK c. int I2C_Send_Start_Condition(uint8_t address, int isRead) i. Send a start or restart condition, followed by 7-bit address, followed by ‘isRead’ bit, which is 0 if write, 1 if read. ii. Returns 1 if successful, 0 otherwise d. int I2C_Send_Stop_Condition() i. returns 1 if successful, 0 otherwise e. int I2C_Request_Read(unint8_t *buffer, int numBytes) i. reads ‘numBytes’ bytes off the bus, each followed by an master ACK except for the last byte, which if followed by a master NAK indicating an end to the read. Returns 1 if it gets all the bytes, 0 otherwise and buffer holds the bytes. Using the datasheet provided, write a C code function float GetTemperature() required to get the temperature of the AD5933 chip. You can add any additional variables as long as you state what they are for and be sure to state any assumptions made. PROBLEM 2 (20 Points): The requirement for this question is to use interrupts to measure the time elapsed while a single button (GPIO) is being pressed. The GPIO pin is pulled to a high state when the button is not depressed. In this application, the button is mechanical and experiences significant bouncing. The goal is to measure the contiguous time (in ms) between when the button is pressed and when the button is released, excluding the bouncing. See diagram below. timeElapsed You have already setup 3 interrupt handlers. One handler is the ISR that handles Timer0’s overflow. That timer is set up with a prescaler of 32, a counter TOP value of 250, and is set up to reset to 0 and count up to TOP. The CLK is running at 16MHz. Here is the handler definition: void Timer0_OV_Handler() The other 2 handlers are for the pin that is connected to the button. One handles the RISING transition, and the other handles the FALLING transition. Here are the definitions: void pinRising_Handler() void pinFalling_Handler() Write the required code snippits (in each handler) that assigns the variable timeElapsed to the specified time in the timing diagram. You may add any additional variables, but be sure to state any assumptions. PROBLEM 3 (20 Points): Suppose you use UART to send an ASCII `Z' (0b01011010) using 8N1 (one start bit, 8 data bits, no parity bit, one stop bit), at 38400 baud. a. Draw a timing diagram for this communication. Assume bit transitions are instantaneous. Make sure to label the time axis (label the time of each bit transition). b. Suppose the receiver is operating at 50000 baud, and is sampling bits at the middle of each bit period (i.e. at 10 s, 30 s, 50 s, etc.). On your timing diagram from the previous part, mark the times at which the receiver would sample the incoming waveform. c. What bits would the receiver “receive"? Would the receiver have any indication of the baud rate mismatch in this example? PROBLEM 4 (10 Points): Suppose you would like to communicate using 1 master and 4 slaves using SPI. Propose a design that will allow complete duplex communication between the master and all 4 slaves using only 5 GPIO lines. You may propose additional hardware if necessary. PROBLEM 5 (20 Points): Consider the I2C timing diagram below. Describe the entire transaction and indicate all stop/start conditions, bytes transferred (including direction), and ack bits. PROBLEM 6 (20 Points): Please evaluate (T or F) and explain the following statements: a. An interrupt is always a high priority, urgent task. b. Using interrupts is always faster than polling. c. System latency is always larger than interrupt latency d. Global variables used within an ISR should always be declared volatile. e. The interrupt vector table must be placed in a specific location in memory. f. An ISR can return a value and take arguments g. It is OK for an ISR to safely access the SPI bus that has multiple slaves.
欢迎咨询51作业君