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
  • I am angry. very angry. The link you are spreading is misleading. It is wrong. It is so wrong that the OP might one day have somebody killed because he adopted your false and wrong methods. A small clue, Mr. Shah: writing delay functions is C is almost never going to perform the way you need it to, especially if the delay required is very short. OP: use interrupt driven delays or assembly. read the damn processor manual, for a change!

Reply
  • I am angry. very angry. The link you are spreading is misleading. It is wrong. It is so wrong that the OP might one day have somebody killed because he adopted your false and wrong methods. A small clue, Mr. Shah: writing delay functions is C is almost never going to perform the way you need it to, especially if the delay required is very short. OP: use interrupt driven delays or assembly. read the damn processor manual, for a change!

Children
  • C busy-loop delays should be synchronized by some form of hardware - for example constantly checking a hardware timer and not break until x ticks has passed.

    The posted link "computes" the delay based on the clock speed - but the processor clock isn't the only variable. The compiler version, optimization level, availability of processor registers etc can also affect a delay. And adaptive delay should at least try to figure out itself the number of loops in a ms - similar to the old Turbo Pascal delay() function (that later resulted in quite a lot of failed Turbo Pascal programs since the the computers became so fast that the adaptive analysis overflowed...)

    Any processor that can't supply hardware for keeping track of the time should be thrown away.

    Another important thing: A busy-loop without feedback, i.e. just counting cycles, (assembler or C) only have a lower bound on the delay. With high interrupt load, the true delay may become very much longer. A CPU running with 50% interrupt load will make all delays twice as long... A robust program should try to be reliable even at high loads.