amrshata
Member level 1
i try to make aprograme that count's 20k pulses using timr0 module
but tmr0h doesn't read any thing just tmr0l read untill 256
void main() {
CMCON = 0x07; // Disable comparators
ADCON1 = 0x0F; // Disable Analog functions
TRISB = 0b00000000; // PORTB All Outputs
TRISA = 0b00010000;
TRISC = 0b00000001;
T0CON = 0b10111000; // TMR1 as 16-bit counter
PWM1_Init(4000);
PWM1_Set_Duty(127);
do{
T0CON.TMR0ON = 1;
TMR0H = 0; //reset the timer
TMR0L = 0;
pwm1_start();
delay_ms(500); //delay 0.5 sec to produce 20k pulses
pwm1_stop(); // stop the pwm
T0CON.TMR0ON = 0;
x=tmr0h*256+tmr0l; //calc. the recevied pulses
}
while(1);
}
and i connected RC2 (pwm source ) with RA4 but TMR0H read nothing any help plzz ?
but tmr0h doesn't read any thing just tmr0l read untill 256
void main() {
CMCON = 0x07; // Disable comparators
ADCON1 = 0x0F; // Disable Analog functions
TRISB = 0b00000000; // PORTB All Outputs
TRISA = 0b00010000;
TRISC = 0b00000001;
T0CON = 0b10111000; // TMR1 as 16-bit counter
PWM1_Init(4000);
PWM1_Set_Duty(127);
do{
T0CON.TMR0ON = 1;
TMR0H = 0; //reset the timer
TMR0L = 0;
pwm1_start();
delay_ms(500); //delay 0.5 sec to produce 20k pulses
pwm1_stop(); // stop the pwm
T0CON.TMR0ON = 0;
x=tmr0h*256+tmr0l; //calc. the recevied pulses
}
while(1);
}
and i connected RC2 (pwm source ) with RA4 but TMR0H read nothing any help plzz ?