Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Homework #6 Due: November 4 9 am Reading: Chapter 11, Section 12.4, and Lecture Slides Solutions When code is requested, include actual .s file. State whether this code has been assembled and run successfully. 1. Using SysTick interrupts, write a program that toggles between red and green LEDs every 0.5 seconds. Use bit-specific addressing for GPIO and index addressing for GPIO and SysTick Registers. Note that GPIO_PORTF_BASE should equate to 0x40025000 and SysTick_BASE should equate to 0xE000E000. 2. Give one example each for what might be a possible application of GPTM used to (a) measure a pulse’s frequency, (b) create a pulse train of a specific frequency, (c) count pulses in the edge pulse mode, and (d) create a PWM signal. a) Measure a pulse’s frequency. Timer organization and counting modes can be a possible application of GPTM used to measure a pulse’s frequency. b) Create a pulse train of a specific frequency Setting output mode can be a possible application of GPTM used to create a pulse train of a specific frequency. For example, in High Mode (001), when meet CCR, it will always be a high voltage c) Count pulse in the edge pulse mode The Time Counter can be a possible application of GPTM used to count pulse in the edge pulse mode. The period is determined by the clock frequency, so whenever it meets the edge, the counter will automatically add one. d) Create a PWM signal Creating PWM by microprocessor can be used to control the rotating rate of the motor, because different duty cycle of PWM represent different energy intensity that can control the power of the machine. 3. The General Purpose Timer Module Prescale register is set to 0x0F, and the system clock runs at 80 MHz. Regarding an input signal, on its rising edge, followed by the next falling edge, followed by the next rising edge, GPTMTAR register values of 1134, 22121, and 49786 respectively are captured. What is the frequency of the free-running timer clock? What is its period? What is the pulse width of the input signal? What is its period? What is its frequency? What is it's duty cycle? What is the lowest frequency input signal that can be measured without accounting for wraparound of the timer module clock? Prescale: b’00001111 = 15+1=16 Freq = 80MHZ/16=5MHZ Period = 200ns Pulse_Width = (22121-1134) * 200ns= 4.197ms Period_time = (49786-1134)*200ns = 9.7304ms Frequency = 1s/period = 102.771HZ Duty Cycle = 4.197ms/9.7304ms = 43.133% Wraparound time = 200ns * 2^16 = 13.107ms Lowest Freq = 1s/13.107ms = 76.30HZ 4. Convert pi to Q8.8 format. Value = I*2^-8 I = 804 I/256 = 3.140625 0.140625 =X*2^-8 X = 36 So Pi(Q8.8) = 00000011.00100100 5. Convert (a) pi to IEEE 754 format and (b) 0xB1E44000 from IEEE 754 format.. (a) Exponent: 10000000 Fraction: 0.5708*2 = 1+0.1416 0.1416*2 = 0+0.2832 0.2832*2 = 0+0.5664 … Pi = 0 10000000 10010010000111111011011 Or 0x40490fdb (b) 0xb1e44000 = 10110001111001000100000000000000 S=1, exponent =99-127 =-28 Fraction = 2^-1 + 2^-2 +2^-5 +2^-9 =0.783203 Number = (-1)*(1+0.783203)(2^-28) = -6.6429493E-9