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

About using internal oscillator for soft serial comm?

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



Joined: 15 Jan 2007
Posts: 39

View user's profile Send private message Visit poster's website

About using internal oscillator for soft serial comm?
PostPosted: Thu Sep 13, 2007 8:38 am     Reply with quote

Hi,
I plan to use a 18F1320 with its Internal oscillator at 8Mhz (or 16F648A at 4Mhz) in a circuit to control I/O (mainly an LCD and 3 or 4 buttons).
For this design I MUST use RS232 communications at 9600bps (I must avoid Crystal and I have no external clock source).

Do you think that Software SUSART routines will be reliable at this rate? I know that temperature effects can alter PIC's internal oscillator precision, but what I want to know is : Does anyone used this solution in a real work and had problems? can you give your feedbacks please?

Regards
Octal
_________________
http://www.pocketmt.com the GLCD Font Creator home Smile
Ttelmah
Guest







PostPosted: Thu Sep 13, 2007 8:52 am     Reply with quote

The 1320, is fine, either with soft serial, or hardware, using the internal clock. provided your temperature range is 'reasonable' (office temperatures say). The allowable total timing error for RS232, depends on your word length etc., but is typically something in the order of 4%. If you assume the other end has 'good' timings, within perhaps 1%, then you can have up to perhaps 3% maximum error at the PIC. The internal oscillator on the 1320, manages a guaranteed +/-1% accuracy at 25C, degrading to +/-5% over the 'commercial' temperature range (-10 to +85C). I have tested a few of these oscillators, and have yet to find one that exceeds +/-2.5%, over the range 0C, to 50C, and so would consider this to be a happy range to use. If the part has to go into something experiencing a wider range than this, then problems become increasingly likely.

Best Wishes
SherpaDoug



Joined: 07 Sep 2003
Posts: 1640
Location: Cape Cod Mass USA

View user's profile Send private message

PostPosted: Thu Sep 13, 2007 11:27 am     Reply with quote

Also look at the voltage range. I think the internal oscillators are good at 5V, but the spec is quite wide at 3.3V or less (maybe the opposite).

If you can individually adjust the speed you can use 9792 baud or 9408 baud (9600 +/- 2%), the software UART wont care.
_________________
The search for better is endless. Instead simply find very good and get the job done.
libor



Joined: 14 Dec 2004
Posts: 288
Location: Hungary

View user's profile Send private message

PostPosted: Thu Sep 13, 2007 12:23 pm     Reply with quote

FYI: The 1320 has an enhanced hw USART (EUSART). It has a self-calibrating baudrate measuring function. All you have to do is turn this function on, and send a 0x55 (0101010101) to it. It will precisely calculate the proper baudrate counting register (BRG) value matching the sending device's baudrate independently of the actual oscillator clockrate in your device. You can store this calibrated value in EEPROM for having a individually tuned device afterwards, or even repeatedly recalibrate it during normal operation (or only when your device fails to communicate because of a possible baudrate mismatch)
There are many options, you might want implement this feature somehow in your product.

BTW: Why don't you want to use the hw USART ? This will result a much simpler code.
octal



Joined: 15 Jan 2007
Posts: 39

View user's profile Send private message Visit poster's website

PostPosted: Fri Sep 14, 2007 2:16 am     Reply with quote

libor wrote:

BTW: Why don't you want to use the hw USART ? This will result a much simpler code.


Simply because if I use Hardware USART I need to use a TTL level shifter/inverter like Max232 ... and
1- For reason costs I can not add such components (and widen by the way the PCB)
2- I will, may be, sell the programmed 18F1320 as a standalone programmed IC, and for that users will for sure be ennoyed if they have to use two or (1 with resistors) chips to interface their mcu with my chip.

anyway, thank you for these answers ...

Regards
Octal
_________________
http://www.pocketmt.com the GLCD Font Creator home Smile
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Fri Sep 14, 2007 2:56 am     Reply with quote

Quote:
Simply because if I use Hardware USART I need to use a TTL level shifter/inverter like Max232
I do not understand this. If your chip is to communicate directly with another microcontroller at the same PCB I agree that you do not want to add the costs of a level shifter but this has nothing to do with the choice between a hardware or software UART.

Maybe you are referring to the software UART's option to select the output polarity, i.e. inverted or not? This feature is missing in the hardware UART, but for a reason: it is hardly ever used! The microcontroller you are going to connect to has a hardware UART too and they both speak the same 'language'. The output of a hardware UART is always inverted but this is no problem, your receiving UART is expecting an inverted signal anyway.
octal



Joined: 15 Jan 2007
Posts: 39

View user's profile Send private message Visit poster's website

PostPosted: Fri Sep 14, 2007 3:26 am     Reply with quote

Hi,
yes I agree with you answer ckielska, my anwser was a bit ambiguous. In fact I offer to the user the choice between using inverted or true mode by pulling one pin High/Low. So Hardware UART can not be used Sad If it was to be interfaced only with users programmed mcu's, things would be easier, but it's intended to be smart enough to accomodate any soft config. Some users asked for that because they use, with their compilers, libraries (without source codes) that let them use only true mode, so no way to make it work with my module. It's to avoid such problems that I want to give the possibility to define signals inversion mode using a special pin.

Regards
Octal
_________________
http://www.pocketmt.com the GLCD Font Creator home Smile
inservi



Joined: 13 May 2007
Posts: 128

View user's profile Send private message

PostPosted: Fri Sep 14, 2007 4:20 am     Reply with quote

Hello,

For TTL level inverting, a simple MOSFET transistor and probably one resistor is need. So with only two MOSFET , (one for TX and one for RX) you can give to user both inverted and not inverted at the same time (with two connector).
dro.
_________________
in médio virtus
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