Accuracy of Vdelay_ms function

Thread Starter

conanav

Joined Jun 14, 2008
14
Does anybody know the accuracy of the Vdelay_ms function in mikroC? They specify that it is not as accurate as the predetermined delay using just delay_ms() (does this one also have an error to it?) but i am just wondering what the uncertainty is. I need to use this function in such way that the value of the delay will be entered by the outside user so i cannot just use a predetermined value. Also, the accuracy plays a very significant role.

Edit: Would it be more accurate to code it straight in assemlby using the 16 bit internal TMR1 timer with an external 10MHZ clock giving me a pulse every 100ns. The number of pulses has to be variable so I was thinking about nesting 255-counting loops (like it was described in another post on delays) in such way that if an outside user enters "5" it would correspond to a 500 ns delay, "50" to 5ms, and "1e8" for 1 sec delay and so on. However , what i still can't figure out is if the TMR1 has only 16 bits, is my input going to be bound by 65,536 and as such will I not be able to count more pulses than that number? I am very new to the subject of microcontrollers so I apologize in advance if my question is completely incoherent.

Thanks
 
Last edited:

nanovate

Joined May 7, 2007
666
Take a look at the "prescaler" for the timer. You can divide down the clock. Also look at how many clocks per instruction/timer counts. You may not actually be getting 100ns per count but 400ns. I will download the datasheet later and look.
 

Thread Starter

conanav

Joined Jun 14, 2008
14
As far as the second part of the question goes, is the input going to be bound by 65,536 in terms of number of clock pulses?
 
Top