mrfunkyjay
New Member
Hi all, I have PIC18F1330.
It has two timer, namely timer0 and timer1. I have no problem with timer1. Here are my codes:
I have two Pulses. Namely Pulse1 and Pulse2. I need to use this microcontroller for sake of designing etc. I need to get my timer0 working at the same principal with the code above. Is it possible to do that with timer0? Or anyone has better idea/solution to this? Thank you very much.
PS: I am going to count the Pulse Width of PWM if this info useful.
It has two timer, namely timer0 and timer1. I have no problem with timer1. Here are my codes:
Code:
int GetPulse2(){
T1CON=0b00000000; /*Init timer1*/
TMR1L=0;
TMR1H=0;
TRISAbits.TRISA1=1; /*Make this pin as an input*/
while(PORTAbits.RA1==1); /*Make pin low*/
while(PORTAbits.RA1==0); /*While pin is high*/
T1CONbits.TMR1ON=1; /*Start timer1*/
while(PORTAbits.RA1==1); /*When pin is low*/
T1CONbits.TMR1ON=0; /*Stop timer1*/
return TMR1H*256+TMR1L; /*return 16bit timer value*/
}
I have two Pulses. Namely Pulse1 and Pulse2. I need to use this microcontroller for sake of designing etc. I need to get my timer0 working at the same principal with the code above. Is it possible to do that with timer0? Or anyone has better idea/solution to this? Thank you very much.
PS: I am going to count the Pulse Width of PWM if this info useful.
Last edited: