EECS 373 Lab 5 Inlab: Clocks, Timers, and Counters - Answer Sheet

Name and Unique Names

 

 

 

Look at the disassembly in <project_name>.lst file in the Debug folder. Find the assembly that was generated for the MYTIMER_enable(), MYTIMER_setOverflowVal(uint32_t value) , and MYTIMER_getCounterVal() functions. Map the generated assembly back to the C code in the functions.


void MYTIMER_enable()
{


    MYTIMER->control |= MYTIMER_ENABLE_MASK;


}

void MYTIMER_disable()
{


    MYTIMER->control &= ~MYTIMER_ENABLE_MASK;


}

void MYTIMER_setOverflowVal(uint32_t value)
{


    uint32_t * timerAddr = (uint32_t*)(MYTIMER);


    *timerAddr = value;


}

uint32_t MYTIMER_getCounterVal()
{


    uint32_t * timerAddr = (uint32_t*)(MYTIMER);


    return *(timerAddr+1);


}

 

 

 

Q: You can see that the numbers overflow after a certain amount of time. Measure that time using a stop watch and calculate the clock frequency. Write down your result. Does it agree with the frequency specified in the MSS Configurator Clock Manager block? Explain in two sentences and have your lab instructor sign off on your work.

 

 

 

Q: How does the latency compare to the latency measured with the oscilloscope in Lab 4? Explain in two sentences.

 

 

 

 

 

 

Add PWM capabilities to your timer library, and write an application that generates a PWM signal at 100Hz and changes the duty cycle from 0 to 100% over 1 second. Observe the signal on an oscilloscope and the LED. Describe your observation in a few sentences and include a screenshot of the oscilloscope.

 

 

 

Q: What do you observe between the synchronous and asynchronous capture values? Explain in a couple of sentences.

 

 

 

Write a small reaction game. At a specific time, using the PWM output, toggle the LED on. The user has to hit the push button when he sees the light turning on. Then, output the time difference between LED toggle and button push on the serial terminal. How good is your reaction time in seconds? Have your lab instructor sign off on your work.

 

 

 

Staff Signature for PostLab Demo