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

crystal

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



Joined: 25 Sep 2010
Posts: 4
Location: Brazil

View user's profile Send private message

crystal
PostPosted: Sat Sep 25, 2010 1:12 pm     Reply with quote

Friends, I am with this source code.
Used with external crystal oscillator XT.
Circuit works in my one week or more.
And for no reason to swing.
I changed the crystal.
Is connected to a resistor 4k7 MCLR (pin4) to +5 v.
leaving the PWM (pin 8) in series with 1K resistor.
4MHz crystal pin 15 and 16 with 22pf capacitor to GND.
It should be alright.
Because for swinging for no reason.


Internal oscillator is no longer accurate.
I need.
I want one with crystal and 100kHz Where am I wrong?
_________________
silvanoservitec


Last edited by silvanoservitec on Sat Feb 05, 2011 12:39 pm; edited 2 times in total
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Sep 26, 2010 5:40 pm     Reply with quote

What is your CCS compiler version ? It's given at the top of the .LST file.
It's a number like 3.249 or 4.112, etc.
silvanoservitec



Joined: 25 Sep 2010
Posts: 4
Location: Brazil

View user's profile Send private message

PostPosted: Sun Sep 26, 2010 6:23 pm     Reply with quote

Thank you for your attention
PCM Programer.
the compiler version is: "CCS PCM C Compiler, Version 4.068,"

I wonder if this source code.
Is complete and true.
sds
silvanoservitec.
_________________
silvanoservitec
Ttelmah



Joined: 11 Mar 2010
Posts: 19539

View user's profile Send private message

PostPosted: Mon Sep 27, 2010 1:57 am     Reply with quote

4.068, was 'on the border', where the version 4 compilers, first started to work. For 99% of simple code, this should probably work. However it did have some configuration problems with some chips, and might be giving problems. I haven't kept any of the V4 compilers before 4.070, which was the first that I found would generate pretty much usable code, so can't verify if your version would work. Classic problems for chips like yours, are that the early compilers often don't initialize things like the ADC pins correctly, but this shouldn't affect what you are trying to do.

Now, taking your original code:
Fosc=4MHz.
Timer2 is being fed off 1MHz.
As shown, you have it counting to 10, so should see 100KHz.
The duty cycle though will only be 30% high, not the 50% you refer to.
To change this to work off an external 4MHz crystal, and give 50%, would need:
Code:

#include <16F818.h>
#fuses XT, NOWDT, MCLR, PUT, BROWNOUT //Switch to using Xtal OSC
#use delay(clock=4000000)

//=============================
void main() {
   setup_ccp1(CCP_PWM);
   setup_timer_2(T2_DIV_BY_1, 9, 1);
   set_pwm1_duty(5);   //For 5/10 duty cycle.
   
   while(1);
}


Best Wishes
silvanoservitec



Joined: 25 Sep 2010
Posts: 4
Location: Brazil

View user's profile Send private message

PostPosted: Mon Sep 27, 2010 2:34 pm     Reply with quote

Ttelmah ok thanks, sorry, was my mistake to post.
I made many tests with this code.
and just posting (set_pwm1_duty (3);) I'm using ((5))).
installed version CCS PCM C Compiler, Version 4088
and compiled.
I will write an internal oscillator with pic and test a few days.

I was lost faith in this code.

sds Laughing
silvanoservitec
_________________
silvanoservitec
Gabriel



Joined: 03 Aug 2009
Posts: 1067
Location: Panama

View user's profile Send private message

PostPosted: Tue Sep 28, 2010 6:51 am     Reply with quote

i might have misunderstood but, you mentioned you changed the crystal...

this would change all your timing schemes...
you would need to adjust timers and prescalers... etc...

... that be my first guess....


Ttelmah seems to have solved the timing issues for you....
_________________
CCS PCM 5.078 & CCS PCH 5.093
silvanoservitec



Joined: 25 Sep 2010
Posts: 4
Location: Brazil

View user's profile Send private message

PostPosted: Tue Sep 28, 2010 6:58 am     Reply with quote

Gabriel, I should have explained badly.
I am using a translator.(portugues-ingles)
I swapped the crystal for another one.
To determine whether the defect was pwm stop generating it.
sds
silvanoservitec
_________________
silvanoservitec
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