??? 02/18/09 17:28 Read: times Msg Score: +1 +1 Good Answer/Helpful |
#162555 - Timer ticks Responding to: ???'s previous message |
Or use C, but initialize a timer to tick every ms (or any other suitable tick frequency that gives a suitable resolution) and let your C program wait the required number of timer ticks.
You may have an interrupt count the ticks (and possibly also set a time-out flag), or you may look directly at timer registers. Just note that your 8-bit processor looks at one byte at a time, and that care should be used if looking at a two-byte register that gets incremented (by interrupt or 16-bit counting in a timer) asynchronously. You may catch one byte and then get a timer overflow before you look at the second byte, in which case you get an invalid result. Assembler delays are best for short delays. An interrupt with timeout-flag allows your program to spend time doing other things while waiting for the flag to be set. With interrupts, you may also sleep your processor while it waits, to reduce the power consumption. Always think green (Intel most definitely don't) - especially if you may need to power the device from batteries. |
Topic | Author | Date |
Delay loop in C Programming | 01/01/70 00:00 | |
you can't | 01/01/70 00:00 | |
Timer ticks | 01/01/70 00:00 | |
It's IMPOSSIBLE - but here's how... | 01/01/70 00:00 | |
You do not![]() | 01/01/70 00:00 |