Reputation: 65
Is there any delay function can be used to PIC18F4550 in C programming, similar to delay()
and delayMicroseconds()
in Arduino?
The delay functions that can find are Delay10KTCYx()
, Delay10TCYx()
and etc which is very difficult to generate the delay that we desired, and the lowest delay is not even in milliseconds.
Kindly seek your assists, please. Thank you
Upvotes: 0
Views: 1243
Reputation: 214810
When doing microcontroller programming, you should always use the on-chip hardware timers if possible. There are typically several of those and perhaps a real-time clock as well. Rather than looking for some busy-delay function, you should look for a driver or HAL around those hardware timers present in your MCU.
In addition, if you need better than 1ms resolution then note that "delay" functions tend to be inaccurate.
Busy-delay() functions/loops are mostly a quick & dirty amateur solution. They are bad because:
Upvotes: 1