Vous êtes sur la page 1sur 6

TUTORIALFORCREATIONOFASSEMBLERPROJECTSFORPICs

USINGMPLABXV3.50
Author:Ing.JorgeHernandezAmbato,Ph.D.

1. Launchthedevelopmentapplicationfromdesktopicon:
2. InsidetheIDEprogram,intheFilemenu,selecttheoptionNewProject


3. ChoicetheoptionStandaloneProjectandmakeaclickinbuttonNext:


4. ChoicethePICtype(i.e.:16F877A)andmakeaclickinbuttonNext:


5. Choice the hardware tool Simulator in order to test the your programs inside virtual
simulatorsinthesameIDEandmakeaclickinbuttonNext:

6. ChoicethecompilatortoolforAssemblerandmakeaclickinbuttonNext:


7. EnterthenameoftheProject(i.e.:MyFirstAssembler)andchoicethedestinationfolderto
createtheprojectfiles.Lefttheotherconfigurationasbydefault.Afterthat,makeaclickin
buttonFinish:


8. Whenyouhavefinishedthewizardprojectcreation,theIDEwillshowyouthetreeproject,
whichisempty,andtheprojectdashboardasshowninthefigure:

9. Inordertoaddthesourceassemblercodeforyouproject,choicetheNewFileoptionin
theFilemenu:


10. In the dialog box appeared, choice the option Assembler in Categories box and
AssemblyFile.asminFileTypesbox.Then,makeaclickinbuttonNext:


11. Inthenextwindow,enterthenamefortheassemblerfile(i.e.:MyFirstIOHandleAssembler)
andmakeaclickinbuttonFinish:

12. Whentheassemblerfilehasbeencreated,copythenextcodeexampleinthemainwindow
file.


;**********************************************************
;STARTOFFIRSTASSEMBLERCODEFORCONFIGURATIONOFIOPORTSOFAPIC16F877A
;**********************************************************
__config_LVP_OFF&_XT_OSC&_WDT_OFF&_PWRTE_ON&_CP_OFF&_BODEN_OFF&
_DEBUG_OFF
listp=16f877
include"p16f877.inc"
;Startattheresetvector
org0x000
gotoStart
org0x004
Interrupt
retfie
Start
BCFSTATUS,RP0 ;
BCFSTATUS,RP1 ;Bank0
CLRFPORTA ;InitializePORTAby
;clearingoutput
;datalatches
BSFSTATUS,RP0 ;SelectBank1
MOVLW0x06 ;Configureallpins
MOVWFADCON1 ;asdigitalinputs
MOVLW0xCF ;Valueusedto
;initializedata
;direction
MOVWFTRISA ;SetRA<3:0>asinputs
;RA<5:4>asoutputs
;TRISA<7:6>arealways
;readas'0'.
BCFSTATUS,RP0 ;ReturntoaddresstheBank0

Main
BTFSSPORTA,RA0
GOTO$+2
BSFPORTA,RA4
BTFSCPORTA,RA0
GOTO$+2
BCFPORTA,RA4

BTFSSPORTA,RA1
GOTO$+2
BSFPORTA,RA5
BTFSCPORTA,RA1
GOTO$+2
BCFPORTA,RA5

GOTOMain

END

13. Oncethecodeisready,youcanuseoneofthefollowingtoolsto:1)onlycompilethecode,
2) clean output files and compile again the code and 3) compile and simulate the code.
Whatevercasewasselected,ifnoerrorsweredetected,theoutputfileswillbelocatedin
theprojectfolder.

(1)(2)(3)



In the case that errors were detected, such errors will be listed in the output terminal
windowasshowninthefigure:








TUTORIALFORSIMULATIONOFASSEMBLERPROGRAMS
USINGMPLABV3.50

1. Whennoerrorsweredetectedbeforeasimulation,theoutputterminalwindowwillshow
amessageindicatingthattheuserprogramisrunning.Inthisway,theusercanselectthe
bottom window called I/O Pins to select the pins involved in the program simulation as
showninthefigure:


Some pins information includes: pin direction mode, pin digital value, function activated
pin.Youcanchangethevalueofpinsbyclickingoverinordertotesttheassembleruser
programoperation.
2. Duringthesimulation,theusercanusesomenavigationbuttonstotesttheprogramina
betterway.Thebuttonsareshowninthefigureas:1)Stoporabortexecution,2)Pause
execution,3)Restartsimulation,4)Continuethesimulationfromtheactualstate,5)Step
overaninstructionand6)Stepinto an instruction. Also information about the Program
CounterPC,Statusbitsvaluesandspecialregistersbankaddressingisshown.

(1)(2)(3)(4)(5)(6)



IndividualTasks

1. IdentifythepurposeoftheassemblercodeexampleandelaborateaFlowDiagramofsuch
code.
2. IdentifyhowmanyassemblerinstructionscountsthePCregisterduringaholeexecution.
3. Makeasimulationoftheassemblercodeusingahigherlevelsimulator(i.e.:Proteous)
4. ElaborateanassemblercodetocopythedigitalstatesofthepinsPORTBinthepinsPORTD.
Makesimulationsinbothsimulators(MPLABandProteous).UseSwitchs,LEDsandResistors
tomakeelectronicandvisualrepresentationsofthedigitalstates.

Vous aimerez peut-être aussi