i stuck in timing control at PIC and wish someone can help me. Now i follow book to learn PIC microcontroller, i done many practise project already, but now i am trying to do my own project. so i use 16F877A with the keypad to set my password and show on the LCD screen. Actually the project is work, but the problem is the timing. My 16F877A IC is run too slow, because i normally use the 32768hz crystal that learn from the book, therefore now my project run too slow so i try to use 4Mhz crystal, but cant be run. Actually i know there is
the program problem, but i cant soft so wish someone can help. Below is my timing programed:
;CAN WORK!!(FOR 32768Hz Crystal, 68PF x2)
;**********************************************************************************************
;DELAY 1 SECOND
DELAY1 CLRF TMR0 ;for 32768Hz crystal:
LOOPA MOVF TMR0,W ;1/4 of 32768 = 8192
SUBLW .32 ;8192/256 =32pulse
BTFSS STATUS,ZEROBIT ;so 1 sec = 32pulse
GOTO LOOPA ;if 0.5 sec = 16pulse
RETLW 0
;DELAY 0.5 SECOND
DELAYp5 CLRF TMR0 ;START TMR0
LOOPb MOVF TMR0,W ;READ TMR0 INTO W.
SUBLW .16 ;TIME - 16
BTFSS STATUS,ZEROBIT ;check TIME-W=0
GOTO LOOPb ;TIME IS NOT=16
RETLW 0
;CANt WORK!!(FOR 4MHz Crystal, 22PF x2)
;**********************************************************************************************
;DELAY 1 SECOND
DELAY1 CLRF TMR0 ;for 4MHz crystal:
LOOPA MOVF TMR0,W ;1/4 of 4MHz = 1MHz
SUBLW .3906 ;1MHz/256 = 3906.25pulse
BTFSS STATUS,ZEROBIT ;so 1 sec = 3906pulse
GOTO LOOPA ;if 0.5 sec = 1953pulse
RETLW 0
;DELAY 0.5 SECOND
DELAYp5 CLRF TMR0
LOOPb MOVF TMR0,W
SUBLW .1953
BTFSS STATUS,ZEROBIT
GOTO LOOPb
RETLW 0
I try to look for internet information but not so understand and very tricky, and i stuck at the timing
quite long, may be my calculation is wrong...hiaz........T.T.....Wish can help..
the program problem, but i cant soft so wish someone can help. Below is my timing programed:
;CAN WORK!!(FOR 32768Hz Crystal, 68PF x2)
;**********************************************************************************************
;DELAY 1 SECOND
DELAY1 CLRF TMR0 ;for 32768Hz crystal:
LOOPA MOVF TMR0,W ;1/4 of 32768 = 8192
SUBLW .32 ;8192/256 =32pulse
BTFSS STATUS,ZEROBIT ;so 1 sec = 32pulse
GOTO LOOPA ;if 0.5 sec = 16pulse
RETLW 0
;DELAY 0.5 SECOND
DELAYp5 CLRF TMR0 ;START TMR0
LOOPb MOVF TMR0,W ;READ TMR0 INTO W.
SUBLW .16 ;TIME - 16
BTFSS STATUS,ZEROBIT ;check TIME-W=0
GOTO LOOPb ;TIME IS NOT=16
RETLW 0
;CANt WORK!!(FOR 4MHz Crystal, 22PF x2)
;**********************************************************************************************
;DELAY 1 SECOND
DELAY1 CLRF TMR0 ;for 4MHz crystal:
LOOPA MOVF TMR0,W ;1/4 of 4MHz = 1MHz
SUBLW .3906 ;1MHz/256 = 3906.25pulse
BTFSS STATUS,ZEROBIT ;so 1 sec = 3906pulse
GOTO LOOPA ;if 0.5 sec = 1953pulse
RETLW 0
;DELAY 0.5 SECOND
DELAYp5 CLRF TMR0
LOOPb MOVF TMR0,W
SUBLW .1953
BTFSS STATUS,ZEROBIT
GOTO LOOPb
RETLW 0
I try to look for internet information but not so understand and very tricky, and i stuck at the timing
quite long, may be my calculation is wrong...hiaz........T.T.....Wish can help..