thank you mate! but how do we determine the 16 bits for TMR1H AND TMR1L?
I'm using the formula: 65536- (99ms X (1Mhz/4) so my result is 16036 which in HEX is: 3EA4 then split in 2 :
TMR1H 3E
TMR1L A4
but still no working. this is what i've done:
Code ASM - [expand ] 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
;PROGRAM START
ORG 0X000 ;PROCESSOR RESET VECTOR
GOTO MAIN ;GO TO BEGINNING OF PROGRAM
MAIN CALL SETUP
CALL DELAY_TEST_2
; GOTO REPEAT
;*********************************************************************************************************
;************************** SETUP PROCEDURE **************************************************************
; Initial settings for Pic Ports and Peripherals'
;*********************************************************************************************************
SETUP
BANK0 ;SWITCH BANK TO BANK 0
CLRF PORTA
CLRF PORTB ;SET UP INITIAL PORTB O/P CONDITIONS
CLRF PORTC
CLRF PORTD
CLRF PORTE
BTFSS PIR1, TMR1IF
MOVLW 0X31
MOVWF T1CON
BANK1 ;SWITCH TO BANK1
MOVLW 0XF0
MOVLW TRISA ;SET TRISA TO ALL O/Ps
CLRF TRISC
CLRF TRISD
CLRF TRISE
; MOVLW 0X07
; MOVWF OPTION_REG
BSF PIE1, TMR1IE
BANK3
CLRF ANSEL
CLRF ANSELH
BANK0 ;SWITCH BACK TO BANK 0
RETURN
;********************************************************************************************************
;********************* DELAY FOR APPROX 22mS ***********************************************************
; MAXIMUM DELAY AVAILABLE APPROX 65mS (4MHz PROCESSOR)
;********************************************************************************************************
DELAY_TEST
BCF INTCON, T0IF
MOVLW 0XAA ;SET UP DELAY COUNTERS
MOVWF TMR0
XX BTFSS INTCON, T0IF
GOTO XX
RETURN
;********************************************************************************************************
;********************* DELAY FOR APPROX 22mS ***********************************************************
; MAXIMUM DELAY AVAILABLE APPROX 65mS (4MHz PROCESSOR)
;********************************************************************************************************
DELAY_TEST_2
BTFSS PIR1, TMR1IF
MOVLW 0X3E ;SET UP DELAY COUNTERS
MOVWF TMR1H
MOVLW 0XA4
MOVWF TMR1L
YY BTFSS PIR1, TMR1IF
GOTO YY
RETURN
;********************************************************************************************************
END
Any guess? the result is like 396mS
thank you again!!
Last edited by a moderator: Nov 9, 2014