You are on page 1of 4

M|croprocessor UI2

Subm|tted by

ke|th Matthew Castro
kather|ne Mae Lspao|a
L|ena G||era
k|ca A|yssa 1ao

**********************************************************************
1hls flle ls a baslc code LemplaLe for assembly code generaLlon *
on Lhe lC16l84A 1hls flle conLalns Lhe baslc code *
bulldlng blocks Lo bulld upon *
*
8efer Lo Lhe MASM users Culde for addlLlonal lnformaLlon on *
feaLures of Lhe assembler (uocumenL uS33014) *
*
8efer Lo Lhe respecLlve lC daLa sheeL for addlLlonal *
lnformaLlon on Lhe lnsLrucLlon seL *
*
**********************************************************************

||ename M|cro u|zasm
Date DLCLM8Lk 13 2012
||e Vers|on

Author CAS1kC kLI1n MA1nnLW
LSANCLA kA1nLkINL MAL
GILLkA LLLNA
1ANC kICA ALSSA

ear and sect|on LCLS_C


**********************************************************************
*
llles 8equlred 16l84AlnC *
*
**********************************************************************

noLes ConnecL Lhe 3 leds Lo each pln poslLlon and asslgned porL program Lhe plc16f84 Lo bllnk
Lhe LLu glven Lhe Llme below LhaL corresponds Lo each poslLlonLLu1 2sec LLu3 4Sec and
LLu6 2sec aL porL 8

**********************************************************************


llsL p16l84A llsL dlrecLlve Lo deflne processor
#lnclude p16l84Alnc processor speclflc varlable deflnlLlons

__CCnllC _C_Cll _Wu1_Cn _W81L_Cn _8C_CSC

__CCnllC dlrecLlve ls used Lo embed conflguraLlon daLa wlLhln asm flle
1he lables followlng Lhe dlrecLlve are locaLed ln Lhe respecLlve lnc flle
See respecLlve daLa sheeL for addlLlonal lnformaLlon on conflguraLlon word




***** vA8lA8LL uLllnl1lCnS
w_Lemp LCu 0x0C varlable used for conLexL savlng
sLaLus_Lemp LCu 0x0u varlable used for conLexL savlng

S1A1uS equ 03h Address of Lhe S1A1uS reglsLer
18lS8 equ 86h Address of Lhe LrlsLaLe reglsLer for porL 8
C818 equ 06h Address of orL 8
counL1 equ 08h address asslgned for counLer 1
counL2 equ 09h address asslgned for counLer 2
counL3 equ 10h address asslgned for counLer 3





**********************************************************************
C8C 0x000 processor reseL vecLor
goLo maln go Lo beglnnlng of program


C8C 0x004 lnLerrupL vecLor locaLlon
movwf w_Lemp save off currenL W reglsLer conLenLs
movf S1A1uSw move sLaLus reglsLer lnLo W reglsLer
movwf sLaLus_Lemp save off conLenLs of S1A1uS reglsLer


lsr code can go here or be locaLed as a call subrouLlne elsewhere


movf sLaLus_Lempw reLrleve copy of S1A1uS reglsLer
movwf S1A1uS resLore prelsr S1A1uS reglsLer conLenLs
swapf w_Lempf
swapf w_Lempw resLore prelsr W reglsLer conLenLs
reLfle reLurn from lnLerrupL



maln

****SeL up Lhe porL****

bsf S1A1uS3 swlLch Lo 8ank 1
movlw 00h seL Lhe orL 8 plns
movwf 86h Lo ouLpuL
bcf S1A1uS3 swlLch Lo 8ank0



****1urn Lhe LLu on********
SLarL

movlw b00100101 Lurn Lhe LLu12 and 3 Cn by flrsL placlng
movwf C818 lL Lo w reglsLer Lhen Lo C818
call uelay 2 sec delay

movlw b00000100 Lurn LLu2 Cn whlle LLu1 and 3 Cll
movwf C818 from w reglsLer Lhen Lo C818
call uelay 2 sec delay
call uelay 2 sec delay

movlw b00100001 Lurn LLu2 on by placlng flrsL
movwf C818 Lo w reglsLer Lhen Lo orL 8
call uelay 2 sec delay

movlw b00000000 Lurn off all LLu


****now go back Lo Lhe sLarL of Lhe program

goLo SLarL go back Lo SLarL and Lurn LLu on agaln

****SubrouLlne Code for uLLA?

uelay
movlw 12
movwf counL1
movlw 24
movwf counL2
movlw 167
movwf counL3

loop decfsz counL3
goLo loop
decfsz counL2
goLo loop
decfsz counL1
goLo loop
reLurn



reLurn
****Lnd of Lhe program****
Lnu dlrecLlve end of program

You might also like