View previous topic :: View next topic |
Author |
Message |
ALPL
Joined: 29 Mar 2009 Posts: 30
|
Re: RS232 misbehaviour |
Posted: Sat Dec 31, 2011 9:21 am |
|
|
cse307 wrote: | ALPL wrote: | cse307 wrote: | ALPL wrote: | Next to a possible GND-problem you may not have put a 0.1µF capacitor between Vdd and Vss or the MCLR-pin is not connected/set properly. |
the MCLR-pin connected correctly i test it But i did not put a 0.1uF cap is it important?? |
Better try with the 0.1µF capacitor. |
i put the Cap between Vcc and Ground?
i will try it when i have one.
thanks for helping me |
Yes, you must put a 0.1µF cap between Vdd and Vss and also 1 0.1µF cap between MCLR and GND (together with a 10K resistor between MCLR and GND). |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19545
|
|
Posted: Sat Dec 31, 2011 9:28 am |
|
|
Er. That will stop the chip running. MCLR needs to be pulled _up_, not to GND.
Best Wishes |
|
|
ALPL
Joined: 29 Mar 2009 Posts: 30
|
|
Posted: Sat Dec 31, 2011 10:31 am |
|
|
Ttelmah wrote: | Er. That will stop the chip running. MCLR needs to be pulled _up_, not to GND.
Best Wishes |
Yes, my mistake - you are right. The resistor to the power line (eg 5V) and not to GND. |
|
|
cse307
Joined: 03 Oct 2011 Posts: 25
|
|
Posted: Sun Jan 01, 2012 6:30 pm |
|
|
ALPL wrote: | Ttelmah wrote: | Er. That will stop the chip running. MCLR needs to be pulled _up_, not to GND.
Best Wishes |
Yes, my mistake - you are right. The resistor to the power line (eg 5V) and not to GND. |
so, i just need one Cap 0.1uF between Vcc and GND.
Dose the crystal oscillator make any difference if goes from 4MHz to 20MHz??
Because i reprogrammed the PIC with just the Printf() to print the text on the screen using RS232 and put some delays and it worked(with the original code NOT). BUT when just replaced the crystal oscillator to 20MHz and of course include it in Code, it returned to same problem !! the baud rate did not changed (9600)? |
|
|
ALPL
Joined: 29 Mar 2009 Posts: 30
|
|
Posted: Mon Jan 02, 2012 12:33 am |
|
|
cse307 wrote: | ALPL wrote: | Ttelmah wrote: | Er. That will stop the chip running. MCLR needs to be pulled _up_, not to GND.
Best Wishes |
Yes, my mistake - you are right. The resistor to the power line (eg 5V) and not to GND. |
so, i just need one Cap 0.1uF between Vcc and GND.
Dose the crystal oscillator make any difference if goes from 4MHz to 20MHz??
Because i reprogrammed the PIC with just the Printf() to print the text on the screen using RS232 and put some delays and it worked(with the original code NOT). BUT when just replaced the crystal oscillator to 20MHz and of course include it in Code, it returned to same problem !! the baud rate did not changed (9600)? |
Did you adjust the capacitor values for the 20MHz-crystal (see PIC datasheet)? |
|
|
cse307
Joined: 03 Oct 2011 Posts: 25
|
|
Posted: Tue Jan 03, 2012 9:10 am |
|
|
I am using 22pF for 4MHz and I did not change them for 20MHz. Do I need to ? |
|
|
ALPL
Joined: 29 Mar 2009 Posts: 30
|
|
Posted: Tue Jan 03, 2012 9:50 am |
|
|
cse307 wrote: | I am using 22pF for 4MHz and I did not change them for 20MHz. Do I need to ? |
Check the data sheet first! And then try if the values given by the data sheet work with you project or not - if not -you must try! Normally 20pF-caps should work for 20MHz - for 4MHz 15pF are recommended. |
|
|
cse307
Joined: 03 Oct 2011 Posts: 25
|
|
Posted: Tue Jan 03, 2012 9:57 am |
|
|
ALPL wrote: | cse307 wrote: | I am using 22pF for 4MHz and I did not change them for 20MHz. Do I need to ? |
Check the data sheet first! And then try if the values given by the data sheet work with you project or not - if not -you must try! Normally 20pF-caps should work for 20MHz - for 4MHz 15pF are recommended. |
i don't have a 15pF for now. the 22pf looks it works good with 4MHz and it is in the range 20MHz Cap's in the data sheet. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19545
|
|
Posted: Tue Jan 03, 2012 10:22 am |
|
|
Actually the 'data sheet' has _nothing_ to do with the capacitor values that should be used, unless you are using exactly the crystal models recommended by Microchip....
The _crystal_ will have a specified loading capacitance. The capacitor values want to each be twice this capacitance, less the stray capacitance of the track and the PIC pin.
The data sheet values are calculated for the example crystals _only_, and assuming the board layout is done as in MicroChip's oscillator application note (no ground plane round the crystal legs, short runs etc..).
However, provided the value is not wildly wrong, the oscillator will run, but the frequency accuracy will be poor, really making it pointless spending for a crystal in the first place.
Best Wishes |
|
|
ALPL
Joined: 29 Mar 2009 Posts: 30
|
|
Posted: Tue Jan 03, 2012 11:02 am |
|
|
Ttelmah wrote: | Actually the 'data sheet' has _nothing_ to do with the capacitor values that should be used, unless you are using exactly the crystal models recommended by Microchip....
The _crystal_ will have a specified loading capacitance. The capacitor values want to each be twice this capacitance, less the stray capacitance of the track and the PIC pin.
The data sheet values are calculated for the example crystals _only_, and assuming the board layout is done as in MicroChip's oscillator application note (no ground plane round the crystal legs, short runs etc..).
However, provided the value is not wildly wrong, the oscillator will run, but the frequency accuracy will be poor, really making it pointless spending for a crystal in the first place.
Best Wishes |
It may be so for very accurate reflections - but even with the internal RC-clock the PICs are very accurate - accurate enough eg for a RTC design which is wrong only 1-2 sec per months (max!). I have some PIC12F683 run accurately for 4 months without deviation! |
|
|
cse307
Joined: 03 Oct 2011 Posts: 25
|
|
Posted: Tue Jan 03, 2012 1:08 pm |
|
|
Ttelmah wrote: | Actually the 'data sheet' has _nothing_ to do with the capacitor values that should be used, unless you are using exactly the crystal models recommended by Microchip....
The _crystal_ will have a specified loading capacitance. The capacitor values want to each be twice this capacitance, less the stray capacitance of the track and the PIC pin.
The data sheet values are calculated for the example crystals _only_, and assuming the board layout is done as in MicroChip's oscillator application note (no ground plane round the crystal legs, short runs etc..).
However, provided the value is not wildly wrong, the oscillator will run, but the frequency accuracy will be poor, really making it pointless spending for a crystal in the first place.
Best Wishes |
what do you recommend to have a very good frequency accuracy for PIC16f877a with 4MHz OR 20MHz ?? |
|
|
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Tue Jan 03, 2012 2:25 pm |
|
|
ALPL wrote: | It may be so for very accurate reflections - but even with the internal RC-clock the PICs are very accurate - accurate enough eg for a RTC design which is wrong only 1-2 sec per months (max!). I have some PIC12F683 run accurately for 4 months without deviation! | I'm happy for you your PIC is this accurate, but according to the specifications this is not something you can account on.
See the datasheet, Table 15-2, parameter OS08: Quote: | Internal Calibrated HFINTOSC Frequency
± 1% Min:7.92 Typ:8.0 Max:8.08 MHz VDD = 3.5V, 25°C |
This means the deviation could be as bad as 36 seconds every hour. |
|
|
SherpaDoug
Joined: 07 Sep 2003 Posts: 1640 Location: Cape Cod Mass USA
|
|
Posted: Tue Jan 03, 2012 3:25 pm |
|
|
ALPL wrote: | cse307 wrote: | I am using 22pF for 4MHz and I did not change them for 20MHz. Do I need to ? |
Check the data sheet first! And then try if the values given by the data sheet work with you project or not - if not -you must try! Normally 20pF-caps should work for 20MHz - for 4MHz 15pF are recommended. |
It is the data sheet of the CRYSTAL that rules here. If you are only looking for +/- 1% for serial comms the exact capacitance does not matter much. But if you are building an alarm clock to keep within 5 minutes per year you need to run your crystal within 10ppm which will require paying attention to these details. The basic frequency, 4MHz vs. 20MHz does not matter. _________________ The search for better is endless. Instead simply find very good and get the job done. |
|
|
|