Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
03/02/10 21:29
Read: times


 
#173747 - fixed length delays in C
I have indeed read through a few threads, infact most have actually cited threads on the keil forums, and all have been helpful!

i wish to introduce a delay in nanoseconds when putting data out on some data lines to a parallel interfaced screen. although i would also like to be able use the delay for longer appplications, perhaps up to 200us.

I am using an f060, with an internal 24.5MHz clock. The way I am currently implementing a delay is through a while loop simply decrementing a value passed to it. Assembler although an option and relatively easy, I would like to stay away from (as this has to be included in a final 12000 word report and it is already at 10000 words without a literature review, I really dont want to cut any more out for some assembler theory section).

I wish to neaten the delay up by calling a function to read and check a timers value, until the timers change in value is equal to my change in time desired. However I have a question I have not found an answer to, if the timer reloads during the call of the function, how will my code overcome this and still detect the change in value it is looking for.

OR

should my function begin by resetting the timer, and accounting for the time taken to do so. i.e. (i haven't looked into this yet, but say it takes 36 clock cycles to reset the timer) i wish to delay for 10us so 24500000*(10*10^-6) = 245, minus the 36 clock cycles to reset the timer = 209. So I call my function delay, it resets the timer, and then reads the timers value until it is equal to the (245-36).

If the answer is simply yes that is correct, I take your point, and sorry for wasting your time. I have a short amount of time to access the lab the dev kit and bits are sitting in tomorrow, I dont have much longer than half an hour to see if this works properly

Joel

List of 9 messages in thread
TopicAuthorDate
fixed length delays in C            01/01/70 00:00      
   Can't do it without assembly.            01/01/70 00:00      
      HLL gives no guarantees            01/01/70 00:00      
      Using a timer in C            01/01/70 00:00      
         overheads            01/01/70 00:00      
            Use a dedicated timer            01/01/70 00:00      
               non-functional code            01/01/70 00:00      
                  Interrupts aren't the biggest problem ...            01/01/70 00:00      
   break apart            01/01/70 00:00      

Back to Subject List