Futterama
- 14th July 2005, 22:22
Hi all,
I'm having trouble using the DIG function.
I have a byte array, and I want to fill it with the digits from a measurement from PulsIn. So I have the following code:
RX VAR BYTE[4]
MeasureResult VAR WORD
PulsIn PORTB.5,1,MeasureResult
RX[0] = MeasureResult DIG 3
RX[1] = MeasureResult DIG 2
RX[2] = MeasureResult DIG 1
RX[3] = MeasureResult DIG 0
The problem is, that whenever "MeasureResult" is more than 2048, DIG simply doesn't work. I've tried to make some dummy code to locate the problem and to find the "limit" of 2048. I simply replace the PulsIn statement with "MeasureResult = 2050" and the thing won't work. If I set MeasureResult to 2048 and below, it works kinda (it screws up some of my other code, but this is not the main issue).
What is wrong here?
I'm having trouble using the DIG function.
I have a byte array, and I want to fill it with the digits from a measurement from PulsIn. So I have the following code:
RX VAR BYTE[4]
MeasureResult VAR WORD
PulsIn PORTB.5,1,MeasureResult
RX[0] = MeasureResult DIG 3
RX[1] = MeasureResult DIG 2
RX[2] = MeasureResult DIG 1
RX[3] = MeasureResult DIG 0
The problem is, that whenever "MeasureResult" is more than 2048, DIG simply doesn't work. I've tried to make some dummy code to locate the problem and to find the "limit" of 2048. I simply replace the PulsIn statement with "MeasureResult = 2050" and the thing won't work. If I set MeasureResult to 2048 and below, it works kinda (it screws up some of my other code, but this is not the main issue).
What is wrong here?