im have one question here..
Prescaler the timer was set to 8, count set to 1, f clk was 20MHz, and TMR1 set to 0xFFFF to make sure it can operate to the maximum. If TMR1 set below than 0, overflow will happened and that make the timer not work properly.
After set everything fout = 9.54Hz.
how i want to set Fout starting with 0Hz. my digital speedometer maximum is 20Hz. so if it start with 9.54Hz, it mean my speedometer will operate when half of car maximum speed.
im using c18 compiler.
code for interrupt ccp:
void InterruptHandlerHigh(void)
{
if (PIR1bits.CCP1IF == 1)
{
PIR1bits.CCP1IF = 0;
if (pwm == 1 )
{
count = ReadCapture1();
OpenCapture1 ( C1_EVERY_FALL_EDGE & CAPTURE_INT_ON );
pwm = 0;
}
else
{
countwidth = ReadCapture1()- count;
OpenCapture1 ( C1_EVERY_RISE_EDGE & CAPTURE_INT_ON );
WriteTimer1(0xFFFF);
pwm = 1;
}
}
INTCONbits.GIE=1; //enable global interrupts
}
Prescaler the timer was set to 8, count set to 1, f clk was 20MHz, and TMR1 set to 0xFFFF to make sure it can operate to the maximum. If TMR1 set below than 0, overflow will happened and that make the timer not work properly.
After set everything fout = 9.54Hz.
how i want to set Fout starting with 0Hz. my digital speedometer maximum is 20Hz. so if it start with 9.54Hz, it mean my speedometer will operate when half of car maximum speed.
im using c18 compiler.
code for interrupt ccp:
void InterruptHandlerHigh(void)
{
if (PIR1bits.CCP1IF == 1)
{
PIR1bits.CCP1IF = 0;
if (pwm == 1 )
{
count = ReadCapture1();
OpenCapture1 ( C1_EVERY_FALL_EDGE & CAPTURE_INT_ON );
pwm = 0;
}
else
{
countwidth = ReadCapture1()- count;
OpenCapture1 ( C1_EVERY_RISE_EDGE & CAPTURE_INT_ON );
WriteTimer1(0xFFFF);
pwm = 1;
}
}
INTCONbits.GIE=1; //enable global interrupts
}