Sie sind auf Seite 1von 3

PROBLEMS SECTION 9. 1: FREE-RUNNING TIMER AND OUTPUT COMPARE FUNCTION 1. 2. 3. 4. 5. 6. 7. 8. 9. 10.

How many free-running timers do we have in the HCS12? 1 TCNT of the HCSI2 is ___ -bit. 16 For accurate reading, the TCNT is accessed as (8-bit, 16-bit). 16-bit The free-running timer supports a highest prescaler value of 128 The free-running timer supports a lowest prescaler value of 1 Which register holds the TOF? TFLG2 register How do we enable the free-running timer? Setting to a high value the bit 7 of register TSCR1 True or false. The TEN bit is part of the TSCR1 register. TRUE Find the TSCR2 value for no prescaler, no interrupt, count up during the freeze, and wait. TSCR2=0x00 Find the frequency and period used by the free-running timer if the crystal attached to the HCS12 has the following values? No prescaler is used a. Cirstalfeq = 4MHz Fbus= 4MHz/2 Fbus= 2MHz T= 1/Fbus T= 1/2MHz T= 0.5s b. Cirstalfeq = 8 MHz Fbus= 8MHz/2 Fbus= 4MHz T= 1/Fbus T= 1/4MHz T= 0.25s c. Cirstalfeq = 10 MHz Fbus= 10MHz/2 Fbus= 5MHz T= 1/Fbus T= 1/5MHz T= 0.2s How many Output Compare channels do we have in HCS12? Give the name of the TCx register for each channel and the output pin associated with it. Eigth channels,TC0 for PT0, TC1 for PT1, TC2 por PT2, TC3 por PT3, TC4 por PT4, TC5 por PT5, TC6 por PT6, TC7 por PT7 Indicate the rollover value (in hex and decimal) for the 16-bit free-running timer. It goes from 0xFFFF (65535 decimal) to 0x0000 (0 decimal) Explain the role of the TCx register in the Output Compare function and how the CxF flag is raised. Is required for the functioning of both input-capture and output-compare functions. The user must access this register in one access rather than two separate accesses, to its high byte and low byte. setting TFFCA raises the flag.

11.

12. 13.

14. True or false. TCNT has its overflow flag. TRUE 15. True or false. Each Output Compare channel has its own match flag. TRUE 16. The selection of Output Compare/Input Capture function is done by manipulating the bits of the _________ register. TIOS 17. Explain the role of TCTL1 and TCTL2 in the Output Compare function. The user chooses on program the action that is being to execute by the output-compare pin that was previously selected uses these two registers. 18. Assume that XTAL = 8 MHz. Find the value needed to generate a time delay of 5 ms. Use the largest prescaler possible. Prescaler = 128 N=(t*Fbus)/128 N=((5x10^-3)*(8MHz/2))/128 N=156.25 157 19. Assume that XTAL = 8 MHz. Find the value needed to generate a time delay of 5 ms. Use prescaler of 16. Prescaler = 16 N=(t*Fbus)/16 N=((5x10^-3)*(8MHz/2))/16 N=1250 20. Assume that XTAL = 4 MHz. Find the value needed to generate a time delay of 5 ms. Use the largest prescaler possible. Prescaler = 128 N=(t*Fbus)/128 N=((5x10^-3)*(4MHz/2))/128 N=78.125 79 21. Assuming that XTAL = 8 MHz, and we are generating a square wave on pin PB7, find the lowest square wave frequency that we can generate. Fe = 4MHz Ftcnt = 0.03125MHz TH * fe = 65535 TH = 2.07 seg T = 4.14 seg F = 0.2386 Hz The lowest frequency is given when the prescaler is 128 22. Assuming that XTAL = 8 MHz, find we are generating a square wave on pin PB2, find the highest square wave frequency that we call generate. Fe = 8MHz Ftcnt = 0.03125MHz TH * fe = 1 TH = 0.25seg T = 0.5 seg F = 2MHz Highest frequency is given when the presacler value is 1 23. Assuming that XTAL = 8 MHz, find the period of clock pulse fed to the TCNT if we use a prescaler of 4. T= 1s 24. Assuming that XTAL = 8 MHz, find the period of dock pulse fed to the TCNT if we use a prescaler of 64. T= 16s 25. Program channel 2 for Output Compare to generate a square wave of 1 kHz with 50% duty cycle. Assume that XTAL = 4 MHz.

26. Program channel 4 for Output Compare to generate a square wave of 1 kHz with 50% duty cycle. Assume that XTAL = 4 MHz. Use the largest prescaler possible. 27. Assuming that TCNT = FFF1H, indicate which states TCNT goes through until the overflow flag is raised. How many states is that? 15 28. Assuming that XTAL = 8 MHz, find the period of clock pulse fed to the TCNT for the following prescalers: a. 2 500ns b. 128 32s c. 8 2 s d. 16 4 s e. 32 8 s f. 64 16 s SECTION 9.2: INPUT CAPTURE PROGRAMMING 29. Explain the role of the TIOS register for the Input Capture function. The TIOS register selects how the channels act (Input Capture and Output Capture) 30. True or false. The Input Capture function can detect only the falling edge. FALSE 31. How many Input Capture channels do we have in HCSI2? Give the name of the TCx register for each channel and the input pin associated with it. In the HCS12 we have eight (8) channels TC0 IOC0 TC1 IOC1 TC2 IOC2 TC3 IOC3 TC4 IOC4 TC5 IOC5 TC6 IOC6 TC7 IOC7 32. Explain the role of TCTL3 and TCTL4 in Input Capture function programming. Those registers are used to select the type of edges that are going to be captured. 33. Explain the role of the TCx register in the Input Capture function and how the CxF flag is raised. a 16-bit register, is required for the functioning of all input-capture and output-compare functions. The user must access this register in one access rather than two separate accesses, to its high byte and low byte. Printing 1 in TFFCA raises the flag. 34. True or false. We can use a given TCx channel for both the Output Compare and the Input Capture function at the same time. FALSE 35. True or false. Each Input Capture channel has its own edge detect flag. TRUE 36. The selection of Output Compare/Input Capture function is done by manipulating the bits of the _______ register. Show how we select the Input Capture function for channel 3. TIOS TIOS &= ~ 0x08;