View previous topic :: View next topic |
Author |
Message |
arulchozhan
Joined: 14 Aug 2015 Posts: 12
|
How to select external crystal at 11.0592 MHz ? |
Posted: Sun Aug 30, 2015 2:47 am |
|
|
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
|
|
Posted: Sun Aug 30, 2015 3:50 am |
|
|
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
|
|
Posted: Sun Aug 30, 2015 4:19 am |
|
|
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
|
|
Posted: Sun Aug 30, 2015 4:45 am |
|
|
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
|
|
Posted: Sun Aug 30, 2015 5:04 am |
|
|
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
|
|
Posted: Sun Aug 30, 2015 5:10 am |
|
|
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
|
|
Posted: Sun Aug 30, 2015 6:28 am |
|
|
Please repost your current version of code.
perhaps you changed something ?
Jay |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19513
|
|
Posted: Sun Aug 30, 2015 7:30 am |
|
|
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). |
|
|
|