Shop OBEX P1 Docs P2 Docs Learn Events
need help understanding " cognew " — Parallax Forums

need help understanding " cognew "

TCTC Posts: 1,019
edited 2007-08-13 03:00 in Propeller 1
I am having troble understanding cognew. using page 190 of the Propeller manual 1.0 as an example. How dose " X " becomes " XAddr "? I am not putting 2 & 2 together

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
We all make mistakes when we are young………That’s why paste is edible!

Comments

  • BergamotBergamot Posts: 185
    edited 2007-08-13 01:31
    The '@' operator gives the address to the variable in hub memory.

    In the manual, they're passing the address of 'X' to the 'Square' function, which calls it 'XAddr'. To get the long variable at XAddr, they use 'long[noparse][[/noparse]XAddr]', which they multiply times itself.
  • TCTC Posts: 1,019
    edited 2007-08-13 01:45
    Thank you, Now I understand what is going on

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    We all make mistakes when we are young………That’s why paste is edible!
  • TCTC Posts: 1,019
    edited 2007-08-13 02:10
    OK since I got a better idea about how " x" becomes "xaddr". I have no idea what I am missing with this code

    PUB Start (backlight, rate)

    · cognew ( Flash_BL(backlight, rate),@stack)

    PUB Flash_BL

    · repeat
    ··· outa [noparse][[/noparse]backlight] := 1
    ··· waitcnt(((CLKFREQ * rate)/ 32) + CNT)
    ··· outa [noparse][[/noparse]backlight] := 0
    ··· waitcnt(((CLKFREQ * rate)/ 64) + CNT)

    "Propeller Tool" keeps cumming up saying that there should be a "," between "Flash_BL" & "(". everywhere I look in the manual for "cognew" there is the same setup that I am using. what am I doing wrong?

    thanks

    TC

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    We all make mistakes when we are young………That’s why paste is edible!
  • Mike GreenMike Green Posts: 23,101
    edited 2007-08-13 02:50
    The problem is that you have two parameters that you're passing to Flash_BL, but you have not included them in the declaration of Flash_BL. That needs to be: PUB Flash_BL(backlight,rate)
  • TCTC Posts: 1,019
    edited 2007-08-13 03:00
    DUH, I am glad you guys are around. I cant believe I did not see that. Thank you

    TC

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    We all make mistakes when we are young………That’s why paste is edible!
Sign In or Register to comment.