View previous topic :: View next topic |
Author |
Message |
hemnath
Joined: 03 Oct 2012 Posts: 242 Location: chennai
|
fuses configuration |
Posted: Mon Jun 21, 2021 9:39 pm |
|
|
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
|
|
Posted: Mon Jun 21, 2021 10:24 pm |
|
|
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: 242 Location: chennai
|
|
Posted: Mon Jun 21, 2021 11:51 pm |
|
|
I want to use internal oscillator to 32 MhZ and use the oscillator pins as output. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19537
|
|
Posted: Tue Jun 22, 2021 12:14 am |
|
|
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: 242 Location: chennai
|
|
Posted: Tue Jun 22, 2021 12:25 am |
|
|
Thanks for your reply.
Compiler version: 4.114 |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19537
|
|
Posted: Tue Jun 22, 2021 12:34 am |
|
|
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. |
|
|
|