Basic Assembly code

Discussion in 'Homework Help' started by kamel2913, Oct 20, 2015.

  1. kamel2913

    Thread Starter New Member

    Mar 6, 2015
    15
    0
    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 (Text):
    1.  
    2. LIST p=16F877A ; Processeur 16F877A
    3. #INCLUDE <p16F877A.inc> ; Définition des registre internes du 16F877A
    4. CONFIG _CP_OFF & _WDT_OFF & _XT_OSC ; Option de programmation
    5. CBLOCK 0x0C
    6. vTempo1, vTempo2;
    7. ENDC
    8. org 0x000
    9. goto start
    10. Tempo:
    11. MOVLW 0xFF ; Charge W avec 0xFF
    12. MOVWF vTempo2 ; pour charge la vTempo2
    13. MOVWF vTempo2 ; pour charge la vTempo2
    14. Tempo2:
    15. MOVWF vTempo1 ; et la vTempo1
    16. Tempo1:
    17. DECFSZ vTempo1, f ; Décrémente vTempo et met le résultat dans vTempo
    18. call Tempo1 ; puis saute l'instruction suivante si 0.
    19. DECFSZ vTempo2, f
    20. GOTO Tempo2
    21. RETURN
    22. Start:
    23. bsf status,RP0 ;passage en page 1
    24. bcf trisa,RA0 ;mise à 0 de RA0 (sortie)
    25. bcf status,RP0 ;retour en page 0
    26. eteind:
    27. bcf porta,RA0 ;mise à 0 de RA0
    28. call Tempo
    29. allum:
    30. bsf porta,RA0 ;mise à 1 de RA0
    31. Call Tempo
    32. goto eteind
    33. end
    34.  
    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.
     
  2. Dodgydave

    Distinguished Member

    Jun 22, 2012
    4,986
    745
    Bonjour Cava,

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