Vous êtes sur la page 1sur 9

Test (Labs 1 and 2) Part 1 1. What is the function of the small switch module used in Lab 1?

Answer: reset system 2. What does TBDML stand for? What is the function of the TBDML programming cable in the experiments? Answer: TBDML = Turbo Background Debug Mode Light Interface between the Debugger running on the PC and the BDM hardware build in to the microcontroller being debugged (to download and debug the software)/connect to the board using Freescale. 3. List two microcontroller chips used on your board. Answer: 9S12C32 and AT89C2051 4. List the frequency of the crystal used on your board and determine the duration of one execution cycle. Answer: 8MHz and 250ns. 5. What is the function of the 74HC540 (octal inverting buffer/line drivers) on the LED and die module? Answer: drive the LEDs 6. What is the function of the RS232 interface on the microcontroller module? Answer: serial communication between the board and PC. 7. Refer to the circuit diagram of the microcontroller chip used in the experiments in the following page. (i) List the ports that are available for use as ordinary input/output ports. (ii) List the functions/applications of the ports in (i) besides acting as input/output ports. Answer: (i) Port A, B, AD, E, M, S, P, T (ii) Ports A and B multiplexing address/data lines & digital input/output port Port AD analog input for analogue-to-digital conversion Port E for bus control signal (E-clk) and interrupt service request signals (XIRQ and IRQ) Port M BDLC (byte data link communications) module that provides access to an external serial communication multiplex bus. Port S 8-bit interface to standard serial interface and serial peripheral interface. Port P pulse width modulation channels Port T timer input capture and output compare 8. 9. 10 Which type of C language is used in the experiments? Answer: ANSI C Name the Integrated Development Environment (IDE) used in the embedded system of this subject. Answer: Freescale Codewarrior. List the set of languages supported by the IDE used in this subject. [1 Mark] [3 Marks]

[2 Marks] [2 Marks]

[1 Mark] [1 Mark]

[4 Marks] [8 Marks]

[1 Mark] [1 Mark] [2 Marks]

. 11 . 12 . Answer: C or C++ and Assembly Is the Linker used in Absolute Assembly or Relocatable Assembly? What is the Linker used for? Answer: Relocatable Assembly. It is used to link multiple assembly source files. Which target(s) would you choose to test your program if the board is not available or download? (Choose from Full Chip Simulation, P&E Multilink/Cyclone Pro, SofTec HCS12, Abatron BDI, HCS12 Serial Monitor, TBDML) Answer: Full Chip Simulation What is the function of the Make button, which you always press when simulating/debugging your code? Answer: Generate the machine code. (i) Which memory model is often selected when creating a new project in this subject? (ii) If the code and data of a project exceeds 64k bytes, should this memory model still be used? Explain briefly why. Answer: Small. No, because the Small memory model can only accommodate 64kbytes. What is the start address (memory location) of the main function? Briefly describe the step(s) taken to verify this answer. Answer: C000. By debugging/single-stepping through the program. Briefly describe how you can ensure if the accelerometer on the voltage module is working properly. Answer: Apply a HIGH to the test pin of the accelerometer and check if the status pin is providing a HIGH vice versa. List the file that must be included to allow serial communication or characters to be display on the terminal program (such as hyper terminal or OC_Console). Answer: termio.c/TermIO.h List the header file that must be included to allow printf( ) to be used in the main program written in C. Answer: stdio.h What are the functions of the BDM interface? Answer: BDM allows the debugger running on the PC to download code and data to the Flash memory of the target microcontroller. Where is the embedded systems program code located in the memory map? Why? Answer: ROM. Because it must be there when the power is on. How does an absolute program differ from relocatable program? Answer: The absolute program has all functions in one source file. The relocatable program has modules developed independently of each other and then combined to create the final program. Which type of memory (RAM or ROM) is used to act as the stack for the [2 Marks]

[1 Mark]

13 . 14 .

[1 Mark] [1 Mark] [2 Marks]

15 . 16 . 17 . 18 . 19 .

[3 Marks] [3 Marks]

[1 Mark]

[1 Mark] [2 Marks]

20 . 21 .

[2 Marks]

[3 Marks]

22

[1 Mark]

. 23 .

9S12C32? Answer: RAM Draw the programming model of the microcontroller used in this subject. Answer: Accumulator A, B (D), index register X, Y, Stack Pointer, Program Counter and Condition Code Register.

[4 Marks]

