• Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

PIC instructions length

Status
Not open for further replies.

french_student

New Member
Hello,

Do you know where i can find the length (in ms or ns) of instructions we're using when we program a PIC?
In fact i need to make some delays but with the instruction "delay_cycles()" i can't have what i want. So i thought i could use some instruction in addition of the delay_cycles() fonction to succeed in having the delay i need.

Thanks.
 

Nigel Goodwin

Super Moderator
Most Helpful Member
french_student said:
Hello,

Do you know where i can find the length (in ms or ns) of instructions we're using when we program a PIC?
In fact i need to make some delays but with the instruction "delay_cycles()" i can't have what i want. So i thought i could use some instruction in addition of the delay_cycles() fonction to succeed in having the delay i need.

Thanks.
The datasheets tell you the instruction timings, basically most instructions are only one processor cycle, but branch instructions are two processor cycles. With a 4MHz clock the processor runs at 1MHz, giving 1uS per processor cycle.

If you want to make a specific delay there's a delay calculator on the PICLIST website at http://www.piclist.com, just fill in your requirements and press the button - instant code :lol:
 

french_student

New Member
really thanks!

Where can i find it on the datasheets? Is there a specific part in which they talk about this?
Your code generator is really good but i work in C language not ass; is there the same code generator but for C instructions?

My problem is surely that i need to make a delay of 420 ns. Can it be possible?

Thanks a lot for your preious help!
 

Nigel Goodwin

Super Moderator
Most Helpful Member
Re: really thanks!

french_student said:
Where can i find it on the datasheets? Is there a specific part in which they talk about this?
Your code generator is really good but i work in C language not ass; is there the same code generator but for C instructions?

My problem is surely that i need to make a delay of 420 ns. Can it be possible?

Thanks a lot for your preious help!
You certainly can't do it at 4MHz, a single instruction (NOP for instance) takes 1uS - at 20MHz it would take 200nS, so two NOP's would take 400nS, you couldn't get 420nS unless you use a slightly slower clock speed (19.0476MHz). Anything extra added by a C compiler would extend this time considerably, so you would really need to do this part in assembler.

As a matter of interest, what are you doing that requires a 420nS delay
 

tom2000

New Member
222

Yes it true to create an exact timming in anything other than assembly is extremely difficult and especially that short.

Even in asm...a simple 'goto' @20mhz takes 400nS, although Im pretty sure that something like this in C would also translate into a 400nS delay


<your code>

goto next1; // 2 cycles (should also be translated into 2 cycles)
next1:

<your code continues>
 

french_student

New Member
Thanks

In fact i need this delay because the pic communicate with an extern ADC (the AD7827). Before sending the clock signal to the AD so that it make the serialization of the data i need to wait for the end of the conversion of the analog data. In the datasheet of the AD7827 it's said that the conversion time is 420 ns maximum, so finally i'll try with a delay of 400ns and see if it works.

I'll tell you if it does!

Thanks for your answers.
 

Nigel Goodwin

Super Moderator
Most Helpful Member
Re: Thanks

french_student said:
In fact i need this delay because the pic communicate with an extern ADC (the AD7827). Before sending the clock signal to the AD so that it make the serialization of the data i need to wait for the end of the conversion of the analog data. In the datasheet of the AD7827 it's said that the conversion time is 420 ns maximum, so finally i'll try with a delay of 400ns and see if it works.
Usually ADC's have an output pin that shows the end of conversion, you could check that (assuming it has one).

Presumably you are trying to digitise a signal as fast as you can?, with the conversion time so fast you could simply read the ADC, start it reading again, then store the previous result - the time taken to store the result will be more than the conversion time of the ADC, so no need to add any delay!.
 
Status
Not open for further replies.

EE World Online Articles

Loading
Top