sir, for delay in micro controller, everytime we have to use TMOD and TR and enable corresponding interrupt.is there any other less tedious way of programing a delay using keil cross compiler. regards, malay lakhani final year BE student, mumbai
for delay in micro controller, everytime we have to use TMOD and TR and enable corresponding interrupt "We" don't need interrupts for that. It's perfectly feasible to use polling to find out when the timer has finished running. is there any other less tedious way of programing a delay using keil cross compiler. To be frank, if you find setting two registers "tedious", then maybe you need to find another field of work.
"... maybe you need to find another field of work." Or put all of that "tedious" stuff in a function or multi-statement macro.
You could alway use a for loop. But you have to time it by hand, And, it can change time if you change the compiler or optimization. make a function called delay that sets the timer and waits for it to be done. Then use it over and over.
You could just leave the hardware timer running permanently. Have a start_timer() function that sets some global to some suitable value; Each timer interrupt then decrements the global; When the global reaches zero, your time is up! You can easily extend this to support several simultaneous timers...