This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Timer

I want 10 sec delay for the system how to implement
it in keil c. kindly help me.

for example: consider a road signal which has three aspects
and when the aspect changes from green to red it goes to yellow aspect and there is a delay of 5 to 10 sec. how to implement it. I implemented it by using for loops. But there is any way to implement using Hardware timer concepts

Parents
  • comment on the following program for approx 10 sec delay.

    #include <REGX52.H>
    #include<stdio.h>
    static unsigned long overflow_count = 0;
    
    void timer1_ISR (void) interrupt 3 {
      overflow_count++;
    
      if(overflow_count==(0x60000))
      {
    
       P0=P0^0xFF;
       overflow_count=0;
      }
    }
    void main (void) {
    
      TMOD = (TMOD & 0x0F) | 0x20;
      TH1 = 0XFF ;
      TL1 = TH1;
      ET1 = 1;
      TR1 = 1;
      EA  = 1;
      while(1);
    }
    

    thanks,
    vijay

Reply
  • comment on the following program for approx 10 sec delay.

    #include <REGX52.H>
    #include<stdio.h>
    static unsigned long overflow_count = 0;
    
    void timer1_ISR (void) interrupt 3 {
      overflow_count++;
    
      if(overflow_count==(0x60000))
      {
    
       P0=P0^0xFF;
       overflow_count=0;
      }
    }
    void main (void) {
    
      TMOD = (TMOD & 0x0F) | 0x20;
      TH1 = 0XFF ;
      TL1 = TH1;
      ET1 = 1;
      TR1 = 1;
      EA  = 1;
      while(1);
    }
    

    thanks,
    vijay

Children