View previous topic :: View next topic |
Author |
Message |
cerr
Joined: 10 Feb 2011 Posts: 241 Location: Vancouver, BC
|
18f8722->18j87k22 |
Posted: Thu Feb 24, 2011 12:05 pm |
|
|
Hi There,
I'm porting my code from an 18f8722 to an 18f87k22. I assume it should be working pretty much the same but the first problem is, the K version doesn't take:
#FUSES HS
and
#FUSES NOLVP
the header file says:
Fuses: SOSC_HIGH,NOXINST,XINST,LP,XT,HSH,HSM,ECH,ECH_IO,RC,RC_IO
but I'm not sure of the difference between hsh or HSM. What should I be using? I'm using a 10MHz crystal oscillator. Also, what about the NOLVP/ Can I just leave it out?
Thanks! |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Feb 24, 2011 12:40 pm |
|
|
Download the PIC data sheet.
Type this into Google:
That takes you to the web page for that PIC and the data sheet:
http://ww1.microchip.com/downloads/en/DeviceDoc/39960b.pdf
Look in the oscillator section:
Quote: |
3.1 Oscillator Types
HS1 is the Medium power mode with a frequency range
of 4 MHz to 16 MHz. HS2 is the High-Power mode, where
the oscillator frequency can go from 16 MHz to 25 MHz.\
|
So it's obvious that CCS has renamed the modes (for some strange
reason) to HSM (medium) and HSH (High power). |
|
![](templates/subSilver/images/spacer.gif) |
cerr
Joined: 10 Feb 2011 Posts: 241 Location: Vancouver, BC
|
|
Posted: Thu Feb 24, 2011 12:49 pm |
|
|
PCM programmer wrote: | Download the PIC data sheet.
Type this into Google:
That takes you to the web page for that PIC and the data sheet:
http://ww1.microchip.com/downloads/en/DeviceDoc/39960b.pdf
Look in the oscillator section:
Quote: |
3.1 Oscillator Types
HS1 is the Medium power mode with a frequency range
of 4 MHz to 16 MHz. HS2 is the High-Power mode, where
the oscillator frequency can go from 16 MHz to 25 MHz.\
|
So it's obvious that CCS has renamed the modes (for some strange
reason) to HSM (medium) and HSH (High power). |
Thank you, I was looking at the datasheet and got confused why it would be HSH & HSM instead of HS1 & HS2 but your solution sounds like a possible way to go......
Thanks |
|
![](templates/subSilver/images/spacer.gif) |
cerr
Joined: 10 Feb 2011 Posts: 241 Location: Vancouver, BC
|
|
Posted: Thu Feb 24, 2011 1:07 pm |
|
|
However, non of them seems to be the correct one either. I can tell by getting a weird character on my rs-232 at 9600 baud and I set a pin high for 200us but it's up for ~50us only. I'm looking at it with my scope....any other clues maybe?
Thanks! |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Feb 24, 2011 1:46 pm |
|
|
Well, that's a clue. It's running 4x faster than expected. Again, look in
the PIC data sheet. Look for something that makes it run 4x faster.
Data sheet says:
Quote: |
3.1 Oscillator Types
There is also an option for running the 4xPLL on any of
the clock sources in the input frequency range of 4 to
16 MHz.
The PLL is enabled by setting the PLLCFG bit
(CONFIG1H<4>) or the PLLEN bit (OSCTUNE<6>). |
Then look at the end of your .LST file, to see what fuses the compiler
is using. It's obvious that it's enabling the PLL:
Quote: | Configuration Fuses:
Word 1: D31D VREGSLEEP INTRC_HP SOSC_HIGH NOXINST HSM PLLEN FCMEN IESO
Word 2: 7C7E PUT BROWNOUT BORV18 ZPBORM NOWDT WDT1048576
Word 3: 8BF9 RTCOSC_T1 EXTADDRSFT ABW20 BW16 NOWAIT CCP2C1 ECCPE MSSPMSK7 MCLR
Word 4: 0091 STVREN BBSIZ2K NODEBUG
Word 5: C0FF NOPROTECT NOCPB NOCPD
Word 6: E0FF NOWRT NOWRTC NOWRTB NOWRTD
Word 7: 40FF NOEBTR NOEBTRB |
Next, look at the top of the 18F87K22.h file and look for a fuse setting
that will disable the PLL. Add that to your #fuses statement. |
|
![](templates/subSilver/images/spacer.gif) |
cerr
Joined: 10 Feb 2011 Posts: 241 Location: Vancouver, BC
|
|
Posted: Thu Feb 24, 2011 2:00 pm |
|
|
PCM programmer wrote: | Well, that's a clue. It's running 4x faster than expected. Again, look in
the PIC data sheet. Look for something that makes it run 4x faster.
Data sheet says:
Quote: |
3.1 Oscillator Types
There is also an option for running the 4xPLL on any of
the clock sources in the input frequency range of 4 to
16 MHz.
The PLL is enabled by setting the PLLCFG bit
(CONFIG1H<4>) or the PLLEN bit (OSCTUNE<6>). |
Then look at the end of your .LST file, to see what fuses the compiler
is using. It's obvious that it's enabling the PLL:
Quote: | Configuration Fuses:
Word 1: D31D VREGSLEEP INTRC_HP SOSC_HIGH NOXINST HSM PLLEN FCMEN IESO
Word 2: 7C7E PUT BROWNOUT BORV18 ZPBORM NOWDT WDT1048576
Word 3: 8BF9 RTCOSC_T1 EXTADDRSFT ABW20 BW16 NOWAIT CCP2C1 ECCPE MSSPMSK7 MCLR
Word 4: 0091 STVREN BBSIZ2K NODEBUG
Word 5: C0FF NOPROTECT NOCPB NOCPD
Word 6: E0FF NOWRT NOWRTC NOWRTB NOWRTD
Word 7: 40FF NOEBTR NOEBTRB |
Next, look at the top of the 18F87K22.h file and look for a fuse setting
that will disable the PLL. Add that to your #fuses statement. |
That was the way to go. I'm sorry, I'm asking stupid questions but I've only been using CCS for a couple of days and need to find my ways around first... Thank you very much tho for the patient answer! It properly resolved my issue! ![Smile](images/smiles/icon_smile.gif) |
|
![](templates/subSilver/images/spacer.gif) |
|