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