miumiu
Newbie

HI GUYS, so i have a problem with my coding, i have 3 question to ask , 1)i cant make it to have a 12ms delayed without overloading, 2)how to create a reset button at pin A3 that will be used to reset the multiplexing 7-Segments, and 3)how to make this the START/ STOP switch that connected at pinA0 that can be count when we pressed and stop the stopwatch when depressed, i only can make it start but not pause, please help me, disclaimer, im still new at this
Code:
LIST P=16F84 ; PIC16F84A Configuration Bit Settings
; STILL NEEDS TO SETUP!!!!
#include <P16F84.inc>
TENS equ 0x20
UNITS equ 0x21
COUNT equ 0x22 ; New variable for counting
org 0x00 ; Reset vector
goto START
LOOKUP addwf PCL,F
retlw 0x3F ; 0
retlw 0x06 ; 1
retlw 0x5B ; 2
retlw 0x4F ; 3
retlw 0x66 ; 4
retlw 0x6D ; 5
retlw 0x7D ; 6
retlw 0x07 ; 7
retlw 0x7F ; 8
retlw 0x67 ; 9
DELAY nop
return
START bsf STATUS,RP0
clrf TRISB ; Port B as output
movlw h'09'
movwf TRISA ;makes PORTA as input
bcf STATUS,RP0
clrf TENS
clrf UNITS
clrf COUNT
call STOP
STOP: btfsc PORTA,0
call DISPLAY_NUMBER
goto STOP
return
DISPLAY_NUMBER:
movf COUNT,W ; Load COUNT into W
movwf TENS ; Store tens place
movlw 0x0A
subwf TENS,W ; Subtract 10 from TENS
btfsc STATUS,C ; If no carry (TENS >= 10)
goto INCREMENT ; Increment TENS
goto SKIP_INCREMENT
INCREMENT:
clrf TENS ; Reset TENS to 0
incf UNITS,F ; Increment UNITS
movlw 0x64 ; Check if UNITS >= 100
subwf UNITS,W
btfss STATUS,Z ; If UNITS >= 100
goto RESET_COUNT ; Reset COUNT
goto SKIP_INCREMENT
call STOP
RESSET: movlw h'00'
movwf COUNT
RESET_COUNT:
clrf COUNT ; Reset COUNT to 0
goto DISPLAY_NUMBER
SKIP_INCREMENT:
movf TENS,W
call LOOKUP
movwf PORTB ; Display tens place
bsf PORTA,1 ; Set enable pin for tens place
call DELAY ; Delay 1ms
bcf PORTA,1 ; Clear enable pin for tens place
movf UNITS,W
call LOOKUP
movwf PORTB ; Display units place
bsf PORTA,2 ; Set enable pin for units place
call DELAY ; Delay 1ms
bcf PORTA,2 ; Clear enable pin for units place
incf COUNT,F ; Increment COUNT
movlw 0x64 ; Check if COUNT >= 100
subwf COUNT,W
btfss STATUS,Z ; If COUNT >= 100
goto DISPLAY_NUMBER
clrf COUNT ; Reset COUNT to 0
goto DISPLAY_NUMBER
end
Last edited by a moderator: