Basic Assembly code

Thread Starter

kamel2913

Joined Mar 6, 2015
43
Hello guys,

well I have a home work: it's say to write a code in assemby to light on a LED with a push button using PIC16F877A

Code:
LIST p=16F877A ; Processeur 16F877A
#INCLUDE <p16F877A.inc> ; Définition des registre internes du 16F877A
CONFIG _CP_OFF & _WDT_OFF & _XT_OSC ; Option de programmation
CBLOCK 0x0C
vTempo1, vTempo2;
ENDC
org 0x000
goto start
Tempo:
MOVLW 0xFF ; Charge W avec 0xFF
MOVWF vTempo2 ; pour charge la vTempo2
MOVWF vTempo2 ; pour charge la vTempo2
Tempo2:
MOVWF vTempo1 ; et la vTempo1
Tempo1:
DECFSZ vTempo1, f ; Décrémente vTempo et met le résultat dans vTempo
call Tempo1 ; puis saute l'instruction suivante si 0.
DECFSZ vTempo2, f
GOTO Tempo2
RETURN
Start:
bsf status,RP0 ;passage en page 1
bcf trisa,RA0 ;mise à 0 de RA0 (sortie)
bcf status,RP0 ;retour en page 0
eteind:
bcf porta,RA0 ;mise à 0 de RA0
call Tempo
allum:
bsf porta,RA0 ;mise à 1 de RA0
Call Tempo
goto eteind
end
the code didn't work and I don't know why, when I try it in practice with "easyPIC" kit, and when I press on the push-button the LED light on and stay at that way, whatever I do.

sorry for my English, if you don't understand it please let me know.
 

Dodgydave

Joined Jun 22, 2012
8,389
Bonjour Cava,

Line 18 should be Goto Tempo 1, not Call, you keep calling and not returning so it crashes,
 
Top