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 support@ccsinfo.com

16F688 rs232 problems

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



Joined: 29 Aug 2007
Posts: 87

View user's profile Send private message

16F688 rs232 problems
PostPosted: Mon Apr 14, 2008 12:31 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Mon Apr 14, 2008 12:36 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Mon Apr 14, 2008 4:48 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Tue Apr 15, 2008 2:26 am     Reply with quote

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







PostPosted: Tue Apr 15, 2008 2:39 am     Reply with quote

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

View user's profile Send private message

PostPosted: Tue Apr 15, 2008 4:44 am     Reply with quote

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
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