Shop OBEX P1 Docs P2 Docs Learn Events
memory addressing in assembly — Parallax Forums

memory addressing in assembly

edited 2007-11-13 15:59 in Propeller 1
I have the following

VAR
· long· I2C_Data[noparse][[/noparse]2]
OBJ
· I2CObject : "I2CAssemblyObject"
PUB main
' Initialize the I2C_Data to 0
· I2C_Data[noparse][[/noparse]0] := $0
· I2C_Data[noparse][[/noparse]1] := $0
· I2CObject.Start(@I2C_Data)

Inside the assembly I2C code I want to check both elements in the puesdo array.·

How do I get access to the second element?confused.gif

·· RDLONG I2CData, PAR ' Gives access to the first element

Thanks.

Comments

  • BaggersBaggers Posts: 3,019
    edited 2007-11-08 18:32
    use something like this
    '
    '
    '
        mov    ptr,PAR      ' copies PAR to ptr, so we can add 4 to point to the second long in i2c_data
        rdlong i2cdata1,ptr ' reads the first long into i2cdata1
        add    ptr,#4       ' points ptr to the second long, by adding 4 to it.
        rdlong i2cdata2,ptr ' reads the second long into i2cdata2
    '
    '
    '
    
    ptr      res 1
    i2cdata1 res 1
    i2cdata2 res 1
    
    


    Hope this helps,
    Baggers.

    edit: put it in code box [noparse]:)[/noparse]
  • edited 2007-11-08 18:49
    Thanks, that helps alot.
  • BaggersBaggers Posts: 3,019
    edited 2007-11-08 19:44
    no problem [noparse]:)[/noparse]
  • edited 2007-11-13 15:02
    I am trying to used a shared resource to share data between cogs.

    Below is the code. The I2CObject sends out the data in I2C_Data[noparse][[/noparse]0] and then sets it to zero when finished.
    The spin code never sees the zero so the other numbers are never sent out.

    Anyone have any idea why this doesn't work.

    Thanks.


    long I2C_Data
    long waitamount
    long I2CValue
    long Shifter
    long tmp
    long zerotmp

    OBJ
    I2CObject : "I2CAssemblyObject"
    PUB main

    ' Initialize the I2C_Data to 0
    I2C_Data[noparse][[/noparse]0] := DataLong
    I2C_Data := InfoLong
    I2CObject.Start(@I2C_Data)
    waitamount := 200_000
    Shifter := MoveBit
    zerotmp := 0
    waitcnt(waitamount+cnt)
    I2CValue:= DataLong
    repeat
    if I2C_Data[noparse][[/noparse]0] == 0 '<-- This statement is never true even though I am 99.999% sure that the assembly code sets it to zero
    waitcnt(waitamount+cnt)
    Shifter<-=1
    tmp := AddressMask&Shifter
    I2CValue := I2CValue&tmp
    I2C_Data[noparse][[/noparse]0] := I2CValue
  • Mike GreenMike Green Posts: 23,101
    edited 2007-11-13 15:26
    Please use the [noparse][[/noparse] code ] and [noparse][[/noparse] /code ] brackets around your code (without the spaces around "code" and "/code"). Without them, you lose the formatting. You also have to insert your own spaces around some subscripts since the forum display routines use some of them to set the font to be used and strips out what you think will display as subscripts.
  • BaggersBaggers Posts: 3,019
    edited 2007-11-13 15:59
    Neighborhood Physicist, ( had to correct myself from spelling it the english way then [noparse]:)[/noparse] )

    few things, does that compile? if so, can you add the rest of the code? as I can't see DataLong or InfoLong's definition.

    your also setting I2C_Data[noparse][[/noparse]0] to DataLong and in the next line I2C_Data to InfoLong, is I2C_Data one long or two, like your first post?

    I've personally not used I2CAssemblyObject, but surely you have to send specific instructions over I2C? to request the data from a specific device? etc.

    You either need to post more code, or at least state what DataLong and InfoLong is, and your intentions with it.

    Baggers.
Sign In or Register to comment.