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 / Topics / capture timerreleted

capture timerreleted

|

Microcontroller › PIC › capture timerreleted

  • This topic has 1 reply, 2 voices, and was last updated 7 years, 9 months ago by selva.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • July 12, 2018 at 11:56 am #4947
    Rian
    Participant

    how to write code in capture timer interrupt in pic16f690

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

  • Author
    Posts
Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.
Log In

RSS feed: Recent Posts Recent Posts

  • How much does generator frequency stability matter for sensitive electrical equipment? October 7, 2026
  • Curiosity is difficult. October 6, 2026
  • Speed control on power tools... October 6, 2026
  • On off switch hack October 6, 2026
  • DBT alternative idea October 4, 2026

Stay Up To Date

Newsletter Signup
EngineersGarage

Copyright © 2026 Arrowfly 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 Arrowfly
Privacy Policy | Advertising

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