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

External Clock PIC16F688
Goto page 1, 2, 3  Next
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
quicksilver



Joined: 04 Feb 2009
Posts: 31

View user's profile Send private message Send e-mail

External Clock PIC16F688
PostPosted: Wed Mar 21, 2012 8:00 am     Reply with quote

Hey guys, I got very surprised the other day when I removed the crystal from my board and the PIC kept working. Surprisingly, I couldn't use the sleep routine. So, my doubt is... What fuse do I need to activate in order to my PIC works with an external clock???

I found this fuse: #fuse EC_IO. But I couldn't get my PIC working with an external clock. I put 4MHz crystal with two capacitors in the respective pins, but even with this, my PIC didn't start.

Thanks beforehand guys.
_________________
everything that has a beginning, has an end
asmboy



Joined: 20 Nov 2007
Posts: 2128
Location: albany ny

View user's profile Send private message AIM Address

PostPosted: Wed Mar 21, 2012 8:19 am     Reply with quote

post your code and compiler versioin
quicksilver



Joined: 04 Feb 2009
Posts: 31

View user's profile Send private message Send e-mail

PostPosted: Wed Mar 21, 2012 8:32 am     Reply with quote

I'm using Version 4.038. And the part of the code is this one.
Code:

#fuses XT, NOWDT, NOBROWNOUT, NOPUT, NOMCLR, EC_IO   
#use delay(clock=4000000)

And I think the fuses is the problem about this, because I don't have any more things in my code. If I remove the EC_IO the PIC will start working with or without an external clock. So, how can I tell to my compiler to use an external clock???.
_________________
everything that has a beginning, has an end
asmboy



Joined: 20 Nov 2007
Posts: 2128
Location: albany ny

View user's profile Send private message AIM Address

PostPosted: Wed Mar 21, 2012 9:43 am     Reply with quote

HAVE YOU TRIED HS instead of XT ??

#fuse PUT,HS ...... ??


YOU NEED TO allow PUT to operate with an ext crystal

you can see if you are getting oscillation on the osc OUT pin

of the pic on an oscilloscope too

you might s have a problem with the size ( or connection) of your crystal phasing capacitors too
quicksilver



Joined: 04 Feb 2009
Posts: 31

View user's profile Send private message Send e-mail

PostPosted: Wed Mar 21, 2012 9:58 am     Reply with quote

But if I'm using a 4MHz Crystal... Can I use the HS fuse???
_________________
everything that has a beginning, has an end
Ttelmah



Joined: 11 Mar 2010
Posts: 19499

View user's profile Send private message

PostPosted: Wed Mar 21, 2012 10:34 am     Reply with quote

Whoa.

You can only have _one_ oscillator fuse. If you are using an external oscillator module, EC_IO, and _get rid of HS, or XT_.
If you are using an external crystal (not a complete oscillator), then get rid of EC_IO, and just have HS or XT.

Having both gives an invalid oscillator configuration for either setup.....

The oscillator settings are mutually exclusive.

At 4Mhz, XT should work. HS 'may work' if the crystal gain is low, but can cause problems on some chips, with the input being overdriven.
However if you have a particularly low gain crystal, then HS may be needed.

Best Wishes
quicksilver



Joined: 04 Feb 2009
Posts: 31

View user's profile Send private message Send e-mail

PostPosted: Wed Mar 21, 2012 10:50 am     Reply with quote

Which value's capacitor you suggest??? I have 10pF.
_________________
everything that has a beginning, has an end
asmboy



Joined: 20 Nov 2007
Posts: 2128
Location: albany ny

View user's profile Send private message AIM Address

PostPosted: Wed Mar 21, 2012 11:04 am     Reply with quote

Quote:

I have 10pF.


depedns on XTAL SPEC

for 4 mhz AT cut i'd try 22pf or 33pf with XT fuse
quicksilver



Joined: 04 Feb 2009
Posts: 31

