Problems Converting Between 5 MHz Crystal and Built in Timer
Chip Magnet
Posts: 2
I am building a little gizmo that uses the Prop chip to do little animations with 8 LEDs in P0 through P7.
First I built up the circuit on a breadboard and I used a 5 MHz crystal. This worked fine. Then I had a professional PCB made up, and I wanted to use the Prop's built-in RC timing circuit, because it was cheaper, and precise timing isn't an issue here. Well, I thought it was just going to be a matter of changing the following:
_clkmode = xtal1 + pll16x
_xinfreq = 5_000_000
CLK_FREQ = ((_clkmode - xtal1) >> 6) * _xinfreq
To:
CLK_FREQ = 12_000_000
Just to make sure some systems were OK, I did run a simple LED on/off program. That worked, but then my main program doesn't I'm also using JM_Bam8 as a background routine. (This is basically a way to get multiple PWM's from one cog). Are there things I should change in that as well?
It has a few lines like this:
TIX_001 := (clkfreq >> 8) >> 8 ' 256Hz, 256 steps
So, when I mess with the CLK_FREQ in the main program, now I messed up things that depend on it in the sub-routines.
Any advice? Switching between the crystal and the internal RC timer isn't as easy as changing a line or two. What are some of the pitfalls to look out for?
Thanks in advance.
First I built up the circuit on a breadboard and I used a 5 MHz crystal. This worked fine. Then I had a professional PCB made up, and I wanted to use the Prop's built-in RC timing circuit, because it was cheaper, and precise timing isn't an issue here. Well, I thought it was just going to be a matter of changing the following:
_clkmode = xtal1 + pll16x
_xinfreq = 5_000_000
CLK_FREQ = ((_clkmode - xtal1) >> 6) * _xinfreq
To:
CLK_FREQ = 12_000_000
Just to make sure some systems were OK, I did run a simple LED on/off program. That worked, but then my main program doesn't I'm also using JM_Bam8 as a background routine. (This is basically a way to get multiple PWM's from one cog). Are there things I should change in that as well?
It has a few lines like this:
TIX_001 := (clkfreq >> 8) >> 8 ' 256Hz, 256 steps
So, when I mess with the CLK_FREQ in the main program, now I messed up things that depend on it in the sub-routines.
Any advice? Switching between the crystal and the internal RC timer isn't as easy as changing a line or two. What are some of the pitfalls to look out for?
Thanks in advance.
Comments
RCFAST gives approximately 12MHz operation.
Don't use _xinfreq or _clkfreq with RCFAST.