CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

PIC24 series oscillator configuration setup

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
GAGAN



Joined: 10 Aug 2016
Posts: 9

View user's profile Send private message Send e-mail

PIC24 series oscillator configuration setup
PostPosted: Wed Aug 10, 2016 6:30 am     Reply with quote

-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.
Rolling Eyes Question
Ttelmah



Joined: 11 Mar 2010
Posts: 19518

View user's profile Send private message

PostPosted: Wed Aug 10, 2016 8:57 am     Reply with quote

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

View user's profile Send private message Send e-mail

PostPosted: Wed Aug 10, 2016 4:17 pm     Reply with quote

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

View user's profile Send private message Visit poster's website

PostPosted: Sun Aug 14, 2016 11:34 pm     Reply with quote

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: 9229
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Mon Aug 15, 2016 5:15 am     Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group