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 support@ccsinfo.com

#use delay() differences compared to just fuses

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



Joined: 30 Sep 2003
Posts: 89

View user's profile Send private message

#use delay() differences compared to just fuses
PostPosted: Fri May 02, 2014 1:51 pm     Reply with quote

18F87j50
CCS compiler 5.025

I had an issue with some code where changing the processor speed would give the the wrong baud rate (and timer rate).

I finally built a very simple led flasher with RS232 printf statements.

I used the wizard and found it created a statement:
Code:
#use delay(clock=48000000,oscillator=12000000)

and the code worked!

If I used:
Code:

#fuses PLL3, NOCPUDIV, ECPLL
#use delay(clock=48000000)

and the code did NOT work.

The fuses as shown in the LST file were identical, but there were code differences.
Code:

Configuration Fuses:
   Word  1: F7AA   NOWDT PLL3 STVREN NOXINST NODEBUG NOCPUDIV NOPROTECT
   Word  2: F7C7   ECPLL FCMEN IESO WDT128
   Word  3: FFF8   EASHFT MCU BW16 NOWAIT CCP2C1 ECCPE PMPEMB MSSPMSK7

While I could probably figure out the purpose of the differences, given enough time, I was hoping someone would know what the additional code does, and how, if not for accidentally finding this use delay option, I would never have known this.

Now I could swear this worked ok when I was using version 4.xxx, but I will have to take a trip down memory lane to check that out.
_________________
-Pete
Ttelmah



Joined: 11 Mar 2010
Posts: 19393

View user's profile Send private message

PostPosted: Sat May 03, 2014 12:22 am     Reply with quote

You'll find the extra code, is the equivalent of adding 'setup_oscillator(OSC_NORMAL)'.

This type of behaviour is getting more common (especially on the PIC24's), where as well as setting the fuses, there has to be a configuration of some registers to setup the clock. The extended clock statement, tries (for instance) to setup the PLL used on these, while the simpler clock statement leaves this unconfigured.
Generally, on the later compilers it is safer to use the extended clock setup, and only get involved in the manual clock fuses if this doesn't work right.

Best Wishes
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