??? 10/25/05 14:09 Read: times |
#102912 - delay in C, yes ! Responding to: ???'s previous message |
It is also possible to write a working delay in C:
#include <reg51.h> // T0 must be running in mode 1 unsigned int read_t0_on_the_fly( void ) { unsigned char tl, th; th = TH0; tl = TL0; if( (tl & 0x80) == 0 ) th = TH0; return tl | th << 8; } void delay_us( unsigned int t ) // 20 ... 60000us at 12MHz { unsigned int d = read_t0_on_the_fly(); while( read_t0_on_the_fly() - d < t ); } Peter |
Topic | Author | Date |
passing parameters from c to assembly | 01/01/70 00:00 | |
RTFM | 01/01/70 00:00 | |
What Compiler? They are all differerent | 01/01/70 00:00 | |
Why assembly??? | 01/01/70 00:00 | |
some things can not be done in C | 01/01/70 00:00 | |
Yes you can... | 01/01/70 00:00 | |
Not true | 01/01/70 00:00 | |
eliminated | 01/01/70 00:00 | |
bull! | 01/01/70 00:00 | |
delay in C, yes ! | 01/01/70 00:00 | |
More on 'C' delay loops... | 01/01/70 00:00 | |
sure, when you use a timer | 01/01/70 00:00 | |
Total Malund! | 01/01/70 00:00 | |
dear Russell re "bull" | 01/01/70 00:00 | |
Malund Bull... | 01/01/70 00:00 | |
Public variable | 01/01/70 00:00 | |
Examples...![]() | 01/01/70 00:00 |