View previous topic :: View next topic |
Author |
Message |
ralph79
Joined: 29 Aug 2007 Posts: 87
|
16F688 rs232 problems |
Posted: Mon Apr 14, 2008 12:31 pm |
|
|
I have a 16f688 connected to an RF receiver (TDA5200). The DATA pin of the TDA is connected to the RC5 of the 16F688.
Initially I have the TDA5200 with a crystal of 13.225625 with tolerances (60ppm) and load capacitance (40pF) quite higher than it was supposed.
With these crystal the system works quite well with the 16F688 at 9600 bps using the internal oscillator at 4Mhz or at 8Mhz.
But now I find another crystal with the exact frequency but with much better tolerances (20 ppm) and CL (12pF).
I thought that with these new crystal my system should work much better. But now with the better crystal, I only can work at 4800bps and with internal clock at 4Mhz. If I put the internal clock at 8Mhz it doesn't work.
At this moment I have:
Code:
#include <16F688.h>
#device *=16
#fuses INTRC_IO,NOWDT,PUT, NOPROTECT,NOMCLR,BROWNOUT,NOIESO,NOFCMEN
#use delay(clock=4000000)
#use rs232(baud=4800, parity=N, xmit=PIN_C4, rcv=PIN_C5, bits=8, STOP=1, errors)
#use fast_io(A)
#use fast_io(C)
void main (void)
{
setup_oscillator(OSC_8MHZ);
setup_adc_ports(NO_ANALOGS|VSS_VDD); // Make PORT A Inputs Digital
setup_adc(ADC_OFF); // Turn OFF ADC
setup_comparator(NC_NC); // Disconnect Comparators
setup_vref(FALSE);
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_256);
setup_timer_1(T1_INTERNAL|T1_DIV_BY_4);
enable_interrupts(INT_RDA);
enable_interrupts(INT_TIMER0);
enable_interrupts(INT_TIMER1);
set_tris_a(0b00100000);
set_tris_c(0b00100000);
port_a_pullups(0b00100000);
enable_interrupts(GLOBAL);
while(TRUE)
{
//....................
}
}
I have been watching the 16F688 data sheet and at 8Mhz the micro is well capable of work at 9600bps, the error is quite low.
One more thing my version is the 4.0.65 |
|
|
ralph79
Joined: 29 Aug 2007 Posts: 87
|
|
Posted: Mon Apr 14, 2008 12:36 pm |
|
|
Sorry in my last post I've an error, during my tests I've putted
Code: |
setup_oscillator(OSC_8MHZ);
|
but actually this is:
Code: |
setup_oscillator(OSC_4MHZ);
|
Regards |
|
|
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Mon Apr 14, 2008 4:48 pm |
|
|
Quote: | But now I find another crystal with the exact frequency but with much better tolerances (20 ppm) and CL (12pF). | It is possible the TD5200 is not running at the exact frequency you think it is.
What is the frequency of the new crystal?
What series capacitor have you placed between the crystal and the TDA5200? |
|
|
ralph79
Joined: 29 Aug 2007 Posts: 87
|
|
Posted: Tue Apr 15, 2008 2:26 am |
|
|
Dear ckielstra,
The frequency of the new crystal is the same of the older one (13.225625Mhz).
I have boards with the older and the with the new crystal.
The circuit is same, if I change the new crystal with the older one, I can run at 9600bps.
With the new crystal I can only work at 4800 bps and with the internal oscillator at 4Mhz.
If I change the internal oscillator of the 16F688 to 8Mhz, neither at 4800 bps it works.
So I suspect that is something with 16F688.
If it was a problem with the circuit, crystal or others, if I put the rs232 at 4800 bps, the 16F688 should work fine such at 4Mhz such as 8MHz. Right?
But no, neither with the older crystal it works at 8Mhz.
So to summarize, my application works at:
-> 4800 bps - with the internal oscillator at 4Mhz and only with this frequency, both with the older and new crystal.
-> 9600 bps - only the older crystal with the internal oscillator at 4Mhz or at 8Mhz.
Do you think that is a different problem?
Best regards, |
|
|
Ttelmah Guest
|
|
Posted: Tue Apr 15, 2008 2:39 am |
|
|
Cl is specified as 12pF. What capacitor are you using? What capacitor was used with the old crystal?. How is the oscillator section of the board laid out?.
I'd suspect there is more board capacitance than you have perhaps allowed for, and the new crystal is running close to the edge of the allowable tolerance range.
Best Wishes |
|
|
ralph79
Joined: 29 Aug 2007 Posts: 87
|
|
Posted: Tue Apr 15, 2008 4:44 am |
|
|
Dear Ttelmah,
At this moment I've changed my receiver from the TDA5200 to the TDA5210.
The pinout is the same I've only changed some values.
But the problem is the same.
At this moment I'm using the capacitors values suggested by Infineon (8,2pF and 22pF).
The capacitors I'm using have a tolerance of 2%.
Should I increase/decrease the values suggested by Infineon?
Regards |
|
|
|