You are on page 1of 8
EEEB373, Semester Il, 2018/2019 QUESTION 1 [10 marks] (a) Refer to Table 1.1 and Table 1.2. Fill in ONE (1) addressing mode and show the content of WREG and STATUS register after each instruction is executed. The content of the memories are as Table 1.1. [6 marks] | Address Data [| ox10 A2|21| D4} 77 | 3A | 25 | 00 | 48} CC) 4E] 11 | 02) 21 | AD | 69 | 00 | 0x20 20 | 30 | 52.| 8B | 44 | 62 | 9A | 06 | 09 | 07 | 34| 00 | 2A | 64 | 00 | O1 Table 1.1 Assembly code | Addressing mode | WREG STATUS N}ov|z]|pc|c Initial condition - 4B} 1} oj}oloj1 iorlw D’ 28 mulwf D/36’,A mov£f PRODL, WREG decf D’17',F,A Table 1.2 (QUESTION 1(a): Please detach this page from the question paper and attach to- gether with the answer booklet) Write your Student ID Number : (b) Write an instruction sequence to divide the data at file register 0x43B by 8. [4 marks] Page 2 of 9 QUESTION 2 [20 marks] EEEB373, Semester Il, 2018/2019 (a) Twenty-four temperature data points were collected and stored in program memory as shown in Figure 2.1, Write a program to process the data points to count the total number of temperature data points which had exceeded the temperature threshold of 25°C. The result should be stored in data memory location 0x010 labelled as RESLT. Include the ‘temperature data points in your program. Temp-data DB 0x16,0x15,0x19,0x1,0x1C,0x18 DB Ox18,0%19,0x15,0x18,0x15,0x16 DB 0x16 0217 Ox1A, 0x12 031,018 DB Ox19,0x18,0x16,0x15,0x14,0x18 Figure 2.1 [14 marks] (b) Given the incomplete delay subroutine below, write a complete subroutine to create a time delay of 20ms on a PICI8F4550 using program loops, Assume the crystal frequency is 20MHz. Show ALL your calculations. {6 marks] delay NOVLW MOVW Repeat, bEecrsz BRA RETURN + COUNTER, A jincompiete Hincomplete sincomplete jincomplete COUNTER, FA Repeat Page 3 of 9 EEEB373, Semester Il, 2018/2019 QUESTION 3 _ [20 marks] (a) Write an instruction sequence to initialize high nibble as input pins and low nibble as output pins of PORTD. [2 marks] (b) Refer to Figure 3.1 and Program 3.2. Program 3.2 is supposed to turn on both LEDs when S1 is closed. Troubleshoot and identify TWO (2) mistakes and propose mitigation action. [4 marks] mn, or UL 4 afiees orem ra bye ‘ere re qx bode % 4 SS 4 weet 4 rcrmevor pat = oopsrocine Lt epee oe 2 J renre Boeck Heer ere be ER cam souteies HES mies Ce ae Sears ce a=. Seas ies merous lt /]Rt mengtowe tt [|B sess Pit Figure 3.1 Schematic diagram for Question 3 1 [#inciude 2 org 0x00 3 goto main 4 org 0x08, 5 retfie 6 org OxI8, 1 retfie 8|main movlw 0x0 9 movwf TRISD,A 10 bsf —-TRISD4,A 11 |upl —movw£ = PORTC\A Jagain btfsc FORTD,2,A B bra uel 4 movlw 0x06 15 movwi PORTC,A 16 bra again 0 end Program 3.2 Page 4 of 9 © @ EEEB373, Semester Il, 2018/2019 A push button SW1 is connected to bit 5 of PORTC and EIGTH (8) LEDs is connected to PORTB. Draw the schematic diagram and write a program to OFF all LEDs when SW1 is closed. Otherwise, all LEDs are on. {7 marks] Refer to Figure 3.3. A push button ($1) is connected to bit 0 of PORTB, a 4-pin DIP switch (DSW1) is connected to bit 0 through 3 and seven segment display (SSD) is connected to bit 4 through 7 of PORTD. Write a program to monitor $1, When S1 is closed, 4 bit data is read from DSW and send to SSD. (7 marks] marae HE He saronce Le sso Figure 3.3 Page 5 of 9 EEEB373, Semester Il, 2018/2019 QUESTION 4 [20 marks] (a) Asasystem designer for DVD player, which technique between polling method and inter- rupt will you choose to receive command codes from remote control? Which justification of your choice. [3 marks] (b) What is the difference between maskable interrupt and nonmaskable interrupt? [3 marks] (©) Referring to Figure 4.1, write an instruction sequence to fully setup INTO and INT] for interrupt application. Requirement for the configuration are as below: 1. Both pins will require a rising edge pulse 2. INT! to be used as low priority interrupt. Figure 4.1 [5 marks] (@)_ Refer to Figure 4.1, when switch X is closed, which interrupt is expected to be called? Justify your answer. [4 marks] (©) What does the count in a timer represent? List and briefly explain TWO (2) applications that using timer, [5 marks] Page 6 of 9 EEEB373, Semester Il, 2018/2019 QUESTION 5_ [30 marks] (a) Study the schematic diagram in Figure 5.1. The seven segment display (SSD1) is connected to PORTC. Two button switches, $1 and S2 are connected to interrupt source INT2 and INTI, respectively. Complete the program shown in Figure 5.2 by answering the following questions: @ (i) (iii) (iv) 3801 Figure 5.1 Schematic diagram for Question 5 Set high priority interrupt vector to INT] and low priority interrupt vector to INT2 [2 marks] Configure INT! to high priority interrupt and INT2 to low priority interrupt [5 marks] Create delay subroutine using TIMERO to provide suitable delay so that SSD1 dis- plays output according to Figure 5.3. [6 marks] Complete the interrupt service routine (ISR) so that when SI is pressed, SSD1 will display only even numbers, from 0 to 8 in sequence one time. When S2 is pressed, SSDI will display 9 for 2 seconds. [9 marks] Page 7 of 9 SBBYRRRBRYBSSIRRESS I Semi sueune 31 2 33 35 37 EEEB373, Semester Il, 2018/2019 #includecp18£458. inc> org 0x00 goto start @ start clré TRISC,A clrf — FORTC,A Ga) movlw upper data movwf TBLPTRUA movlw high data movwf TBLPTRH.A movlw low data movw= TBLPTRL.A movlw D"10" movwf 0x10,A again tbirdet movif TABLAT,PORTC call delay movf TBLPTRL,WA eptseq 0x10, bra again movlw low data movwf TBLPTRLA bra again delay (iii) Interrupt service routine Gv) ssd_num db 0x3F 0x06 ,0x5B,0x4F ,0%66,0%6D ,0%7D,0%07 Ox7F ,0x6F ap 077 070,039 ,0x5E,0%79,0x71 end Program 5.2 Source code of the program for Question 5 Hic 61 i | 0 Figure 5.3 Change of seven segment display over time Page 8 of 9 EEEB373, Semester Il, 2018/2019 (v) The program source code in Figure 5.2 however have a bug. Troubleshoot and rectify the problem [2 marks] (b) Sketch the output of word "YA’ when it is transmitted using the format of one start bit, eight data bits and one stop bit, The ASCII code of letter Y and A is 0x59 and Ox41, respectively. [2 marks] (©) Consider the following schematic diagram. Determine the corresponding voltage value when the content in ADRES is 0x3F2. av [4 marks] - END OF QUESTION PAPER - Page 9 of 9

You might also like