Sie sind auf Seite 1von 5

ENGR 270

Lab # 2
Input/Output and
Watchdog Timer Options
Joseph Liguid
Team:
Ron Cotton
Ivan Cruz
Date Completed:
7/21/15

Experiment 1

In this experiment, using the PICmicro and MPLab IDE we implemented and
tested a two-bit adder.
Disassembled Code
MPASM5.62/HOME/RONC/MPLABXPROJECTS/LAB2/L718201518:53:03PAGE1

LOCOBJECTCODELINESOURCETEXT
VALUE
00001;
00002;FILE:main.asm
00003;DESC:Lab2Input/OutputandWatchdogTimerOperation
00004;DATE:7/17/2015
00005;AUTH:LabGroup#18RonCotton,IvanCruz,JosephLiguidENGR270
00006;DEVICE:PICmicro(PIC18F1220)
00007;
00008
00009listp=18F1220;defaultprocessortarget
00010radixhex;setdefaultradixtohex
CF0F1E808103C0000011configWDT=OFF,LVP=OFF;disablewatchdogtimerandLVP
3E00340
00012;Info:
00013;PortB,Pin11LowVoltageProgramming
00014;OtherwaystodisableWDT:
00015;instructionCLRWDTClearwatchdog
00016;orbit0ofCONFIG2H=0
00017
00018#definePORTB0xF81
00019#defineTRISB0xF93
00020#defineADCON10xFC1
00021
0000008000022OP1equ0x080;OP1Operand1Input1(RB0&RB1)
0000008100023OP2equ0x081;OP2Operand2Input2(RB2&RB3)
0000008200024LASTequ0x082;LASTTemporaryWREGUsedfor
00025;ResultantValueandtodetectInput
00026;Change
00027
00000000028org0x000;Programcodestartsat0x000
00029
00030;BEGINInitialization
00031
0000006A8100032CLRFPORTB;PORTBValuestoZero
0000020E7F00033MOVLW0x7F;01111111valueforADCON1
0000046EC100034MOVWFADCON1;setA/DPINStodigital
0000060E0F00035MOVLW0x0F;00001111valueforTRISB
0000086E9300036MOVWFTRISB;SetTRISB1=Input,0=Output
00037;SetRB0RB3Input&RB4RB7Output
00038
00039;ENDInitialization
00040;
00000A00041Start:
00042;BEGINClearVariables
00043
00000A6B8000044CLRFOP1;OP1=0
00000C6B8100045CLRFOP2;OP2=0
00000E6B8200046CLRFLAST;LAST=0
00047
00048;ENDClearVariables
00049;
00050;BEGINGetSwitchInput
00051
000010CF81F08000052MOVFFPORTB,OP1;SetOP1=PORTB

MPASM5.62/HOME/RONC/MPLABXPROJECTS/LAB2/L718201518:53:03PAGE2

LOCOBJECTCODELINESOURCETEXT
VALUE
0000140E0300053MOVLW0x3;SetWREG=00000011
000016178000054ANDWFOP1;SetOP1=OP1ANDWREG
00055
000018CF81F08100056MOVFFPORTB,OP2;SetOP2=PORTB
00001C0E0C00057MOVLW0XC;SetWREG=00001100
00001E178100058ANDWFOP2;SetOP2=OP2ANDWREG
000020438100059RRNCFOP2;setOP2=OP2(ShiftRightx2)
000022438100060RRNCFOP2
00061;ENDGetSwitchInput
00062;
00063;BEGINAddOperands
00064
000024518000065MOVFOP1,0;SetWREG=OP1
000026258100066ADDWFOP2,0;SetWREG=WREG+OP2
0000286F8200067MOVWFLAST;SetLAST=WREG
00068
00069;ENDAddOperands
00070;
00071;BEGINOutputTotal
00072
00002A478200073RLNCFLAST;SetLAST=(ShiftedLeft)LAST
00002C478200074RLNCFLAST;(repeat5x)
00002E478200075RLNCFLAST;
000030478200076RLNCFLAST;"GettingLASTreadyforOutputto
000032478200077RLNCFLAST;PORTB"
00078
0000340EE000079MOVLW0xE0;SetWREG=11100000
000036178200080ANDWFLAST;SetLAST=LASTANDWREG
00081
000038C082FF8100082MOVFFLAST,PORTB;SetPORTB=LAST(OutputResulttoLEDS)
00083
00084;ENDOutputTotal
00085;
00086;BEGINCheckInputChange
00087
00003CCF81F08200088MOVFFPORTB,LAST;SetLAST=PORTB(SetInputstoLAST)
00004000089Wait:
00090
000040508100091MOVFPORTB,0;SetWREG=PORTB
000042198200092XORWFLAST,0;SetWREG=PORTBXORLAST
000044E0FD00093BZWait;IfnochangeinInputs,MovetoaddrWait
000046EF05F00000094GOTOStart;otherwise,GototheaddrStart
00095
00096;ENDCheckInputChange
00097END
MPASM5.62/HOME/RONC/MPLABXPROJECTS/LAB2/L718201518:53:03PAGE3

SYMBOLTABLE
LABELVALUE
ADCON10xFC1
LAST00000082
OP100000080
OP200000081
PORTB0xF81
Start0000000A
TRISB0xF93
Wait00000040
__18F122000000001
MEMORYUSAGEMAP('X'=Used,''=Unused)
0000:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0040:XXXXXXXXXX
0000:XXXXXXXXXXX
Allothermemoryblocksunused.

ProgramMemoryBytesUsed:85
ProgramMemoryBytesFree:4011
Errors:0
Warnings:0reported,0suppressed
Messages:0reported,0suppressed

Schematic

There were some issues that we had encountered during the lab:
Some of the shifting was miscalculated for OP2 resulting in errors in the return value. We had
also failed to store the value of PORTB to TEMP before checking the input change. In some
parts of the code the MOVFF commands were backwards. We also got Address not found for
breakpoint warnings for breakpoints where there was no code, placed NOP in certain blocks
of code to test values after commands have executed. The NOPs were removed when testing
was done.

Lessons Learned
The biggest items that I had learned doing this lab involved the usage of the pins on
the PIC18F1220, noticeably the TRIS, PORT, and ADCON; specifically how to use them
in the circuit and their locations in the memory. It was interesting how TRISA and
TRISBs output/input switch was determined by the value placed in their respected
locations.

New Experiment
518

Das könnte Ihnen auch gefallen