Hi everyone!
Im very new to PIC programming and hope to get some help with timer1... I'm using MPLAB IDE 8.20
I am required to create a 75mS delay with timer1.
I am using a PIC 16F870 with a 4Mhz crystal
So the instruction cycle is 1 microsecond.
Sorry Im really totally new to this and just havent got my head around programming yet. I havent found much help on timer1 on the net either.
I have used the following formula to get the number i have to put into TMR1 to achieve a 75mS delay:
65536 - (75mS x (1Mhz / 8)
which gives me 56161 which is DB61 in hex
So I then load DB into TMR1H and 61 into TMR1L. Is this right so far?
And this is what Ive written so far:
BCF PIR1,0
CLRF TMR1L
MOVLW 0X0B
MOVWF TMR1H
MOVLW 0XDC
MOVWF TMR1L
TIME1
BSF T1CON,0
BTFSS PIR1,0
GOTO TIME1
EDIT:
For some reason this code is only giving me a 62mS delay in the stopwatch
To be honest Im a bit stuck right now as to how to continue from here... hope someone can point me in the right direction.
cheers!
Im very new to PIC programming and hope to get some help with timer1... I'm using MPLAB IDE 8.20
I am required to create a 75mS delay with timer1.
I am using a PIC 16F870 with a 4Mhz crystal
So the instruction cycle is 1 microsecond.
Sorry Im really totally new to this and just havent got my head around programming yet. I havent found much help on timer1 on the net either.
I have used the following formula to get the number i have to put into TMR1 to achieve a 75mS delay:
65536 - (75mS x (1Mhz / 8)
which gives me 56161 which is DB61 in hex
So I then load DB into TMR1H and 61 into TMR1L. Is this right so far?
And this is what Ive written so far:
BCF PIR1,0
CLRF TMR1L
MOVLW 0X0B
MOVWF TMR1H
MOVLW 0XDC
MOVWF TMR1L
TIME1
BSF T1CON,0
BTFSS PIR1,0
GOTO TIME1
EDIT:
For some reason this code is only giving me a 62mS delay in the stopwatch
To be honest Im a bit stuck right now as to how to continue from here... hope someone can point me in the right direction.
cheers!
Last edited: