John Abshier
08-08-2010, 04:24 PM
I am getting frequencies that I don't understand. At low frequencies the error is 5 percent. At higher frequencies the error is 1.5 percent. Here is the code:
CON
_clkmode = xtal1 + pll16x
_xinfreq = 5_000_000
#1, HOME, #8, BKSP, TAB, LF, CLREOL, CLRLB, CR, #16, CLS ' PST formmatting control
VAR
Pub Main | i
dira[0..1]~~ ' Make pins 0 and 1 outputs
outa[0]~~ ' High
outa[1]~ ' Low
i := cnt
repeat
i += clkfreq / 10
!outa[0..1] ' Toggle
waitcnt(i)
' clkfreq / 2 -> period 1.05 clkfreq / 10-> period 0.21 both 5 percent from expected.
' Above values tested on PDB and Demo Board. Lower values only tested on Demo Board
' clkfreq / 100 -> period 19.7 or 20.3 1.5 % clkfreq / 1000 -> period 1.97 or 2.03 1.5 %
' clkfreq / 10000 -> period 197 or 203 uS 1.5% error
John Abshier
CON
_clkmode = xtal1 + pll16x
_xinfreq = 5_000_000
#1, HOME, #8, BKSP, TAB, LF, CLREOL, CLRLB, CR, #16, CLS ' PST formmatting control
VAR
Pub Main | i
dira[0..1]~~ ' Make pins 0 and 1 outputs
outa[0]~~ ' High
outa[1]~ ' Low
i := cnt
repeat
i += clkfreq / 10
!outa[0..1] ' Toggle
waitcnt(i)
' clkfreq / 2 -> period 1.05 clkfreq / 10-> period 0.21 both 5 percent from expected.
' Above values tested on PDB and Demo Board. Lower values only tested on Demo Board
' clkfreq / 100 -> period 19.7 or 20.3 1.5 % clkfreq / 1000 -> period 1.97 or 2.03 1.5 %
' clkfreq / 10000 -> period 197 or 203 uS 1.5% error
John Abshier