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

#use delay is twice what it should be
Goto page Previous  1, 2
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
mbradley



Joined: 11 Jul 2009
Posts: 118
Location: California, USA

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

PostPosted: Tue Dec 08, 2009 1:06 pm     Reply with quote

To the best of my knowledge, and I could be wrong, but the #use delay preprocessor command is used solely for the compiler to know internally how to handle the delay_xx and the bitbang serial routines.

Using this does not change/config the internal clock:
Code:

#use delay (clock=16000000)

One must do this:
Code:

#use delay (clock=16000000)  // tell ccs what the clock is running at in main:
void main(void)
{
setup_oscillator(OSC_16MHZ);// setup the internal oscilator
..rest of your code...

}

_________________
Michael Bradley
www.mculabs.com
Open Drivers and Projects
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Tue Dec 08, 2009 1:37 pm     Reply with quote

When I reported
Quote:
that oscillator frequency is already set from #use delay

you can be pretty sure, that I checked the respective compiler code. But it didn't work correctly with previous
compiler versions, setup_oscillator(OSC_16MHZ) also didn't in this case. Your statement can be still correct
for other processors or other compiler versions. Did you actually check or is it just a guess?
dyeatman



Joined: 06 Sep 2003
Posts: 1985
Location: Norman, OK

View user's profile Send private message

PostPosted: Tue Dec 08, 2009 2:13 pm     Reply with quote

If you are still looking for account info go here:
http://www.ccsinfo.com/renewals.php?navcode=/renewals

Put in your account number and ZIP and it will show your purchase history at the top of the page. (it did for me anyway)
_________________
Google and Forum Search are some of your best tools
rovtech



Joined: 24 Sep 2006
Posts: 288

View user's profile Send private message AIM Address

PostPosted: Tue Dec 08, 2009 2:34 pm     Reply with quote

CCS tells me that this problem is corrected in newer compiler versions. Mine is version 4.089
There are several things that do not work although they should according to the .h file. The problems are specific to this device - 16F722
Thanks to everyone for their help. As an inexperienced programmer I assumed the problems were mine.
mbradley



Joined: 11 Jul 2009
Posts: 118
Location: California, USA

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

PostPosted: Thu Dec 10, 2009 2:17 am     Reply with quote

from the manual:
Code:
//set timing config to 32KHz, restart watchdog timer
//on delay_us() and delay_ms()
#use delay (clock=32000, RESTART_WDT)
 
//the following 4 examples all configure the timing library
//to use a 20Mhz clock, where the source is an oscillator.
#use delay (clock=20000000)             //user must manually set HS config bit
#use delay (clock=20,000,000)           //user must manually set HS config bit
#use delay(clock=20M)                   //user must manually set HS config bit
#use delay(clock=20M, oscillator)       //compiler will set HS config bit
#use delay(oscillator=20M)              //compiler will set HS config bit
 
//application is using a 10Mhz oscillator, but using the 4x PLL
//to upscale it to 40Mhz.  Compiler will set H4 config bit.
#use delay(clock=40M, oscillator=10M)       
 
//application will use the internal oscillator at 8MHz.
//compiler will set INTOSC_IO config bit, and set the internal
//oscillator to 8MHz.
#use delay(internal=8M)


I guess the usedelay can be used to set the clock, i just never have
_________________
Michael Bradley
www.mculabs.com
Open Drivers and Projects
Ttelmah
Guest







PostPosted: Thu Dec 10, 2009 3:18 am     Reply with quote

mbradley wrote:
To the best of my knowledge, and I could be wrong, but the #use delay preprocessor command is used solely for the compiler to know internaly how to handle the delay_xx and the bitbang serial routines.

Using this does not change/config the internal clock:
Code:

#use delay (clock=16000000)

One must do this:
Code:

#use delay (clock=16000000)  // tell ccs what the clock is running at in main:
void main(void)
{
setup_oscillator(OSC_16MHZ);// setup the internal oscilator
..rest of your code...

}


No.
What you say was 'right' for the earlier compilers, but at some point in the mid V3 compilers, CCS added a feature, so that if you were running on a chip with selectable clock rates, and set the delay statement to one of these rates, with the INT_RC fuse, the compiler automatically setup the internal oscillator to 'match'. When this works, you don't need the setup_oscillator line at all. However as with most CCS 'features', it has a habit of not working on particular chips......

Best Wishes
rovtech



Joined: 24 Sep 2006
Posts: 288

View user's profile Send private message AIM Address

PostPosted: Thu Dec 10, 2009 2:04 pm     Reply with quote

Note that

setup_oscillator(OSC_16MHZ);// setup the internal oscilator

did not work either. As I said, CCS tells me the problem is corrected in the latest compiler. I believe this problem is probably specific to the 16F722 (but maybe others others).
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page Previous  1, 2
Page 2 of 2

 
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