ECET 340 All Homework 1-6schoolbench
Page 252, problem 1-5
1.Indicate what data type you would use for the following variables:
(a) The temperature
(b) The number of days in a week
(c) The number of days in a year
(d) The number of months in a year
(e) The counter to keep the number of people getting on a bus
(f) The counter to keep the number of people going to a class
(g) An address of 64K RAM space
(h) The age of a person
(i) A string for a message to welcome people to a building
2.Give the hex value that is sent to the port for each of the following C statements:
3.Give two factors that can affect time delay code size in the HCS12 microcontroller.
4.Of the two factors in Problem 3, which can be set by the system designer?
5.Can the programmer set the number of clock cycles used to execute an instruction? Explain your answer.
Page 430-431, problem 1-9, 21-25
1.The LCD discussed in this section has ____ (4, 8) data pins.
2.Describe the function of pins E, R/W, and RS in the LCD.
3.What is the difference between the VCC and VEE pins on the LCD?
4.“Clear LCD” is a __ (command code, data item) and its value is __ hex.
5.What is the hex value of the command code for “display on, cursor on”?
6.Give the state of RS, E, and R/W when sending a command code to the LCD.
7.Give the state of RS, E, and R/W when sending data character ‘Z’ to the LCD.
8.Which of the following is needed on the E pin in order for a command code (or data) to be latched in by the LCD?
(a) H-to-L pulse
(b) L-to-H pulse
9.True or false. For the above to work, the value of the command code (data) must already be at the D0–D7 pins.
21. In reading the columns of a keyboard matrix, if no key is pressed we should get all ___ (1s, 0s).
22. In Figure 12-6, to detect the key press, which of the following is grounded?
Pages 402-403, problems 1, 3, 6, 7, 10, 12, 13, 14, 27, 36, 55
1. Which technique, interrupt or polling, avoids tying down the microcontroller?
3. In the HCS12, what memory location in the interrupt vector table is assigned to Reset?
6. What memory address in the interrupt vector table is assigned to IRQ?
7. What memory address in the interrupt vector table is assigned to XIRQ?
10. How many bytes of address space in the interrupt vector table are assigned to each interrupt?
12. With a single instruction, show how to disable all the peripheral interrupts.
13. With a single instruction, show how to enable the XIRQ interrupt.
14. True or false. Upon reset, all interrupts are enabled by the HCS12.
27. Assume that the I bit for external hardware interrupt IRQ is enabled and is low-leveltriggered. Explain how this interrupt works when it is activated. How can we make sure that a single interrupt is not interpreted as multiple interrupts?
36. Explain the difference between the low-level and edge-triggered interrupts.
55. Explain what happens if both IRQ and XIRQ are activated at the same time.
Pages 323-325, problems 1-7, 10a, 20, 25, 29, 32
1.How many free-running timers do we have in the HCS12?
2.TCNT of the HCS12 is ____-bit.
3.For accurate reading, the TCNT is accessed as (8-bit, 16-bit).
4.The free-running timer supports a highest prescaler value of ______.
5.The free-running timer supports a lowest prescaler value of ______.
6.Which register holds the TOF?
7.How do we enable the free-running timer?
10. Find the frequency and period used by the free-running timer if the crystal attached to the HCS12 has the following values:
(a) XTAL = 4 MHz
20. Assume that XTAL = 4 MHz. Find the value needed to generate a time delay of 5 ms. Use the largest prescaler possible.
25. Program channel 2 for Output Compare to generate a square wave of 1 kHz with 50% duty cycle. Assume that XTAL = 4 MHz.
29. Explain the role of the TIOS register for the Input Capture function.
32. Explain the role of TCTL3 and TCLT4 in Input Capture function programming.
Page 324, problems 46, 48
46. For the PAC1 counter, which pin is used for the input pulse?
48. Program PACA to be an event counter. Use 16-bit mode, and display the binarycount on PORTB and PORTA continuously. Set the initial count to 20,000.
Page 467, review questions 1-4
1.In a DAC, input is __ (digital, analog) and output is __ (digital, analog).
2.In an ADC, input is _ (digital, analog) and output is __ (digital, analog).
3.DAC0808 is a(n) __-bit D-to-A converter.
(a) The output of DAC0808 is in __ (current, voltage).
(b) True or false. The output of DAC0808 is ideal to drive a motor.
Page 469, problems 55-60
55.True or false. DAC0808 is the same as DAC1408.
56.Find the number of discrete voltages provided by the n-bit DAC for the following:
(a) n = 8
(b) n = 10
(c) n = 12
57.For DAC1408, if Iref = 2 mA, show how to get an Iout of 1.99 when all inputs are HIGH.
58.Find the Iout for the following inputs. Assume Iref = 2 mA for DAC0808.
59.To get a smaller step, we need a DAC with _ (more, fewer) digital inputs.
60.To get full-scale output, what should be the inputs for DAC?
Pages 467-468, problems 1, 5, 11, 12, 35, 38
1. True or false. Sensor output is in analog.
5. True or false. An ADC with 8 channels of analog input must have 8 pins, one for each analog input.
11. Which of the following ADC sizes provides the best resolution?
(e) They are all the same.
12. In Problem 11, which provides the smallest step size?
35. With Vrh = 2.56 V and Vrl = Gnd, find the Vin for the following outputs:.
(a) D9–D0 = 1111111111 =
(b) D9–D0 = 1000000001 =
(c) D9–D0 = 1100110000 =
38. How do we start conversion in the HCS12?
Page 355 problems 3, 4, 6, 12
3.Show the framing of the letter ASCII ‘Z’ (0101 1010), no parity, 1 stop bit.
4.If there is no data transfer and the line is high, it is called ____ (mark, space).
6. Calculate the overhead percentage if the data size is 7, 1 stop bit, no parity.
12. State the absolute minimum number of signals needed to transfer data between two PCs connected serially. Give their names.
Page 529 problems 1-5
1.True or false. The SPI protocol writes and reads information in 8-bit chunks.
2.True or false. In SPI, the address is immediately followed by the data.
3.True or false. In an SPI write cycle, bit A7 of the address is LOW.
4.True or false. In an SPI write, the LSB goes in first.
5.State the difference between the single-byte and burst modes in terms of the CE signal.
Page 535 problems 1-4
1.True or false. In the HCS12, we have at least two sets of SPI modules.
2.True or false. The SPIxBR register is used for setting SCLK speed.
3.True or false. In the HCS12, the highest SCLK is BusFreq/2.
4.True or false. In transferring data, the use of SPISR is optional.