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

fuses configuration

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



Joined: 03 Oct 2012
Posts: 227
Location: chennai

View user's profile Send private message

fuses configuration
PostPosted: Mon Jun 21, 2021 9:39 pm     Reply with quote

Code:
#include "18F2520.h"
#include "f2520_regs.h"
#fuses RC,NOWDT,NOPROTECT,PUT,CPB
#fuses NOWDT,NOPROTECT,INTRC_IO
#use delay(clock=32000000) // 32MHz


Main loop
Code:
setup_oscillator(OSC_32MHZ); //This automatically selects the PLL


Does the fuses configuration are ok?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Jun 21, 2021 10:24 pm     Reply with quote

hemnath wrote:
[code]#include "18F2520.h"
#include "f2520_regs.h"
#fuses RC,NOWDT,NOPROTECT,PUT,CPB
#fuses NOWDT,NOPROTECT,INTRC_IO

Look at the 18F2520 data sheet in the oscillator section. It says:
Quote:

2.1 Oscillator Types

RC - External Resistor/Capacitor with FOSC/4 Output on RA6

and
Quote:

Param 1A:

Fosc External CLKI Frequency: DC to 1 MHz Max - RC Oscillator mode


Do you want your PIC to run at 1 MHz with an external cap and resistor ?
hemnath



Joined: 03 Oct 2012
Posts: 227
Location: chennai

View user's profile Send private message

PostPosted: Mon Jun 21, 2021 11:51 pm     Reply with quote

I want to use internal oscillator to 32 MhZ and use the oscillator pins as output.
Ttelmah



Joined: 11 Mar 2010
Posts: 19195

View user's profile Send private message

PostPosted: Tue Jun 22, 2021 12:14 am     Reply with quote

OK.

Code:

   
#include "18F2520.h"
#include "f2520_regs.h"
#fuses NOWDT,NOPROTECT,INTRC_IO,PUT
#use delay(internal=32000000) // 32MHz   

//Just at the start of the main code. Not in a 'loop' of any sort
setup_oscillator(OSC_32MHZ); //This automatically selects the PLL


Now you were showing CPB, this would only be required if you were using
a bootloader in the protected block at the base of ROM. PUT is not 'needed'
with the INTRC, but does help give a little more time for the supply to
stabilise, so can help overall reliability.

Using the 'internal=' syntax, automatically sets up the oscillator fuses
for the internal clock. With this, depending on your compiler version,
you may not even need the setup_oscillator line. Basically on this
chip the PLL has to be enabled 'in code', rather than in the fuses, so
on old compilers you had to have the oscillator setup line to do this.
However newer compilers will automatically add this when 32MHz is
selected for the internal oscillator. [/code]
hemnath



Joined: 03 Oct 2012
Posts: 227
Location: chennai

View user's profile Send private message

PostPosted: Tue Jun 22, 2021 12:25 am     Reply with quote

Thanks for your reply.

Compiler version: 4.114
Ttelmah



Joined: 11 Mar 2010
Posts: 19195

View user's profile Send private message

PostPosted: Tue Jun 22, 2021 12:34 am     Reply with quote

Ouch. I suspect (actually am sure), you will need the setup_oscillator line then.
No, just checked, and you don't need it. That compiler does already do this.
It was about 4.100, where this feature was introduced.
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