Shop OBEX P1 Docs P2 Docs Learn Events
help error at (46,18) expected "," ????? — Parallax Forums

help error at (46,18) expected "," ?????

purplemonkeypurplemonkey Posts: 89
edited 2012-09-14 10:55 in Propeller 1
i keep getting this error with this command

COGNEW(main(16,clkfreq/50), @stack[0])

error at (46,18) expected ","

any ideas as its driving me nuts!????

Comments

  • Duane DegnDuane Degn Posts: 10,588
    edited 2012-09-12 12:05
    What does the method "main" look like?
  • Mike GreenMike Green Posts: 23,101
    edited 2012-09-12 12:05
    You need to show your definition of "main". Presumably, you've got a mismatch between that definition and how you've called it from within the COGNEW. Specifically, you show "main" as having two parameters. The definition will have to have two parameters defined as well.
  • purplemonkeypurplemonkey Posts: 89
    edited 2012-09-12 12:18
    it looks like this:

    VAR


    LONG stack[20]
    CON
    _clkmode = xtal1 + pll16x
    _xinfreq = 5_000_000


    txpin = 16
    freq1 = 500
    freq2 = 1000
    delta = 50000
    txfreq = 92_500_000.0
    freqb = round(txfreq * 4_294_967_296.0 / (16.0 * 80_000_000.0))


    PUB main | numclks1, numclks2


    dira := 1 << txpin

    numclks1 := clkfreq / (2 * freq1)
    numclks2 := clkfreq / (2 * freq2)


    ctrb[30..26] := %00010
    ctrb[25..23] := 7
    ctrb[5..0] := 16


    repeat

    ' Generate the first frequency for one-half second
    repeat freq1 >> 1
    frqb := freqb + delta
    waitcnt(numclks1 + cnt)
    frqb := freqb - delta
    waitcnt(numclks1 + cnt)

    ' Generate the second frequency for one-half second
    repeat freq2 >> 1
    frqb := freqb + delta
    waitcnt(numclks2 + cnt)
    frqb := freqb - delta
    waitcnt(numclks2 + cnt)


    cognew(main(16,clkfreq/50), @stack[0])


    i'm just trying to get my head around running the same program on different cogs but just changing the pin number and the frequency
  • JonnyMacJonnyMac Posts: 9,108
    edited 2012-09-12 12:45
    Your main method requires no parameters and yet you are trying to send two (looks like pin and update rate). Per Mike's comment, this mismatch is the source of the compilation error.
  • purplemonkeypurplemonkey Posts: 89
    edited 2012-09-12 12:54
    I understand thanks! However still confused how to get this program running on multiple cogs and different pins, how would you approach it?

    I can't figure out also which part of the program defines which cog it runs on?
  • Mike GMike G Posts: 2,702
    edited 2012-09-12 12:54
    It looks like the cognew function is in the main method. So every time main is called so is another instance of cognew. I'm not sure what that would do but I'm sure it's not good.

    This is
    PUB main | numclks1, numclks2
    

    is not the same as
    PUB main(numclks1, numclks2)
    

    Also, please use the [ code ] [/ code ] tags to wrap your source code when posting to the form. It makes the code easier to read.
  • purplemonkeypurplemonkey Posts: 89
    edited 2012-09-12 12:59
    Where should it be?
  • Mike GreenMike Green Posts: 23,101
    edited 2012-09-12 13:01
    First you need to figure out what you want to do and express it in writing. Just producing one frequency on one pin, then producing a different frequency on a different pin doesn't require more than a single cog. In fact, since there are two counters per cog, you can produce two separate frequencies on two separate pins at the same time, just by setting up first one counter, then the other. Look at JonnyMac's frequency generator object in the ObEx for an excellent example of this.
  • purplemonkeypurplemonkey Posts: 89
    edited 2012-09-12 13:19
    I would like to have the prop chip transmitting the same tones but on different frequencies betwee 1-128 mhz on each pin for all of them. So to do this presumably I can have have two frequencies per a cog but will still need multiple cogs to output to all pins.

    Really I just want to know the process for repeating the whole thing on a different cog? Just want to know what the code is?
  • JonnyMacJonnyMac Posts: 9,108
    edited 2012-09-14 10:55
    The attached demo only works in NCO mode (which won't do the frequencies you want), but it will give you a starting point. Have a look at the synth object in the Propeller Library on your system for handling higher frequencies.
Sign In or Register to comment.