+ 1
Can someone please help me understand how to calculate time delay for PIC 16F1619 4Mhz? Assembler Code
I need help with this assignment, and I don't understand stand how to do it. If someone can atleast help me with one. Write the Assembler code and show your calculations to create the following delays: a) 20 micro secs b) 100 micro secs c) 500 micros secs d) 10 mS e) 100 mS f) 500 mS g) 1.5 Seconds h) 5.0 seconds
1 Answer
+ 1
The solution depends on the target hardware and OS (if any). Several approaches to consider:
1. Write a loop that executes no-op instructions (e.g., NOP) a number of times. The number depends on the processor clock speed and how many clock cycles per NOP instruction, plus overhead time of the loop instruction(s).
2. If there is a clock counter available with microsecond resolution, read its initial value and loop until the specified number of ticks have passed.
3. If no clock counter is available, implement your own by hooking into a suitable timer interrupt.
4. Make an OS API call to suspend your process for the specified duration.
EDIT: I see that you added the microprocessor and speed to the question. That narrows down what kind of answer you needed. See Martin Taylor's responses.