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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
Joel Ward
03/02/10 15:29
Read: 402 times
Wolverhampton
United Kingdom


 
#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      Joel Ward      03/02/10 15:29      
   Can't do it without assembly.        Christoph Franck      03/03/10 02:28      
      HLL gives no guarantees      Andy Neil      03/03/10 02:50      
      Using a timer in C      David Prentice      03/03/10 03:53      
         overheads      Joel Ward      03/03/10 04:40      
            Use a dedicated timer      David Prentice      03/03/10 16:44      
               non-functional code      Erik Malund      03/03/10 17:26      
                  Interrupts aren't the biggest problem ...      Christoph Franck      03/04/10 01:49      
   break apart      Stefan KAnev      03/04/10 14:11      

Back to Subject List