Need help with CODE
O.A.A.
Posts: 25
Can someone please tell me what is happening in the following code segment :
DAT
··· ScratchPad byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
'······················ · · 0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1
PUB Main
·· DIRA := %00001111_00000011_10100000_11111111
·· OUTA := %00000000_00000000_00000000_00000000
·· waitcnt(2_000_000 + cnt)
·· workVariable := word[noparse][[/noparse]@ScratchPad][noparse][[/noparse]21]
·· If workVariable <> 0
···· Beep
···· Beep
PRI Beep
·· repeat 2
····· !outa[noparse][[/noparse]Beeper]
····· waitcnt(5_000_000 + cnt)
For some reason "workVariable" is not zero for index values 17 and onwards.
workVariable := word[noparse][[/noparse]@ScratchPad][noparse][[/noparse]17]· ·is· ·-24573
workVariable := word[noparse][[/noparse]@ScratchPad][noparse][[/noparse]19]· ·is···· 13750
workVariable := word[noparse][[/noparse]@ScratchPad][noparse][[/noparse]21]· ·is··· · 7738
workVariable := word[noparse][[/noparse]@ScratchPad][noparse][[/noparse]23]· ·is·· -28353
workVariable := word[noparse][[/noparse]@ScratchPad][noparse][[/noparse]25]· ·is···· 30423
·Thanks.
Post Edited (O.A.A.) : 1/12/2010 6:48:59 PM GMT
DAT
··· ScratchPad byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
'······················ · · 0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1
PUB Main
·· DIRA := %00001111_00000011_10100000_11111111
·· OUTA := %00000000_00000000_00000000_00000000
·· waitcnt(2_000_000 + cnt)
·· workVariable := word[noparse][[/noparse]@ScratchPad][noparse][[/noparse]21]
·· If workVariable <> 0
···· Beep
···· Beep
PRI Beep
·· repeat 2
····· !outa[noparse][[/noparse]Beeper]
····· waitcnt(5_000_000 + cnt)
For some reason "workVariable" is not zero for index values 17 and onwards.
workVariable := word[noparse][[/noparse]@ScratchPad][noparse][[/noparse]17]· ·is· ·-24573
workVariable := word[noparse][[/noparse]@ScratchPad][noparse][[/noparse]19]· ·is···· 13750
workVariable := word[noparse][[/noparse]@ScratchPad][noparse][[/noparse]21]· ·is··· · 7738
workVariable := word[noparse][[/noparse]@ScratchPad][noparse][[/noparse]23]· ·is·· -28353
workVariable := word[noparse][[/noparse]@ScratchPad][noparse][[/noparse]25]· ·is···· 30423
·Thanks.
Post Edited (O.A.A.) : 1/12/2010 6:48:59 PM GMT
Comments
The definition of Scratchpad is as followws:
' ScratchPad(0) : indx
' ScratchPad(1) : RAC Rudder Angle Change Index
' ScratchPad(2) : RLim Rudder Limit
' ScratchPad(3) : Gain
' ScratchPad(4) : DBnd Rudder Deadband
' ScratchPad(5) : CRud Counter Rudder
' ScratchPad(6) : SHF Standing Helm Factor
' ScratchPad(7) : SpdF Speed Factor
' ScratchPad(8) : Mom Momentum Index
' ScratchPad(9) : RudMax.LowByte
' ScratchPad(10) : RudMax.HighByte
' ScratchPad(11) : Mode
' ScratchPad(12) : Bearing.LowByte
' ScratchPad(13) : Bearing.HighByte
' ScratchPad(14) : Speed
' ScratchPad(15) : Track.LowByte
' ScratchPad(16) : Track.HighByte
' ScratchPad(17) : TrackPrev.LowByte
' ScratchPad(18) : TrackPrev.HighByte
' ScratchPad(19) : omega.LowByte
' ScratchPad(20) : omega.HighByte
' ScratchPad(21) : omegaPrev.LowByte
' ScratchPad(22) : omegaPrev.HighByte
' ScratchPad(23) : SHelm.LowByte
' ScratchPad(24) : SHelm.HighByte
' ScratchPad(25) : RudPos.LowByte
' ScratchPad(26) : RudPos.HighByte
' ScratchPad(27) : cogreg i.e. 00011111 indicates cogs 0,1,2,3,4 are active
' ScratchPad(28) : startup
' ScratchPad(29) : err == 99 --> No NMEA data, reset needed
' ScratchPad(30) : unused
' ScratchPad(31) : unused
Upto index value 17 the BYTE and WORD are all zero.
For index value 17 and onwards I get the above stated values.
O.A.Ardali
Post Edited (Mike Green) : 1/12/2010 7:13:12 PM GMT
I have overlooked the fact that the subscript field is in terms of words which of course causes an overflow outside the data block.
Thanks again.
Change your code to Either
OR
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Samuel
www.RobotBASIC.com
·