Cog memory access in Spin / ASM.
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.
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
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
>>>>>
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
I think I am sseing it now.
Please disregard my previous reply.
Cheers, Chris
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