View user's profile Send private message Send e-mail

PostPosted: Wed Mar 21, 2012 12:14 pm     Reply with quote

OK guys... I'm trying to do this... because I think that my biggest problem is that I'm using the sleep routine, but, doesn't work, that's anybody has an example that works???
_________________
everything that has a beginning, has an end
Ttelmah



Joined: 11 Mar 2010
Posts: 19499

View user's profile Send private message

PostPosted: Wed Mar 21, 2012 12:37 pm     Reply with quote

Walk first.
Prove your chip is working, and at the right frequency.
Just do a 'toggle pin' routine, with a specified delay, and time that the delay is right.
Only move on to trying to sleep, once you are sure this is all working.

On sleep, depends what you want to wake it up?. Remember you can only wake using things that keep running, when the chip is asleep, The data sheet tells you what can do this. So, hardware interrupt - yes. Serial receive - no. Watchdog - yes, but relatively innacurate. Also remember it takes a long time to wake up the crystal.

Best Wishes
quicksilver



Joined: 04 Feb 2009
Posts: 31

View user's profile Send private message Send e-mail

PostPosted: Wed Mar 21, 2012 12:57 pm     Reply with quote

Guys, even I can't turn on a LED with this... what is the problem??? I can't find it... can someone point it out??? Please???

Code:
#include <16F688.H>
#fuses NOWDT, NOBROWNOUT, PUT, NOMCLR, EC_IO
#use delay(clock=4000000)


short flag_timer=0;


#int_TIMER1
void  TIMER1_isr(void)
{
   set_timer1(0);
   flag_timer=1;
}



void main()
{
   setup_timer_1(T1_EXTERNAL|T1_DIV_BY_8);
   enable_interrupts(INT_TIMER1);
   enable_interrupts(GLOBAL);
   
while(true){

   sleep();
   if(flag_timer)
   {
   flag_timer=0;
   output_high(pin_c5);
   delay_ms(100);
   output_low(pin_c5);
   }
}
}
[/code]
_________________
everything that has a beginning, has an end
drh



Joined: 12 Jul 2004
Posts: 192
Location: Hemet, California USA

View user's profile Send private message

PostPosted: Wed Mar 21, 2012 1:08 pm     Reply with quote

Change T1_EXTERNAL to T1_INTERNAL

Are you using an external oscillator or a xtal with capacitors? Your FUSE is set up for an external oscillator. For a xtal, use either XT or HS.
_________________
David
quicksilver



Joined: 04 Feb 2009
Posts: 31

View user's profile Send private message Send e-mail

PostPosted: Wed Mar 21, 2012 1:13 pm     Reply with quote

I tried all of them. If I remove the sleep routine, it will work, so I'm confuse... I need and external crystal to make the interruption, right??? that's anybody has a clue about what is going on here with this code???
_________________
everything that has a beginning, has an end
asmboy



Joined: 20 Nov 2007
Posts: 2128
Location: albany ny

View user's profile Send private message AIM Address

PostPosted: Wed Mar 21, 2012 2:35 pm     Reply with quote

Code:

#include <16F688.H>

#Fuses XT,NOWDT,PUT,NOMCLR,NOPROTECT,NOCPD,NOBROWNOUT,
#fuses NOIESO,NOFCMEN,

#use delay(clock=4000000)


void main() {

   while(true){
    output_toggle(pin_c5);
    delay_ms(100);
   }
}


does this work for you or not ???
quicksilver



Joined: 04 Feb 2009
Posts: 31

View user's profile Send private message Send e-mail

PostPosted: Wed Mar 21, 2012 2:42 pm     Reply with quote

Well... I'm trying to save energy, I have to save it... that's why I need to work with the sleep mode, So I'm trying to use the external clock to generate an interruption with the external clock, but, it doesn't work.
_________________
everything that has a beginning, has an end
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page 1, 2, 3  Next
Page 1 of 3

 
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