Shop OBEX P1 Docs P2 Docs Learn Events
Cog memory access in Spin / ASM. — Parallax Forums

Cog memory access in Spin / ASM.

FORDFORD Posts: 221
edited 2006-04-08 01:32 in Propeller 1
Hello test pilots...

Am I correct in thinking...

1- If a cog is started and the program in·that cog·is·Spin code, the cog RAM can't be accessed because the Spin interpreter is loaded into that cogs RAM to run the Spin program within it ?

2- A cog with Spin code can access any area of the global RAM (I am thinking that at initial startup the global RAM is just a mirror image of the 24lc256)

3- How is / what commands are used to access the global RAM in Spin code ?
Do you have to declare variables for the RAM locations to read / write them ?, or can you simply read / write addresses such as 'read and write' in pbasic.

Sorry if my questions are poorly written.

Thanks,
Chris
West Oz.

Comments

  • Jon WilliamsJon Williams Posts: 6,491
    edited 2006-04-07 23:33
    I believe that with Spin you can only access the main RAM.· I wrote this quick test program to confirm:

    PUB main

    · if lcd.start(0, 19_200, 4)
    ··· lcd.cursor(0)
    ··· lcd.cls
    ··· lcd.backlight(1)
    ··· repeat
    ····· lcd.home
    ····· dira[noparse][[/noparse]31..0] := $00_00_00_FF
    ····· lcd.str(num.hex(long[noparse][[/noparse]$1F6], 8))
    ····· lcd.gotoxy(0, 1)
    ····· lcd.str(num.hex(dira[noparse][[/noparse]31..0], 8))

    The address used in the first line, $1F6, is the location of the dira register in the Cog RAM, but it that does not return the value I set into dira, while the second line does.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • FORDFORD Posts: 221
    edited 2006-04-07 23:55
    Thanks Jon, correct me if I'm wrong...

    >>>>>
    if lcd.start(0, 19_200, 4)
    ··· lcd.cursor(0)
    ··· lcd.cls
    ··· lcd.backlight(1)
    ··· repeat
    ····· lcd.home
    >>>> the above is simply setting up the LCD

    ····· dira[noparse][[/noparse]31..0] := $00_00_00_FF
    >>>> this writes a 1 to the lowest 8 output pins (0 to 7)

    ····· lcd.str(num.hex(long[noparse][[/noparse]$1F6], 8))
    >>>> this writes a string $1F6 padded with zeroes to the LCD.

    ····· lcd.gotoxy(0, 1)
    ····· lcd.str(num.hex(dira[noparse][[/noparse]31..0], 8))
    >>>>·this sets a cursor position and writes the hex value of all 32 i/o's to the LCD.


    I can't see where you have tried to 'look' at the Global RAM or the local RAM.
    Am I lost or what ??

    Cheers,
    Chris
  • FORDFORD Posts: 221
    edited 2006-04-07 23:57
    OOps,

    I think I am sseing it now.

    Please disregard my previous reply.

    Cheers, Chris
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2006-04-08 01:32
    Yes, the long[noparse][[/noparse]$1F6] is reading four bytes (little endian) from that address -- in Main RAM.

    And remember that dira[noparse]/noparse is the DDR for the 'a' pin group; to write to pins one would use outa[noparse]/noparse, and to read, ina[noparse]/noparse.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
Sign In or Register to comment.