PIC 16F84 Assembly language

The topic on number crunching

PIC 16F84 Assembly language

Postby SJC1981 » Sat Jun 30, 2018 7:05 pm

Hi guys, apparently I've got both a linear and a subroutine programming error in the code below from lines 20-35? Could someone point me in the right direction. I think one might be the 'CALL wait' instruction, which should be 'CALL delay'? Not really sure as new to this, any help would be much appreciated, cheers!

1. ; Slow output binary count is stopped, started
2. ; and reset with push buttons. This version uses a
3. ; subroutine for the delay....
4. ;
5. ; *******************************************************************
6. processor 16f84
7. include <p16f84.inc>
8. __config _RC_OSC & _WDT_OFF & _PWRTE_ON
9. ; Register Label Equates..............................................
10. porta EQU 05 ; Port A Data Register
11. portb EQU 06 ; Port B Data Register
12. timer EQU 0C ; Spare register for delay
13. ; Input Bit Label Equates.............................................
14. inres EQU 0 ; ‘Reset’ input button = RA0
15. inrun EQU 1 ; ‘Run’ input button = RA1
16. ; Initialise Port B (Port A defaults to inputs).........................
17. MOVLW b’00000000’ ; Port B Data Direction Code
18. TRIS portb ; Load the DDR code into F86
19. GOTO reset
20. ; ‘delay’ subroutine.................................................
21. delay MOVWF timer ; Copy W to timer register
22. down DECFSZ timer ; Decrement timer register
23. GOTO reset ; and repeat until zero
24. RETURN ; Jump back to main program103
25. ; Start main loop..............................................
26. reset CLRF portb ; Clear Port B Data
27. start BTFSS porta,inres ; Test RA0 input button is set
28. GOTO reset ; reset Port B if pressed
29. BTFSC porta,inrun ; Test RA1 input button is clear
30. GOTO start ; and run count if pressed
31. INCF portb ; Increment count at Port B
32. MOVLW 0FF ; Delay count literal
33. CALL wait ; Jump to delay subroutine
34. GOTO start ; Repeat main loop always
35. END ; Terminate source code
SJC1981
 
Posts: 2
Joined: Sat Jun 30, 2018 4:49 pm

Return to Microcontrollers & Embedded

Who is online

Users browsing this forum: No registered users and 0 guests