Hi friends, I'd like to fix a delay time of minimum 400ns (maybe with an external clock), but the minimum time delay with "wait" icon is 1us and 0.4us isn't accepted. Do you have any solutions?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
As always get the Data Sheet for your processor and read it.
//// One instruction cycle consists of four oscillator periods;
for an oscillator frequency of 4 MHz, this gives a
nominal instruction execution time of 1 μs. All
instructions are executed within a single instruction
cycle, unless a conditional test is true, or the program
counter is changed as a result of an instruction
/////
This is Quoted from the data sheet
NOP like most pic instructions use 1 instruction cycle.
What is your osc frequency?
to get 400 nanosec you would need 20 Mhz osc and execute 2 NOP's in a row.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
using NOP 's in GCBasic is easy because assembler instructions can be embedded into the code and used just like basic instructions.
I have seen code where 10 or more NOP's are used in a row for timing.
You would think that for code compactness you would put the NOP in a FOR loop or REPEAT loop but remember that the loops have "over head" which means additional instructions that take up time. Many times I have used FOR loops to waste time when the amount of time was not important. You would look at the assembler for a FOR loop to seen what additional instructions were added.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi friends, I'd like to fix a delay time of minimum 400ns (maybe with an external clock), but the minimum time delay with "wait" icon is 1us and 0.4us isn't accepted. Do you have any solutions?
Hi
400ns seem a very short time for a microcontroller to control, even using a 20 MHz quartz I suggest a "NOP".
Ciao
What's a "NOP"?
a single assembler instruction delay
Ciao
Could someone explain me how to generate a NOP? Please.
PS
I found NOP = No Operation instruction. Not a real delay.
Last edit: cosmok82 2014-01-17
If I understand correctly, the NOP instruction doesn't execute instruction for N cycles of clock, but what's the value of N?
As always get the Data Sheet for your processor and read it.
//// One instruction cycle consists of four oscillator periods;
for an oscillator frequency of 4 MHz, this gives a
nominal instruction execution time of 1 μs. All
instructions are executed within a single instruction
cycle, unless a conditional test is true, or the program
counter is changed as a result of an instruction
/////
This is Quoted from the data sheet
NOP like most pic instructions use 1 instruction cycle.
What is your osc frequency?
to get 400 nanosec you would need 20 Mhz osc and execute 2 NOP's in a row.
I thought the context it was this, but i preferred to ask you. Thanks mmotte!
using NOP 's in GCBasic is easy because assembler instructions can be embedded into the code and used just like basic instructions.
I have seen code where 10 or more NOP's are used in a row for timing.
You would think that for code compactness you would put the NOP in a FOR loop or REPEAT loop but remember that the loops have "over head" which means additional instructions that take up time. Many times I have used FOR loops to waste time when the amount of time was not important. You would look at the assembler for a FOR loop to seen what additional instructions were added.