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

How to select external crystal at 11.0592 MHz ?

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



Joined: 14 Aug 2015
Posts: 12

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

How to select external crystal at 11.0592 MHz ?
PostPosted: Sun Aug 30, 2015 2:47 am     Reply with quote

hi this is aul, I am trying to do simple serial print but am getting fail. I am getting simulation output but in my hardware i get special char. What is the problem? Please anyone help me.
Code:

#include<16f877a.h>
#fuses XT,HS, NOPROTECT, PUT, NOWDT, NOLVP
#use delay(clock=11059200)
#use rs232(baud=9600,xmit=pin_c6,rcv=pin_c7)

void main()
{
char d='a';

set_tris_d(0);
set_tris_a(0x00);
set_tris_c(0x80);
set_tris_b(0x00);
output_b(0);

while(1)
  {
   output_b(0xff);
   delay_ms(100);
   output_b(0x00);
   delay_ms(100);
   putc(d);
   putc(d);
   putc(d);
   putc(d);
  }
}
Ttelmah



Joined: 11 Mar 2010
Posts: 19513

View user's profile Send private message

PostPosted: Sun Aug 30, 2015 3:50 am     Reply with quote

First critical thing get rid of XT.

You can only ever select _one_ oscillator. Currently you have a crystal<=4MHz, and a crystal>4MHz both selected at once (XT,HS).

It should override and select just the second, but maybe not (depending on compiler version).

Then are you sure you have the right capacitors on the crystal?. Commonest cause of a crystal running off frequency is an error with these, perhaps selecting nF, instead of pF.

Then are you sure the crystal is the right type?. Parallel cut?.
arulchozhan



Joined: 14 Aug 2015
Posts: 12

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

PostPosted: Sun Aug 30, 2015 4:19 am     Reply with quote

thank you for you reply
am modify this in my earlier code
#fuse HS
#use delay (clock=11059200,EXTERNAL)

this think arte modified my code but still am getting this same error. am using ccs v4.01.
if suppose am set #use delay (clock=20000000,EXTERNAL) instead of #use delay (clock=11059200,EXTERNAL) am getting some chunk value in my serial window. am still confused because am using 11.0592 mhz only but the time no value came in serial but set 20 mhz am getting some special character(chunk value) but both setting the led are blink.so please give any idea to solve this problem.
my crystal capacitor range is 22 pf
Ttelmah



Joined: 11 Mar 2010
Posts: 19513

View user's profile Send private message

PostPosted: Sun Aug 30, 2015 4:45 am     Reply with quote

4.01, is not a CCS compiler version number. It is always x.xxx. Look at the top of the .lst file.

Forget RS232. Stick a single LED on a pin of the PIC (with a suitable current limiting resistor), and run a simple program to toggle this pin at 1 second intervals. So something like:
Code:

#include<16f877a.h>
#fuses HS, NOPROTECT, PUT, NOWDT, NOLVP
#use delay(clock=11059200)

void main()
{
   char d='a';
   while (TRUE)
   {
       output_toggle(PIN_B0);
       delay_ms(1000);
   }
}   


This needs to be changing the LED once per second, before you try anything else.

Do things one step at a time.
temtronic



Joined: 01 Jul 2010
Posts: 9226
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Sun Aug 30, 2015 5:04 am     Reply with quote

Have you got a MAX232 or equal connected between the PIC and teh PC ? This must be there otherwise the serial data is inverted and you'll get 'garbage'.
22pf seems top be high for me, I think 15 pf might be better depending on PCB layout.

Mr. T is right though , get the 1Hz flashing LED program running first THEN proceed to getting serial program running.

Jay
arulchozhan



Joined: 14 Aug 2015
Posts: 12

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

PostPosted: Sun Aug 30, 2015 5:10 am     Reply with quote

Sorry my version is v4.057. I am getting led blink but in serial output not getting in am posting a code how can I solve? I check my hardware and that work (test by short c6 and c7. if type, I am getting typing in my serial window) .
So please what error in serial function?
temtronic



Joined: 01 Jul 2010
Posts: 9226
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Sun Aug 30, 2015 6:28 am     Reply with quote

Please repost your current version of code.
perhaps you changed something ?

Jay
Ttelmah



Joined: 11 Mar 2010
Posts: 19513

View user's profile Send private message

PostPosted: Sun Aug 30, 2015 7:30 am     Reply with quote

Is the LED at exactly the right rate?. Count ten flashes against a stopwatch.

4.057, is a rather low number for a V4 compiler. There were a lot of bugs still at these sort of version numbers, _but_ something as basic as simple RS232 will work, but only if the clock is right, and the interface is right (so check the exact rate the chip is running, and tell us the circuit you are using to drive the RS232 - you _need_ an RS232 driver chip).
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