I was playing with DT_Analog, and random variable set to 0 when I call GetADC.
This was happen only with long variable enabled.
So quick look and here is what happened:
If I use PBPL then assembler use this lineCode:#IF __LONG__ DTadAccum VAR LONG ; local - 32-bit sample accumulator #ELSE DTadAccum VAR WORD[2] ; local - 32-bit sample accumulator #ENDIF
DTadAccum VAR LONG ; local - 32-bit sample accumulator
And that is fine... Just declaring LONG var.
But later in code when Darrel clears accumulator:
So where is located DTadAccum[1]?Code:DTadAccum = 0 : DTadAccum[1] = 0 ; clear the accumulator
- 4 bytes after DTadAccum, and where was located my variables that get cleared after calling GetADC? You guessed...
Solution:
Replace
withCode:DTadAccum = 0 : DTadAccum[1] = 0 ; clear the accumulator
And that's all.Code:#IF __LONG__ DTadAccum = 0 ; clear the accumulator #ELSE DTadAccum = 0 : DTadAccum[1] = 0 ; clear the accumulator #ENDIF




Bookmarks