memory addressing in assembly
Neighborhood Physicist
Posts: 32
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?
·· RDLONG I2CData, PAR ' Gives access to the first element
Thanks.
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?
·· RDLONG I2CData, PAR ' Gives access to the first element
Thanks.
Comments
Hope this helps,
Baggers.
edit: put it in code box [noparse]:)[/noparse]
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
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.