Part 2 1. An analog-to-digital converter (ADC) uses 16 bits to represent the digital output and allows a full range of 3.3V. (i) Calculate the resolution of the ADC. (ii) Determine the expected digital word produced by the ADC if it is supplied an analog voltage of 0.5V. Answer: 3.3V = 5.0355 105V (i) Re solution = 16 2 1 0.5V = 9929.54 9930 5 (ii) 5.0355 10 V 2. 3. 4. 9930 = 26CAH = 0010 0110 1100 10102 How many analog input channels does the 9S12C32 ATD support? Answer: 8 Where/Which pins should the analog input signals be connected to if analogto-digital (ATD) conversion is performed using the 9S12C32? Answer: PAD0 PAD7 What are the functions of VRH and VRL in the ATD process? Answer: VRH is for the high analog voltage level and VRL is for the low analog voltage level. Difference between the two = full input span. What is the function of the analogue multiplexer in the ATD? Answer: allowing multiple analog signals to be connected to a single analog-to-digital converter. List the registers (control registers) involved in 9S12C32s analog-to-digital (ATD) conversion. Briefly describe what they are used for. Answer: ATDCTL2 power, hardware trigger & interrupts ATDCTL3 sequence length, FIFO and debug control ATDCTL4 resolution and speed ATDCTL5 format, mode and sequence length ATDDIEN used to enable digital use of the port pins. ATDSTAT0 status or sequence complete flag (SCF) o ATDSTAT1 flags for individual conversion (multiple analog input)= case) ATDDR Results registers. o Port AD analog input Write the instruction in C to turn on (or power up) the analog-to-digital converter. Then re-write the instruction in assembly language. Answer:

[2 Marks] [3 Marks]

[1 Mark] [1 Mark]
[3 Marks]

5. 6.

[1 Mark]
[7 Marks]

7.

[3 Marks]

ATDCTL2 = 0x80; ATDCTL2 EQU $0082 movb #$80, ATDCTL2 Write the instruction in C to initialise the analog-to-digital converter to do one conversion only. Then re-write the instruction in assembly language. Answer: ATDCTL3 = 0x08; ATDCTL3 EQU $0083 movb #$08, ATDCTL3 Write the instruction in C to initialise the analog-to-digital converter to achieve the shortest analog conversion time and uses 10 bits to represent the digital output. Then re-write the instruction in assembly language. Answer: ATDCTL4 = 0x00; ATDCTL4 EQU $0083 movb #$00, ATDCTL4 List one way to begin an ATD conversion. Answer: By writing to ATDCTL5 Which bit is used and how is it initialised to produce right justified results? Answer: DJM = 1. Which bit is used and how is it initialised to do a single conversion sequence? Answer: SCAN = 0 Which bit is used and how is it initialised to sample only one channel? Answer: MULT = 0 Which bits are used and how are they initialised to convert the analog signal on channel 2? Answer: ATDCTL5 =0x02; Note: CC:CB:CA = 010 How do you know when the conversion is finished? Answer: The Sequence Complete Flag (SCF) bit can be polled/checked to see if it is set. Draw the 16-bit A/D result register and show how the bits are organized in the register if the ATD result format is 10-bit, left justified. Answer:

8.

[3 Marks]

9.

[4 Marks]

10 . 11 . 12 . 13 . 14 .

[1 Mark]

[2 Marks]

[2 Marks]

[2 Marks]

[2 Marks]

15 . 16 .

[1 Mark]

[3 Marks]

17 .

Write the instruction sequence in C that allows the ATD result register to be shown in the Data1 window when single-stepped.

[2 Marks]

Answer: typedef unsigned int U16; #define ATDDR ((volatile U16*) 0x090) Are the DDRAD bits set or reset (0) to input digital data? Answer: Reset Are the ATDIEN bits set or reset to input digital data? Answer: Set How is the flag cleared when the ATD conversion is completed? Answer: cleared by reading from the result registers. Given the following codes, #define BIT2 4 #define BIT3 8 . . . ATDDIEN |= BIT2|BIT3; is Port AD used as an analog input or a digital input? Explain. Answer: Both. For Port AD bits to act as digital input, the respective bits in ATDDIEN must be = 1. BIT2|BIT3 = 0000 0100|0000 1000 = 0000 1100 ATDDIEN |=BIT2|BIT3 ATDDIEN = ATDDIEN |BIT2|BIT3 Ensures bit 2 and bit 3 of ATDDIEN are set to 1 enable bits 2 and 3 of Port AD to be used as digital inputs. 21 . Figure 2 shows the connection used to interface the HC12 with the LCD module. Table 1 summarises the actions taken by LCD for different RS, R/W* and E values. PM0 PM1 PM2 HC12 PT.7-0 E Data.7-0 LCD Module Figure 2 Table 1 R/W* RS

