Shop OBEX P1 Docs P2 Docs Learn Events
Generateing multiple Frequencies — Parallax Forums

Generateing multiple Frequencies

Armondo522Armondo522 Posts: 9
edited 2006-12-19 20:57 in Propeller 1
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


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

  • Mike GreenMike Green Posts: 23,101
    edited 2006-12-19 18:55
    You only need one additional cog to generate 2 signals. You can't use the same stack space for two cogs running at the same time. Try this:
    PUB CTR_Demo
      cognew(SecondCtr,@stack)
      Freq.Synth("A",Pin,Frequency)
      Freq.Synth("B",PinA,FrequencyA)
    PUB SecondCtr
      Freq.Synth("A",PinB,FrequencyB)
      Freq.Synth("B",PinC,FrequencyC)
    
    
  • Armondo522Armondo522 Posts: 9
    edited 2006-12-19 20:45
    Thanks Mike for the fast response

    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..


    ···
  • Mike GreenMike Green Posts: 23,101
    edited 2006-12-19 20:57
    I think you will need a repeat in SecondCtr as well. I'm sorry I didn't think of it. Without the repeat or something similar, the method returns at its end and this causes an implicit stop which shuts down the counters in the cog.

    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
Sign In or Register to comment.