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

18f8722->18j87k22

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



Joined: 10 Feb 2011
Posts: 241
Location: Vancouver, BC

View user's profile Send private message

18f8722->18j87k22
PostPosted: Thu Feb 24, 2011 12:05 pm     Reply with quote

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!
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Feb 24, 2011 12:40 pm     Reply with quote

Download the PIC data sheet.
Type this into Google:
Quote:
PIC18F87K22

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).
cerr



Joined: 10 Feb 2011
Posts: 241
Location: Vancouver, BC

View user's profile Send private message

PostPosted: Thu Feb 24, 2011 12:49 pm     Reply with quote

PCM programmer wrote:
Download the PIC data sheet.
Type this into Google:
Quote:
PIC18F87K22

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
cerr



Joined: 10 Feb 2011
Posts: 241
Location: Vancouver, BC

View user's profile Send private message

PostPosted: Thu Feb 24, 2011 1:07 pm     Reply with quote

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!
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Feb 24, 2011 1:46 pm     Reply with quote

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.
cerr



Joined: 10 Feb 2011
Posts: 241
Location: Vancouver, BC

View user's profile Send private message

PostPosted: Thu Feb 24, 2011 2:00 pm     Reply with quote

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... Rolling Eyes Thank you very much tho for the patient answer! It properly resolved my issue! Smile
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