PDA

View Full Version : 9600 baud using 12F675 INTRC_OSC



AndyP
- 3rd August 2004, 12:14
When I first tried communication at 9.6K using the internal RC oscillator on the 12F675, I just got mumbo jumbo at the receiving end, but browsing through the manual and on this forum's FAQ section etc, I have found that if you are patient enough to callibrate the RC oscillator in the 675, 9600baud IS possible.

On the datasheet it said that %11111100 (252) was the max frequency, and %00000000 (0) the lowest. When I outputted the value of OSCCAL to an LCD, by default it was set to 128, approx half way between these two values.

I then hooked the scope up to pin GPIO.4 (remembering to add:
@ DEVICE pic12F675, INTRC_OSC_CLKOUT

at the start of the program and measured the frequency of the oscillator. It is infact Fosc/4, i.e 1Mhz, which equates to a cycle period of 1us.

When OSCCAL was set to 252, my cycle period was: 0.76us.
When OSCCAL was set to 0, my cycle period was: 1.2us.

By decrementing the value of OSCAL by 8 and re-measuring, I managed to get the oscillator bang on 4Mhz. The actual value in the end was 88 (%01011100). I am now successfully communicating at 9600 baud to other pics etc..

Dont know if this might be useful to anyone with a scope, but it has made my day, and saved me 2 pins!

Roy
- 3rd August 2004, 13:32
Nice that you posted your effort, i haven't tried the 675 int osc yet but how much is the osc/timing drifting in normal "indoor" climat.

Is it reliable for serialcomm after calibration ? within 5-10 deg C?

Brgds Roy

AndyP
- 3rd August 2004, 14:46
I dont know yet how stable the internal oscillator will be, but as the project I am working on is an outside temperature sensor, I will let you know just as I find out!

At the moment, the comms are very reliable, I dont get any weird characters, but having said that the temperature is a constant 25 degrees in here..

Roy
- 3rd August 2004, 17:09
Ok, interesting, keep us all informed.

Brgds Roy

NavMicroSystems
- 3rd August 2004, 23:37
@ AndyP

This is quite interesting.

My experience is with a "well calibrated" INTRC-OSC at one end and a Crystal at the other end (PIC-2-PIC communication)
you can get more or less reliable communication even @ 9600.

With INTRC-OSC at both ends 4800 was the maximum I could achieve (reliable).

If either one of the two PICs has a tuned Crystal the Dirift of the RC-PIC doesn't matter that much,
but if they are both RC "clocked" and they drift different ways it does matter.

Please keep us posted.

rgds.