EngineersGarage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Advertise
You are here: Home / Replies / void interrupt isr(){if

void interrupt isr(){if

|

Microcontroller › PIC › capture timerreleted › void interrupt isr(){if

December 26, 2018 at 6:11 am #14982
selva
Participant

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)
{
}
}
 

RSS Recent Posts

  • isolating S-params in of PCB board without connectors April 11, 2026
  • Assistance locating a 'trail' camera gadget, please ? April 10, 2026
  • Raise your hand if your car had one of these: April 10, 2026
  • Some opamp advice please April 10, 2026
  • Voltage comparator circuit verification April 10, 2026

Stay Up To Date

Newsletter Signup
EngineersGarage

Copyright © 2026 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy | Advertising | About Us

Search Engineers Garage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Advertise