View previous topic :: View next topic |
Author |
Message |
GAGAN
Joined: 10 Aug 2016 Posts: 9
|
PIC24 series oscillator configuration setup |
Posted: Wed Aug 10, 2016 6:30 am |
|
|
-Kindly explain the significance of #USE delay()..?
-What are argument supported by #USE delay()..?
-How does it affect the CPU clock speed and delay generation...?
-I want to generate 100 nsec delay for my application, what should be my #USE delay() setting, kindly explain in detail.
|
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19496
|
|
Posted: Wed Aug 10, 2016 8:57 am |
|
|
Er. Basic CCS.
#USE delay itself basically does nothing. You just tell it what clock rate your chip is running. Nothing else. The figure has to be right or almost nothing will work.
It is then used by all of the other timing related commands, to tell _them_ how to satisfy your needs. So when you set a UART to a baud rate, it is the figure from #USE DELAY that is used to setup the BRG. When you say 'delay_ms(10)', it is the figure from #USE DELAY that is used to calculate the processor delay actually needed. When you set the SPI or I2C to a particular rate, it is the figure from #USE delay that again tells the compiler what to do.
It doesn't 'affect the CPU clock speed', you need to set it to match the CPU clock speed.
However 100nSec, it won't be involved with at all. You will have to do this yourself by using delay_cycles, and you will have to also calculate for yourself how much time is involved in every other piece of code.
So if (for instance) you wanted to pulse a pin high for this long, you would have to look at the data sheet and work out what the timing overhead for the actual I/O instructions was, then work our how many machine instruction cycles need to be added to give the required delay. |
|
|
gjs_rsdi
Joined: 06 Feb 2006 Posts: 468 Location: Bali
|
|
Posted: Wed Aug 10, 2016 4:17 pm |
|
|
GAGAN
If your controller runs at 40 MHz, PC=100 ns so is in any case the time between one instruction to another if the instruction is a one PC instruction.
Available delay are:
Code: |
delay_cycles();
delay_us();
delay_ms();
|
Best wishes
Joe |
|
|
guy
Joined: 21 Oct 2005 Posts: 297
|
|
Posted: Sun Aug 14, 2016 11:34 pm |
|
|
Please look at the help file. #USE delay() is well documented with all of the options, which is good to know. |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9221 Location: Greensville,Ontario
|
|
Posted: Mon Aug 15, 2016 5:15 am |
|
|
BTW, pressing F11 while your project is open 'magically' opens the Help file ! I tend to keep it open as I forget little things like 'syntax' and 'order of values'.....
Jay |
|
|
|