PDA

View Full Version : 4mhz to 8 mhz



Forkosh
- 16th December 2007, 11:39
When I change the microcontroller clock from 4mhz to 8 mhz I put the following code in the beginning of the program

DEFINE OSC 8 'Set oscillator speed to 8

Now I also have to change the values of PULSOUT to be 2 times higher
By 4mhz = PULSOUT 100 by 8mhz = PULSOUT 200

Would I also have to change the values of PULSIN by times 2
by 4mhz = PULSIN 2 by 8mhz =PULSIN 4 ( I KNOW THATS NOT THE COMPLETE SYNTAX)

Also , what effect would the oscillator change have on serially controllling an LCD screen.
Any other changes to the program that would result by switching to a higher speed?

would PAUSE also be affected?

FRANCISCOGIM
- 17th December 2007, 18:26
If you put your oscillator of 4 and put DEFINED OSC 4 or put an oscillator, 8 and put DEFINED OSC 8 nothing happens A pause 100 will be the same in both cases.
You must match the external oscillator with the definition put that in the compiler.
You can not put an external oscillator of 4 and set in compiler one of 8 that does not work well.

Forkosh
- 17th December 2007, 19:55
What about PULSIN and PULSOUT

would their resolution be doubled?

skimask
- 17th December 2007, 19:57
What about PULSIN and PULSOUT

would their resolution be doubled?

EDIT: Disregard...wrong post...

Forkosh
- 17th December 2007, 19:59
Only in versions 7.61 and up. The manual has a good list.

I have PICBASIC pro version 2.47 . version 7?

skimask
- 17th December 2007, 20:01
I have PICBASIC pro version 2.47 . version 7?

The manual talks all about how PAUSE, PAUSEUS, PULSIN, PULSOUT, SERIN/SEROUT (software based UART type commands), and various other commands are affected by changes in actual oscillator speed and the DEFINE'd oscillator speed. (i.e. faster oscillator, faster this, slower oscillator, slower that).

PBP compensates for different DEFINE'd speeds (i.e. SEROUT using 2400 baud will be 2400 baud if you DEFINE OSC 4 or DEFINE OSC 40), but can't do anything about what you put into the OSC1/OSC2 pins or what, if anything, you end up selecting for the actual oscillator frequency, either internal or external types.

Forkosh
- 17th December 2007, 20:03
Thanks skimask! :D