Instructions: This is an open book, do-at-home quiz. You must hand-write your solution to this quiz on A4 papers with yo
Posted: Mon May 02, 2022 2:38 pm
Instructions: This is an open book, do-at-home quiz. You must hand-write your solution to this quiz on A4 papers with your name and SID on top of each page of the paper. Pages without name and SID will not be marked. Scan / snapshot your solution clearly, and save it as one PDF file with your Student ID (SID) as filename. For example, for a student with SID of EE0101928, then the PDF file should be named EE0101928.pdf. Submit your solution online to Moodle before the deadline of 11:59 pm, 27th April 2022. Question: As shown in Figure 1, a PIC18 is connected to two push buttons (S1 and S2), five LEDs (DO to D4), and a 4-pin DIP switch (DSW). U1 ARCUS ROTOTI CUTNOS R1 R2 AN LAGOVNE RAM RIVRES RAIRE RA RADIANTE CORO ROSSG WORDS RADO RODOK NOTRKOT D1 RS HHLPA ROCANT RAPPRECOPIA REANU ROUP OSPIPID PGC - Hà RECORD DO 02 RO LEDED DS R10 LEDED D4 R11 CERED R? hane | Figure 1 Schematic for Quiz 5.
Write a PIC18 assembly program to perform the following: At the main program: a) Configure the parallel ports, and initialize the four LEDs DI to D4 to turn on at start, while LED DO is to be turned off. b) Configure and enable S2 as low priority interrupt. c) Poll for S1 to be pressed – as long as Si is not pressed, LED DO should remain off. d) When SI is pressed, turn on LED DO, and turn off all LEDs from D1 to 04. e) Repeat (e) and (d) forever. When the interrupt is triggered from S2, interrupt service routine (ISR) for S2: a. Clears interrupt flag. b. Turns off LED DO. c. Reads the values of DSW and displays the status of each switch at the four LEDs (DI to D4). For instance, the status read from DSW at RCO should be displayed to LED DI, at RCI to LED D2, at RC2 to LED D3 and at RC3 to LED D4. d. After that, the ISR returns from interrupt. The main program should start at address 0x000200. The ISR for S2 should start at address 0x001000 and should be named S2_ISR.
Write a PIC18 assembly program to perform the following: At the main program: a) Configure the parallel ports, and initialize the four LEDs DI to D4 to turn on at start, while LED DO is to be turned off. b) Configure and enable S2 as low priority interrupt. c) Poll for S1 to be pressed – as long as Si is not pressed, LED DO should remain off. d) When SI is pressed, turn on LED DO, and turn off all LEDs from D1 to 04. e) Repeat (e) and (d) forever. When the interrupt is triggered from S2, interrupt service routine (ISR) for S2: a. Clears interrupt flag. b. Turns off LED DO. c. Reads the values of DSW and displays the status of each switch at the four LEDs (DI to D4). For instance, the status read from DSW at RCO should be displayed to LED DI, at RCI to LED D2, at RC2 to LED D3 and at RC3 to LED D4. d. After that, the ISR returns from interrupt. The main program should start at address 0x000200. The ISR for S2 should start at address 0x001000 and should be named S2_ISR.