Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

need help explain line by line

Status
Not open for further replies.

Allif Izzat

Newbie level 4
Newbie level 4
Joined
May 25, 2015
Messages
6
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
51
Code:
void InitTimer1() {
    T1CON = 0x30;
    TMR1IF_bit = 0;
    TMR1H = 0x0B;
    TMR1L = 0xDC;
    TMR1IE_bit = 1;
}

void interrupt() {
    if(INTF_bit) {
         if(TMR1ON_bit == 0) {
              TMR1ON_bit = 1;
         }
         else counter += 1;

         INTF_bit = 0;
    }

    if(TMR1IF_bit){
        TMR1IF_bit = 0;
        TMR1H = 0x0B;
        TMR1L = 0xDC;
        //Enter your code here
        if(++count == 2) {
             INTE_bit = 0;
             TMR1ON_bit = 0;
             count = 0;
        }
    }
}
 

Very long homework,
Specific questions would have worked faster and useful.
 

I think that code is written by me. Let me explain. Timer1 is configured to interrupt say every 500 ms but initially Timer1 is not ON. When external interrupt is detected at INT0 pin, Timer1 is turned ON. Then in the Timer interrupt Timer1 is turned OFF after count becomes 2 that means two 500ms interrupts is over. This means Timer1 stops after 1 second. The counter variable holds the number pulses detected on INT0 pin during this 1 second.
 
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top