讲解:CPEG 222、Java,c/c++、Python、canvasPython|Proces

CPEG 222 Fall 2019Homework 4This homework is to be completed individually.Due: Nov 13th at midnight (through canvas)Note: To receive full credit, please show your steps and put comments for your code.1. Assume that a sensor outputs an analog signal with a range of 0V and 3.3V (i.e., reference voltage =3.3V). A linear A/D converter then converts the analog signal into a digital signal. The transfer functionis shifted to the left ½ LSB to reduce quantization error.(a) Identify the smallest detectable change in voltage (that is, no matter what the original voltage is,the change can always be detected) if the ADC uses (1) 5-bits of resolution; (2) 8-bits ofresolution.(b) For an input voltage of 3.14V, identify the quantization error if the ADC uses (1) 5-bits ofresolution; (2) 8-bits of resolution.2. An analog temperature sensor is connected to analog port AN0 of a PIC32MX370F512LMicrocontroller. The sensor provides an analog output voltage proportionally to the temperature, i.eV0 = 10mV/oC.(c) Write a c code to declare pin AN0 as analog input.(d) Write a c code to configure the ADC module and read the temperature sensor manually.3. Assume a student configures his timer and ADC to sample at 11KHz. When a sample arrives, aninterrupt handler will be invoked to process the sample. When 1024 samples are collected, an FFTprocedure is invoked to process them and convert the signal from time domain to frequency domain.Assume the processor takes 200 cycles to switch from a procedure to ISR and from the ISR to theprocedure. The ISR takes 500 cycles to process each sample, and FFT takes 80,000 cycles to process1024 sample points at once. The processor speed is 80MHz and executes one instruction per cycle.(a) How many application instructions can be executed between two consecutive interrupts?(b) If timer interrupts are allowed to interrupt FFT, in one single FFT process, how many times willFFT be interrupted?4. Consider the following program that monitors two sensors. Here sensor1 and sensor2 denote thevariables storing the readouts from two sensors. The actual read is performed by the functionsreadSensor1() and readSensor2(), respectively, which are called in the interrupt service routine ISR.char flag = 0;char* display;short sensor1, sensor2;void ISR() {if (flag) {sensor1 = readSensor1();} else {sensor2 = readSensor2();}}int main() {// ... set up interrupts ...// ... enable interrupts ...while(1) {if (flag) {if isFaulty2(sensor2) {display = Sensor2 Faulty;}} else {if isFaulty1(sensor1) {display = Sensor1 Faulty;}}flag = !flag;}}Functions isFaulty1() and isFaulty2() check the sensor readings for any discrepancies, returning 1 ifthere is a fault and 0 otherwise. Assume that the variable display defines what is shown on the monitorto alert a human operator about faults. Also, you may assume that flag is modified only in the body ofmain. Answer the following questions:a) Is it possible for the ISR to update the value of sensor1 while the main function is checking whethersensor1 is faulty? Why or why not?b) Is it possible for the ISR to update the value of sensor2 while the main function is checking whethersensor2 is faulty? Why or why not?c) Suppose a spurious error occurs that causes sensor1 or sensor2 to be faulty for one measurement.Is it possible that this code would not report “Sensor1 faulty” or “Sensor2 faulty”? Please explainyour answer.d) Assuming the interrupt source for ISR() is timer-driven, what conditions would cause this code tonever check whether the sensors are faulty?转自:http://www.3daixie.com/contents/11/3444.html

你可能感兴趣的:(讲解:CPEG 222、Java,c/c++、Python、canvasPython|Proces)