??? 03/24/10 14:04 Read: times |
#174474 - Have you looked at the tutorials yet? Responding to: ???'s previous message |
The datasheet will tell you how fast the timer ticks in relation to the processor clock frequency.
If you then have a 16-bit timer, you will know how long the maximum delay is. Note that your code is using a long. Using a 32-bit integer in an 8-bit processor means a huge overhead and large code size. Even if you do implement a timer delay of 1ms - do you then need support for billions of milliseconds (millions of seconds)? For long delays, you normally configures the processor to generate a timer interrupt at a fixed speed. You then let the timer interrupt handler count interrupts. After n interrupts, the interrupt handler then sets a flag (and potentially restart the delay cycle again). This means that your application can continue to do other things, and when it sees the flag it performs the magic action. For very short delays, you may busy-loop, in case you are sure that there are no other things you need done during the wait time (and that other things can't be handled directly by interrupt handlers). Have you looked through the tutorials on this site? There are several useful tutorials. It is easier if you first check them out, and then return back with follow-up questions, if there is something you don't understand. |
Topic | Author | Date |
Atmel 89C5131A-UM Internal memory programming | 01/01/70 00:00 | |
compiler specific | 01/01/70 00:00 | |
Reply | 01/01/70 00:00 | |
Sample code? | 01/01/70 00:00 | |
Timers | 01/01/70 00:00 | |
Timers Reply | 01/01/70 00:00 | |
Have you looked at the tutorials yet? | 01/01/70 00:00 | |
it's all for assembler - but that doesn't matter! | 01/01/70 00:00 | |
Huge amounts of data | 01/01/70 00:00 | |
disregard the large numbers | 01/01/70 00:00 | |
No compiler support for EEPROM | 01/01/70 00:00 | |
compiler handling the EEPROM transparently | 01/01/70 00:00 | |
I did not know Keil helper functions. | 01/01/70 00:00 | |
It's part of the "xdata banking" support | 01/01/70 00:00 | |
Previously, on 8052.com...![]() | 01/01/70 00:00 |