PDA

View Full Version : Calculations for using faster Clocks.



Tissy
- 18th April 2005, 11:49
Is there a set calculation for using a faster clock?

I initially used a 4Mhz resonator, which has now been changed to a 20Mhz to get smoother PMW.

In my code it has many PAUSE commands and FOR...NEXT Loops.

It states in the manual:



PAUSE assumes an oscillator frequency of 4MHz. If an oscillator other
that 4MHz is used, PBP must be told using a DEFINE OSC command.
See the section on speed for more information.

PAUSE 1000 ‘ Delay for 1 second


Therefore, I appriciate that any PAUSE X command will not be affected as long as the DEFINE OSC command is used, as 50ms is 50ms.

However, a FOR...NEXT Loop will be affected as it will get from 1 to 100, for example, quicker.

Is it as simple as changing the FOR...NEXT Loop to be 5 times longer. ie instead of:

FOR Time = 1 TO 100 (4MHz Version).

It'll be:

FOR Time = 1 TO 500 (20Mhz Version).

Is it as simple as that or is there any easier way round things insead of going through all the code and increasing some of the Variables by 500%.

Many Thanks,

Steve

Tissy
- 18th April 2005, 14:24
Cancel my last, i think i found what the problem was.

Although i thought i was defining the OSC speed, it appears i wasn't. Which is why the program was contradicting the manual.

It would appear that the Define Osc needs to be in capitals, ie.

DEFINE OSC 20

and not

define osc 20

We Live and learn.

Steve