PDA

View Full Version : Serial com with internal oscillator



mikendee
- 14th June 2007, 14:09
Hi,
Iam looking at using a 16F88 with an AD7730 and outputing the result in RS-232. I have read in other threads that the internal oscillator is not recommended for asynchronous serial. I have a few questions and would be very greatful if someone could help me with any of them.

1. Is the problem that the ocsillator is unstable or can it be adjusted with the OSCTUNE register to work ok?

2. It says on page1 of the datasheet that you don't need a crystal for RS-232. Is this not true?

3. As the 16F88 only has 1 AUSART port is it better to use it for RS-232 or SSP.

Thanks,

Mike

mister_e
- 14th June 2007, 14:35
1. Is the problem that the ocsillator is unstable or can it be adjusted with the OSCTUNE register to work ok?

it could be adjusted, but for any serial communication, i never trust any internal oscillator, i prefer to use a crystal instead. The internal will shift with temperature, gas price, wind direction and so on. Using a crystal allow to sleep really well all night ;)


2. It says on page1 of the datasheet that you don't need a crystal for RS-232. Is this not true?

Not false, not true, this will depend of the environment and how lucky you are.


3. As the 16F88 only has 1 AUSART port is it better to use it for RS-232 or SSP.

It's two different animal, MSSP is used to interface I2C and/or SPI device, while USART is just plain serial communication, synchronous or not.

mikendee
- 14th June 2007, 15:02
Hi Mister-e
Thanks for the reply.

My question with the AUSART is. I have to us SHIFTIN and SHIFTOUT to talk to the AD7730 and Serout2 to send the result to another Pic.

Can I use Shiftout with RB1/SDO, RB2/SDI and RB4/SCK and SEROUT or HSEROUT with RB5/TX?

If I did this would the TXSTA register have to be changed between transmissions or would it be better to use another pin?

Ron Marcus
- 14th June 2007, 16:05
I have spent days collectively trying to work with async comms and no xtal. I can get lucky, but for a customer app. I would always revert to a crystal Why not use SPI for both. Use one pin to select your other PIC, and one to select your peripheral.Or, if the peripheral is looking for a low to select, set your outlying PIC as an enable high, and use the same pin. Just make sure both external units go into high impedance when deselected. I did this with a video on screen display. The PIC generating the overlay could only grab a little info between frames. I used shiftin and shiftout with very reliable results. Async can be unreliable even with a crystal in noisy environs, but makes it easy to hook up to a PC or GPS engine, etc...

Ron

mikendee
- 14th June 2007, 20:47
Hi Ron,

I think this will be the solution for me. I will have to use an extra pin to select the AD7730 but then I have 2 extras from not using an xtal. I can't see whether it is high impedance when not selected from the Datasheet but will check in a breadboard to see. I'll have to learn to use a pic as a slave in SPI but hopefully that won't be too tricky.

Thankyou both for your help. I'd be stumbling around in the dark without it.

Thanks,

Mike

mister_e
- 14th June 2007, 21:24
SPI or I2C, synchronous serial communication is really the way to go with an internal oscillator. If you're using SPI/I2C device, no harm to use the internal oscillator as it's a synchronous communication, but for RS232 asynch... this will cause you problem one day or another... unless you're really lucky!