Close or Esc Key

Arduino Projects   |   Raspberry Pi   |   Electronic Circuits   |   AVR   |   PIC   |   8051   |   Electronic Projects

capture timerreleted

2 posts / 0 new
Last post
sagar
sagar's picture
Offline
Last seen: 6 months 4 weeks ago
Joined: 05/07/2018 - 15:23
capture timerreleted

how to write code in capture timer interrupt in pic16f690

Fransis
Fransis's picture
Offline
Last seen: 2 months 3 weeks ago
Joined: 26/12/2018 - 11:18
void interrupt isr(){if

void interrupt isr()
{
if(PIR1bits.CCP1IF ==1)
{
PIR1bits.CCP1IF = 0;//CCP1 interrupt overflow;
T1CONbits.TMR1ON = 1; // start timer 1
timer1_value1 = CCPR1H;//higher value;
timer1_value2 = CCPR1L;//lower value;
timer1_value = timer1_value1 + (((int)CCPR1L) << 8);
CLK=~CLK;

}
}
void CAPTURE_MODE()
{
unsigned long CP;
CCP1CONbits.CCP1M=0xb;//compare mode trigger special event(CCPIF bit set,CCP1 resets TMR1 or TMR2,and start A/D conversion if ADC value enable)
T1CONbits.T1CKPS=0x1;//prescalar 1:1 bit
OPTION_REGbits.INTEDG=1;//rising edge
PIE1bits.TMR1IE=1;//enable the timer 1 overflow interrupt;
PIR1bits.TMR1IF=0;//clear timer flag;

INTCONbits.GIE=1;//global interrupt enable
INTCONbits.PEIE=1;//peripheral interrupt enable bit;

PIE1bits.CCP1IE=1;
// PIR1bits.CCP1IF=0;//CCP1 interrupt flag bit
CCPR1H=0x00;//loaded value high;
CCPR1L=0x32;//loaded value low;
T1CONbits.TMR1ON=1;
}
 
void main(void)
{
TRISCbits.TRISC5=0;
unsigned long CP=0;
CAPTURE_MODE();
// TIMER_INIT();
while(1)
{
}
}