Generateing multiple Frequencies
Hi,
I am new to the Propeller Chip. It looks like I can find lots of uses for it. But i am having a tough time getting over this one hurdle. I am trying to generate 4 distict frequencies on 4 different output pins. I have loaded up the demo Freq sysn program, and it will let me generate only 2 of the 4 freq's i need. I have enclosed a sample of the code... Any suggestion will be appreciated..
Thanks...![freaked.gif](http://forums.parallax.com/images/smilies/freaked.gif)
CON
· _CLKMODE = XTAL1 + PLL16X
· _XINFREQ = 5_000_000
· Pin·· = 0
· PinA· = 1
· PinB· = 2
· PinC· = 3
· Frequency = 204_700·································· 'DC to 128MHz
· FrequencyA = 245_760
· FrequencyB = 1_600_000
· FrequencyC = 1_900_000
·
VAR
long stack[noparse][[/noparse]20]
OBJ
· Freq : "Synth"
·
PUB CTR_Demo
·
· cognew(Freq.Synth("A",PinB, FrequencyB),@stack)
·· Cognew(Freq.Synth("B",PinC, FrequencyC),@stack)
···· Freq.Synth("A",Pin, Frequency)
·· Freq.Synth("B",PinA, FrequencyA)
I am new to the Propeller Chip. It looks like I can find lots of uses for it. But i am having a tough time getting over this one hurdle. I am trying to generate 4 distict frequencies on 4 different output pins. I have loaded up the demo Freq sysn program, and it will let me generate only 2 of the 4 freq's i need. I have enclosed a sample of the code... Any suggestion will be appreciated..
Thanks...
![freaked.gif](http://forums.parallax.com/images/smilies/freaked.gif)
CON
· _CLKMODE = XTAL1 + PLL16X
· _XINFREQ = 5_000_000
· Pin·· = 0
· PinA· = 1
· PinB· = 2
· PinC· = 3
· Frequency = 204_700·································· 'DC to 128MHz
· FrequencyA = 245_760
· FrequencyB = 1_600_000
· FrequencyC = 1_900_000
·
VAR
long stack[noparse][[/noparse]20]
OBJ
· Freq : "Synth"
·
PUB CTR_Demo
·
· cognew(Freq.Synth("A",PinB, FrequencyB),@stack)
·· Cognew(Freq.Synth("B",PinC, FrequencyC),@stack)
···· Freq.Synth("A",Pin, Frequency)
·· Freq.Synth("B",PinA, FrequencyA)
Comments
This is what i have put in the program,
CON
· _CLKMODE = XTAL1 + PLL16X
· _XINFREQ = 5_000_000
· Pin·· = 0
· PinA· = 1
· PinB· = 2
· PinC· = 3
· Frequency = 204_700·································· 'DC to 128MHz
· FrequencyA = 245_760
· FrequencyB = 1_600_000
· FrequencyC = 1_900_000
·
VAR
long stack[noparse][[/noparse]18]
OBJ
· Freq : "Synth"
·
··
PUB CTR_Demo
· cognew(SecondCtr,@stack)
· Freq.Synth("A",Pin,Frequency)························ 'Synth({Counter"A" or
··Freq.Synth("B",PinA,FrequencyA)
·repeat················································ 'loop forever to keep cog alive
PUB SecondCtr
· Freq.Synth("A",PinB,FrequencyB)
· Freq.Synth("B",PinC,FrequencyC)
··But,·Frequency B & C still do not work, Also I do not understand why the synth module is so particular when passing the A & B parameters. I originally Added C & D IF statements just to try and the whole module stopped working.··I see how it should work, but it doesnt...
thanks again..
···
If you look at the code for Synth, it just does some calculations, then sets up either the A counter or the B counter based on the first parameter. There's an A and a B counter and other associated registers for each cog, so you can set up two independent frequency outputs per cog. The A and B counters are identical in function and each consist of two identical sets of 3 registers (CTRx,PHSx,FRQx) and associated logic.
Mike