Fan174
Member level 2
Hi,
Since CCP1 represents a 16 bit value I recommend to use uint16.
For sure you may use a nother variable: new_ccp (just local in ISR)
And you need the variable: delta_t (global)
Then (pseudo code)Code:* New_ccp = ccp1h, ccp1l * Delta_t = new_ccp - t0 * t0 = new_ccp
No need for a loop
Klaus
I don't know to store timer value (CCPR1H CCPR1L)
I think We can store value like
Code:
void interrupt CCP1_ISP()
{
// CCP1 Interrupt
if(CCP1IF == 1) // if CCP1 Interrupt flag is set
{
uint8_t New_ccp, Delta_t, t0;
New_ccp = CCPR1H + CCPR1L;
Delta_t = New_ccp - t0;
t0 = New_ccp;
}
}