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 CCS Technical Support

H4 Fuse with External Oscillator on 18f14k22 way off!

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



Joined: 21 Nov 2006
Posts: 129

View user's profile Send private message

H4 Fuse with External Oscillator on 18f14k22 way off!
PostPosted: Wed Jul 14, 2010 2:20 pm     Reply with quote

I'm using PCH version 4.092 with a 18F14K22. I've got a 10.000mHz crystal with 18pF capacitors.

The following, as verified on a scope, gives about the right timing (seems to be about 12us instead of the expected 10, but in the ballpark at least):

Code:
#include <18f14k22.h>

#fuses HS,WDT256,NOMCLR,NOWDT,NOBROWNOUT,BORV22,NOLVP
#fuses NOPROTECT,NOCPD,NOCPB,NOWRT,NOWRTD,NOWRTB,NOWRTC,NOEBTR,NOEBTRB

#use delay(clock=10000000)

void main() {
     while(1) {
          output_low(PIN_C1);
          delay_us(10);
          output_high(PIN_C1);
          delay_us(10);
     }
}


But when I try to get 40mHz out of it with the following code, the pulse takes 400us! Exactly 40 times what it should.

Code:
#include <18f14k22.h>

#fuses H4,WDT256,NOMCLR,NOWDT,NOBROWNOUT,BORV22,NOLVP
#fuses NOPROTECT,NOCPD,NOCPB,NOWRT,NOWRTD,NOWRTB,NOWRTC,NOEBTR,NOEBTRB

#use delay(clock=40000000)

void main() {
     while(1) {
          output_low(PIN_C1);
          delay_us(10);
          output_high(PIN_C1);
          delay_us(10);
     }
}


Is this a compiler bug? Could someone compile this code with a newer version and PM the hex file to me so I can try it?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Jul 14, 2010 3:18 pm     Reply with quote

Edit your 2nd program:

1. Change the H4 fuse to HS.

2. Add this line to the beginning of main():
Code:

setup_oscillator(OSC_PLL_ON);
evsource



Joined: 21 Nov 2006
Posts: 129

View user's profile Send private message

PostPosted: Thu Jul 15, 2010 4:19 pm     Reply with quote

PCM programmer wrote:
Edit your 2nd program:

1. Change the H4 fuse to HS.

2. Add this line to the beginning of main():
Code:

setup_oscillator(OSC_PLL_ON);


Ah, okay, thanks. Who would have thought?!
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