

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
A series of homework problems for eecs 203 students, focusing on programming the pic16c74a microcontroller. The tasks include identifying directives and instructions, analyzing potential dangers in instruction sequences, writing safe alternatives, and understanding the use of specific registers. Students are encouraged to use a pic assembler and simulator for verification.
Typology: Assignments
1 / 2
This page cannot be seen from the preview
Don't miss anything!


When you can verify an answer, do so. I encourage you to use a PIC assembler and simulator to help you verify your answers. Show your work.
clrf TRISA comf TRISA, F
(a) (5 pts.) Which of these are directives/pseudo-operations and which are instructions? (b) (5 pts.) Use a sentence to describe the overall effect of this instruction sequence. (c) (5 pts.) Assuming the output of a driver is connected to one of the pins on port a, why is this sequence of instructions potentially dangerous? (d) (5 pts.) If your processor is clocked at 3 MHz, what is the maximum duration of the dangerous condition? Please refer to the Architectural Overview section in the PIC16C74A datasheet. (e) (5 pts.) Write an instruction sequence that will safely accomplish the same thing as these potentially dangerous instructions. (f) (5 pts.) Rewrite your answer to question 1e, replacing all directives with genuine sequences of instructions. Please refer to the Status Register documentation in the PIC16C74A datasheet. (g) (5 pts.) Write the binary 14-bit opcode (including register specifiers) for each line of your answer to question 1f. Refer to the Table 15.2 in the PIC16C74A datasheet.
LOW_TICK equ 0x HIGH_TICK equ 0x
delay_loop: ; Wait for 30 ms to make sure switch bouncing is finished ; 2 MHz clock, about 2 us per normal instruction, 4 us per taken loop movlw d’30’ movwf HIGH_TICK
LONG_WAIT_LOOP
; Wait for approx. 1 ms SHORT_WAIT movlw d’100’ movwf LOW_TICK
; Loop body takes 10 us SHORT_WAIT_LOOP nop
nop nop decfsz LOW_TICK, F goto SHORT_WAIT_LOOP
decfsz HIGH_TICK, F goto LONG_WAIT_LOOP return
(a) (5 pts.) Why is this subroutine broken into two loops instead of using only one loop? (b) (10 pts.) Rewrite this subroutine such that, when called, it waits for 10 ms multiplied by whatever value was in the accumulator, W , when delay loop was called.