Problem in using timer1 as counter in PIC 16f877

akj

New Member
Dear all

I am using pic16f877 for reading the no. of rotation of encoder. I am using TIMER1 as counter.The problem is that even when I am not connecting the encoder wire to the RC0 or RC1 pin the value of timer register keeps changing. I am sending the value of timer register to UART. I have even tried making TMR1ON=0 but the value kept changing . My current settings of timer are :-(pls. note "//" indicates comment line, btw I am using HiTechC compiler)
//START OF Configuration of different bits of T1CON
T1CKPS0=0;
T1CKPS1=0;//prescaler is 1:1
T1OSCEN=1;//for pin RC1 as external clock input
T1SYNC=1;// DO NOT SYNCHRONIZE TO EXTERNAL CLOCK INPUT
TMR1CS=1;//for external clock as rising edge
TMR1ON=1;//Stop/start Timer

//End OF Configuration of different bits of T1CON


Pls. help urgently.

I have attached the .c file and uart output for your reference.

Regs.

AKJ
 

Attachments

Cookies are required to use this site. You must accept them to continue using the site. Learn more…