Study Guide for Microprocessors Exam 1


1) Suppose with have symbolic register names Reg1, Reg2, Reg3 . Write the corresponding PIC code to accomplish the following:

if (Reg1 > Reg2)
{       Reg3 = Reg3 +1; }
else
{       Reg3= Reg3+2;   }
Reg1=Reg1+2;

2) Suppose with have symbolic register names Reg1, Reg2. Write the corresponding PIC code to accomplish the following:

    Reg2=0
    for (Reg1=0 ; Reg 1< 10 ; Reg1 = Reg1+2)
    {
          Reg2=Reg2+Reg1;
    }

3) Write a PIC loop to add the contents of memory locations 0x20 , 0x22, 0x24, ........, 0x30. Your loop must use the INDF and FSR registers.


4) Write the PIC code that will set bit B0 through B3 of PORTB as input and pins B4 through B7 as output.

5) Write the PIC code that will branch to the label HERE if the carry bit is set and branch to the label THERE if the carry bit is clear.

6) Write a function/subroutine that causes a 100 microsecond delay. Call the subroutine Delay100. The subroutine may contain at most 4 NOPs. The time between the end of executing the statement at Label1 and the beginning of executing the statement at Label3 should be 100 microseconds.

Label1       MOVLW 0x1
Label2       CALL Delay100
Label3       MOVF   Goofy,f
   


7) Create the following embedded system:
Pin A7 of PORTA will be an input switch. An LED is hooked up to pin B7 of PORTB. When A7 is connected to ground, the LED on B7 is off. When A7 is connected to 5 volts, the LED on B7 is lit.  The switch employed should be a momentary switch which is normally open.

a) What is a momentary switch ? SPST ? What is meant by switch bounce ?
a) Provide the complete PIC code to accomplsih this
b) Provie the complete schematic diagram for this system. Your LED should be connected in series to a 300 Ohm resistor. Your pull up/push down resistor should be 5000 Ohms.