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

  • More fun with ws2812 this time XC8 and CLC July 14, 2025
  • Wierd makita battery July 14, 2025
  • I Wanna build a robot July 13, 2025
  • using a RTC in SF basic July 13, 2025
  • Is AI making embedded software developers more productive? July 13, 2025

Stay Up To Date

Newsletter Signup
EngineersGarage

Copyright © 2025 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