Home     Contact     Projects     Experiments     Circuits     Theory     BLOG     PIC Tutorials     Time for Science     RSS     Terms of services     Privacy policy  
 Home      Projects     Experiments     Circuits     Theory     BLOG     PIC Tutorials     Time for Science   

<< Back to INDEX

Delay subroutines in assembly for PIC16 [Programing]
posted February 22 2014 4:52.48 by spic0m

Benoit Frigon is sharing his delay routines for PIC microcontrollers.

"This is the delay subroutines i use in my PIC projects. It was written for the PIC16 family but should be compatible with the 18F instruction set as well.

The simplest way to produce delay is to write a subroutine that waste instructions cycles for the desired amount of time. This method should not be used for application that require a high level of precision since the delay subroutine may be halted by interrupts. The delay is offset by the time it takes to execute the interrupt service routine. For short delays however, this should not be a problem.

How many cycles are required

Let's say that the processor clock runs at 8 MHZ. It takes 4 clock pulse to execute one instruction cycle. At 8 MHZ, the processor is able to execute 2 millions instructions per seconds. It also means that each instructions takes 0.0000005 seconds (0.5 micro seconds) to execute. To produce a 50 milliseconds delay, you then need to execute 100,000 instruction cycles.

Here is the formula to find out the number of instruction required :

i_time = 1 / (fosc / 4)
0.0000005 = 1 / (8000000 / 4)

n = time / i_time
100000 = 0.05 / 0.0000005
The delay subroutines

There are 4 delay subroutines :"

Head to the original article for the code.

[Link: Benoit Frigon]

You might also like...

Zooming Into a Microchip

Weather Station [Project]

World's Fastest Computer Will Operate Like a Human Brain [Science]

10 facts about black holes [Space]

Researchers levitate objects using nothing but sound [Innovation]

Paper Generators: Harvesting Energy from Touching, Rubbing and Sliding [Innovation]

What Your Body Does In 30 Seconds [Science]

Do you Yoyo? [Physics]

<< Back to INDEX



  Email (shall not be published)


Notify me of new posts via email

Write your comments below:
BEFORE you post a comment:You are welcome to comment for corrections and suggestions on this page. But if you have questions please use the forum instead to post it. Thank you.


No comment yet...

Be the first to comment on this page!

 Contact     Forum     Projects     Experiments     Circuits     Theory     BLOG     PIC Tutorials     Time for Science     RSS   

Site design: Giorgos Lazaridis
© Copyright 2008
Please read the Terms of services and the Privacy policy