Using Timer1 Gated Toggle Mode for RPM detector with Pin RA3 of PIC12F1572
1.I used the function of "Timer 1 Module with Gated Control" of PIC12F1572 to design a RPM detector and the RPM input is by pin RA3 as Fig.1.
2. The system clock is 16MHz and the Timer 1 is programmed in "Gated Toggle Mode" for RPM detector in 1MHz clock. The timing of "Gated Toggle Mode" is in Fig.2.
3. My brief program is name proram.txt and whole program is name Frq.X.zip as following:
4. My problems are:
(a) There is no interrupt happen if I set the T1GSEL=1; conversely, It will interrupt while T1GSEL=0.
According to the P.101 of data sheet of PIC12F1572, T1G=RA3 if T1GSEL=1.
(b) The load value from TMR1's count is unstable (Period = TMR1; //Get TMR1 Counter).
Period = TMR1; //Get TMR1 Counter
G_Period = 1; // Set a flag for main routine check
TMR1 = 0; //Reset Counter
PIR1bits.TMR1GIF = 0; // clear TMR1 interrupt flag
(c) I will be very appreciated if any one help me to solve those problems.
post edited by Hj_Chen - 2019/06/22 10:21:34