Set Variable to Dat address
gianallen
Posts: 16
Hello,
As a test setup for a larger program, I want to iterate through sending byte arrays to a UART from a few Dat locations once every 5 seconds. I assumed, apparently incorrectly, that I could set a variable equal to the name assigned to each of the first values in the DAT array, and that would set the variable equal to that memory address. I figured, again apparently incorrectly, that I could use that variable name just as I would have used the DAT-block "variable" name to access the elements of the array. Instead, it looks as though setting local Var := Dat Block name sets the Var to the value at Dat-block name. Is there a simple way to accomplish what I'm trying to do? Thanks. Here's my code:
EmulateDatMsgs.spin
As a test setup for a larger program, I want to iterate through sending byte arrays to a UART from a few Dat locations once every 5 seconds. I assumed, apparently incorrectly, that I could set a variable equal to the name assigned to each of the first values in the DAT array, and that would set the variable equal to that memory address. I figured, again apparently incorrectly, that I could use that variable name just as I would have used the DAT-block "variable" name to access the elements of the array. Instead, it looks as though setting local Var := Dat Block name sets the Var to the value at Dat-block name. Is there a simple way to accomplish what I'm trying to do? Thanks. Here's my code:
EmulateDatMsgs.spin
spin
779B
Comments
1: CurrentMsg := @Msg1
2: CurrentMsg := @Msg2
3: CurrentMsg := @Msg3
...
char := byte[CurrentMsg][idx]