18 . 19 . 20 . 21 .

[1 Mark]

[1 Mark]

[1 Mark]

[3 Marks]

RS X L L H H (i) (ii) (iii) (iv) (v)

R/W* X H L H L

E L H H H H

Action none read from control register (read busy flag) write to control register (issue a command) read from data register (from display or character RAM) write to data register (to display or character RAM)
[2 Marks]

How would you test the LCD module to know if it is working without using a program? What is the function of Port T? What is the function of PM0, PM1 and PM2? Which bit is involved in handshaking between HC12 and LCD? The codes used to initialise the LCD is (as part of initLCD()) is given below. delay (15 /*ms*/); outControl(0x30); delay (5 /*ms*/); outControl(0x30); delay (1 /*ms*/); putCommand(0x30); putCommand(0x3C); putCommand(0x08); putCommand(0x01); putCommand(0x0F); putCommand(0x06); Why does the LCD need to be initialised? Refer to Table 2 and the codes above, state the font size used to display characters on the LCD. Refer to Table 2 and the codes above, will the cursor shift left or right after displaying a character? Write an instruction (like the ones above) to position the cursor at the beginning of the second line. Write an instruction to use 1 line, 5x7 font and 4-bit mode. Draw the hardware configuration if this instruction is to be used. Write a brief sequence to describe/tell me what you are supposed to do in Part 5 of Lab 2. You do not have to write out the whole program. Give 3 suggestions to improve your Part 5 of Lab 2.

[1 Mark] [1 Mark] [1 Mark]

a. b. c. d. e. f. g. (i) (ii) (iii) (iv) (v)

[1 Mark] [1 Mark] [1 Mark] [2 Marks] [5 Marks] [4 Marks] [3 Marks]

Supply 5V and see if the first line of the LCD is highlighted (actually black rectangles will appear on the first if the device is ok). Adjust the contrast if necessary. Provide instructions or display data to the LCD. These are used to provide control signals to the LCD. Bit 7.

a. So that the LCD knows how and where the characters should be displayed. b. putCommand(0x30) 5x7 font size putCommand(0x3C) 5x10 font size c. shift right d. putCommand(0x46) e. putCommand(0x20) L = 0; 1 line, N = 0; 5x7 font F = 0; 4-bit mode. hardware configuration for 4-bit mode. PM0 PM1 PM2 HC12 PT.7-4 E Data.7-4 LCD Module f. See Lab 2 g. Turning the cursor off can improve the display by reducing flicker, code to test the accelerometer before use in your program and report any malfunction, use interrupts instead of polling. Table 2 Action Clear display and return cursor to home position (top left) Returns the cursor to the home position. Returns shifted display to original position. Contents of display RAM is unaffected. Set the cursor move direction (I=0 to right, I=1 to left) Control whether display shifts (S=0 no shift, S=1 shift) These actions happen during writes to the display RAM Display, cursor and blink on/off (D=0 display off, D=1 display on) (C=0 cursor off, D=1 cursor on) (B=0 cursor blink off, B=1 cursor blink on) Move cursor or display (S=0 cursor move, S=1 display move) (R=0 shift to left, S=1 shift to right) Display function set (L=0 4-bit data bus, L=1 8-bit data bus) (N=0 1-line display, N=1 2-line display) (F=0 5x7 font, F=1 5x10 font) R/W* RS

Value 00000001 0000001000001IS 00001DCB

Execution Time 1.64 ms 1.64 ms 40 us 40 us

0001SR-001LNF--

40 us 40 us

01aaaaaa

1aaaaaaa

Sets character generator RAM address (aaaaaa = address to set) After this instruction, writes to the data register, access character generator RAM Sets display RAM address (aaaaaa = address to set) After this instruction, writes to the data register, access display RAM. This instruction may be used for gotoXY(). Table 3

40 us

40 us

Display Col => Row 0 Row 1

0 00 40

1 01 41

2 02 42

3 03 43

14 0E 4E

15 0F 4F 10 50 11 51 24 64 25 65 26 66 27 67

Vous aimerez peut-être aussi