| View previous topic :: View next topic |
| Author |
Message |
mbradley
Joined: 11 Jul 2009 Posts: 118 Location: California, USA
|
|
Posted: Tue Dec 08, 2009 1:06 pm |
|
|
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
|
|
Posted: Tue Dec 08, 2009 1:37 pm |
|
|
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
|
|
Posted: Tue Dec 08, 2009 2:13 pm |
|
|
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
|
|
Posted: Tue Dec 08, 2009 2:34 pm |
|
|
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
|
|
Posted: Thu Dec 10, 2009 2:17 am |
|
|
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
|
|
Posted: Thu Dec 10, 2009 3:18 am |
|
|
| 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
|
|
Posted: Thu Dec 10, 2009 2:04 pm |
|
|
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). |
|
 |
|