Shop OBEX P1 Docs P2 Docs Learn Events
Shared Memory Question — Parallax Forums

Shared Memory Question

worthyamherstworthyamherst Posts: 46
edited 2011-07-19 09:48 in Propeller 1
How can I access the shared memory on the Propeller. I am receiving Ping))) data from a basic stamp using an XBee. I can show the received data on the Serial Terminal, I am just wondering how I can store the data as a variable or something in the HUB.

Comments

  • StefanL38StefanL38 Posts: 2,292
    edited 2011-07-19 08:47
    whenever you are coding in SPIN the HUB-RAM is used to store your code and all variables.

    you have to use the fullduplexserial-object to receive serial data. Please provide more details of what you want to do and how far you got
    with the code on the propeller

    keep the questions coming
    best regards

    Stefan
  • worthyamherstworthyamherst Posts: 46
    edited 2011-07-19 08:54
    CON

    'ClkFreq: 80 Mhz

    _XINFREQ = 5_000_000 'Adjust the frequency
    _CLKMODE = XTAL1 + PLL16X 'Adjust the frequency

    rx = 25
    tx = 27
    baudRate = 9600
    polarity = 1
    bits = 8

    OBJ

    bs : "BS2_Functions" 'Basic Stamp 2 library

    VAR

    byte number

    PUB start

    BS.start(31, 30)

    repeat
    number := BS.serin_char(rx, baudRate, polarity, bits) 'receive from BS; k
    BS.serout_dec(30, number, baudRate, 1, 8) 'show data received on screen
    BS.Debug_Char(13)
    waitcnt(clkfreq/2 + cnt) '0.5 sec pause

    This is the spin code we have to receive the Ping))) Data. I guess my question is if "number" is my variable that I can then send out. Is the variable automatically stored in the Hub? Can I transmit the variable from another cog? And thanks for the help. I am very new to the propeller and spin.
  • JonnyMacJonnyMac Posts: 9,208
    edited 2011-07-19 09:48
    If you store the value in a global variable defined by your top object it will be in the hub. Spin methods (even in there own cogs) will be able to see this variable. If you want a PASM cog to have access to the variable you will need to pass the variable's address to that cog.
Sign In or Register to comment.