Hey all
ive become quite proficient with PICs, the one im using currently is the PIC16F877A...very common i know and im using TIMER1 really well... Its been quite user friendly
However i need another timer, and if i can help it, id like to use another timer and not use multiples of timer 1.
I need timer 2 OR timer 0 to count up to 0.1ms (20MHz clock) so loading the PRESCALER to 1:4 will allow this.
But Timer0 doesnt indictae how to TURN ON or TURN OFF the timer, i need to be able to control it like TIMER1. Timer 2 has this functionality but gets me a bif baffled. The use of the PR2 register, if i load this with 125, then with the values stated, i should get an interrupt at 0.1ms, but i dont
I cant see where ive gone wrong? heres the timer code
ive become quite proficient with PICs, the one im using currently is the PIC16F877A...very common i know and im using TIMER1 really well... Its been quite user friendly
However i need another timer, and if i can help it, id like to use another timer and not use multiples of timer 1.
I need timer 2 OR timer 0 to count up to 0.1ms (20MHz clock) so loading the PRESCALER to 1:4 will allow this.
But Timer0 doesnt indictae how to TURN ON or TURN OFF the timer, i need to be able to control it like TIMER1. Timer 2 has this functionality but gets me a bif baffled. The use of the PR2 register, if i load this with 125, then with the values stated, i should get an interrupt at 0.1ms, but i dont
I cant see where ive gone wrong? heres the timer code
Code:
BSF T1CON, T1CKPS1 ;THESE 2 LINES
BSF T1CON, T1CKPS0 ;SET PRESCALER TO 8
BCF T1CON, T1OSCEN
BCF T1CON, TMR1CS
BCF T1CON, TMR1ON ;STOPS TIMER
CLRF T2CON
BSF T2CON, T2CKPS0 ;POSTSCALER TO 4
MOVLW h'FE' ;reset timer1 values 0.5MS
MOVWF TMR1H
MOVLW h'C7' ;reset timer1 values 0.5MS
MOVWF TMR1L
BSF INTCON, PEIE
BCF PIR1, TMR1IF
BCF PIR1, TMR2IF
BSF STATUS, 5 ;Change to BANK 1
BSF PIE1, TMR1IE
BSF PIE1, RCIE
BSF OPTION_REG, INTEDG
BCF STATUS, 5 ;Change to BANK 0
BSF INTCON, INTE ;Enable EXTERNAL INTERRUPT
BSF INTCON, GIE ;GLOBAL INTERRUPT ENABLE
BSF T2CON, TMR2ON ;STARTS TIMER
BSF PORTC, 1