Truncated match.
PICList
Thread
'12 bit a to d +comparing'
1998\04\18@142030
by
marcel
|
Tanks for the reply's on this matter
the thing is what i wand to do is more complicated
I am reading 12 bit of data from an potentiometer when it is in the
middle
it should give something like 0x0800 "hex"
when i turn left it decreases and when i turn right it increases
The maximum increment should be from 0x80 to 0xEF and the maximum
decrement must not cross 0x00 from0x80 down to 0x00within one reading
if so i have to increment or decrement
with these maximums or less until i reach the last readout.
I hope i am more clear on what i want to do
I can get the data msb first in the registers datahi and datalo but
the LTC1286 allows also to read LSB first
Example first readout could be x0800 the next 0x0880
the differents is 80 positive is bigger than 0x7F so i add 0x7Fto
previous readout
and compare again with the last readout witch can have changed in this
example
i assume not so 0x880 sub 0x87F is 0x01 witch is less than 0x7F and
i add 0x01 to the first readout and the process stops until a new
readout
appears to be differend .
I don't understand what is the meaning msb stored at lower adress at the
moment i am
trying simulating this in MacPic
Storlox equ 0x10
Storhix equ 0x11
;Storloy equ 0x12
;Storhiy equ 0x13
TmpReg1 equ 0x14
TmpReg2 equ 0x15
datalo equ 0x16
datahi equ 0x17
movlw 0x30
movwf datalo
movlw 0x01
movwf datahi
movlw 0x20
movwf Storlox
movlw 0x01
movwf Storhix
clrf TmpReg1
clrf TmpReg2
sub16
movf datalo,W ; subtract lsbs
subwf Storlox,W
movwf TmpReg1
movf datahi,W ; subtract msbs
btfss status,C ; including any carry
incfsz Storhix,W
subwf datahi,W
movwf TmpReg2
btfsc status,C ; new smaller?
goto smaller ; yes
goto larger ; no
smaller movf TmpReg1,W
addwf TmpReg2,W
btfsc STATUS,Z
goto zero
bcf STATUS,Z
decf Storlox
goto sub16
larger incf Storlox
goto sub16
zero incf Storlox
goto sub16
I am totaly confused with carry's not going well
this makes me think to do somting in two complement like this
also totaly confusing
Storlox equ 0x10
Storhix equ 0x11
;Storloy equ 0x12
;Storhiy equ 0x13
TmpReg1 equ 0x14
TmpReg2 equ 0x15
datalo equ 0x16
datahi equ 0x17
movlw 0x30 ; new lowByte
movwf datalo ;
movlw 0x01 ; new highByte
movwf datahi
movlw 0x20 ; old lowByte
movwf Storlox
movlw 0x01 ; old highByte
movwf Storhix
clrf TmpReg1 ; Store diff
clrf TmpReg2 ; Store diff
comf datalo,W ; two complement lowbyte
addlw 0x01
movwf datalo
;btfsc STATUS,C
;incfsz datahi
comf datahi,W ;two complement higbyte
addlw 0x01
movwf datahi
cmp16
movf datalo,W ; datalo>W
addwf Storlox,W ; add oldlobyte
movwf TmpReg1 ; store difference
movf datahi,W ; get new higbyte
btfsc STATUS,C ; test carry ifso
incfsz Storhix,W ; incf oldhighbyte
addwf Storhix,W
movwf TmpReg2
btfss STATUS,C
goto smaller ; yes
goto larger ; no
smaller movf TmpReg1,W
addwf TmpReg2,W
btfsc STATUS,Z
goto zero
bcf STATUS,Z
decf Storlox
goto cmp16
larger incf Storlox
goto cmp16
zero incf Storlox
goto zero
I realy need help on this
Marcel Elektronic workshop
Amsterdam
1998\04\18@144342
by
marcel
|
marcel wrote:
{Quote hidden}> Tanks for the reply's on this matter
> the thing is what i wand to do is more complicated
> I am reading 12 bit of data from an potentiometer when it is in the
> middle
> it should give something like 0x0800 "hex"
> when i turn left it decreases and when i turn right it increases
> The maximum increment should be from 0x80 to 0xEF and the maximum
> decrement must not cross 0x00 from0x80 down to 0x00within one reading
> if so i have to increment or decrement
> with these maximums or less until i reach the last readout.
>
> I hope i am more clear on what i want to do
>
> I can get the data msb first in the registers datahi and datalo but
> the LTC1286 allows also to read LSB first
>
> Example first readout could be x0800 the next 0x0880
> the differents is 80 positive is bigger than 0x7F so i add 0x7Fto
> previous readout
> and compare again with the last readout witch can have changed in this
> example
> i assume not so 0x880 sub 0x87F is 0x01 witch is less than 0x7F and
> i add 0x01 to the first readout and the process stops until a new
> readout
> appears to be differend .
>
> I don't understand what is the meaning msb stored at lower adress at the
>
> moment i am
> trying simulating this in MacPic
>
> Storlox equ 0x10
> Storhix equ 0x11
> ;Storloy equ 0x12
> ;Storhiy equ 0x13
> TmpReg1 equ 0x14
> TmpReg2 equ 0x15
> datalo equ 0x16
> datahi equ 0x17
>
> movlw 0x30
> movwf datalo
> movlw 0x01
> movwf datahi
> movlw 0x20
> movwf Storlox
> movlw 0x01
> movwf Storhix
> clrf TmpReg1
> clrf TmpReg2
>
> sub16
>
> movf datalo,W ; subtract lsbs
> subwf Storlox,W
> movwf TmpReg1
> movf datahi,W ; subtract msbs
> btfss status,C ; including any carry
> incfsz Storhix,W
> subwf datahi,W
> movwf TmpReg2
> btfsc status,C ; new smaller?
> goto smaller ; yes
> goto larger ; no
>
> smaller movf TmpReg1,W
> addwf TmpReg2,W
> btfsc STATUS,Z
> goto zero
> bcf STATUS,Z
> decf Storlox
> goto sub16
>
> larger incf Storlox
> goto sub16
>
> zero incf Storlox
> goto sub16
>
> I am totaly confused with carry's not going well
> this makes me think to do somting in two complement like this
> also totaly confusing
>
> Storlox equ 0x10
> Storhix equ 0x11
> ;Storloy equ 0x12
> ;Storhiy equ 0x13
> TmpReg1 equ 0x14
> TmpReg2 equ 0x15
> datalo equ 0x16
> datahi equ 0x17
>
> movlw 0x30 ; new lowByte
> movwf datalo ;
> movlw 0x01 ; new highByte
> movwf datahi
> movlw 0x20 ; old lowByte
> movwf Storlox
> movlw 0x01 ; old highByte
> movwf Storhix
> clrf TmpReg1 ; Store diff
> clrf TmpReg2 ; Store diff
>
> comf datalo,W ; two complement lowbyte
> addlw 0x01
> movwf datalo
> ;btfsc STATUS,C
> ;incfsz datahi
> comf datahi,W ;two complement higbyte
> addlw 0x01
> movwf datahi
>
> cmp16
> movf datalo,W ; datalo>W
> addwf Storlox,W ; add oldlobyte
> movwf TmpReg1 ; store difference
> movf datahi,W ; get new higbyte
> btfsc STATUS,C ; test carry ifso
> incfsz Storhix,W ; incf oldhighbyte
> addwf Storhix,W
> movwf TmpReg2
> btfss STATUS,C
> goto smaller ; yes
> goto larger ; no
>
> smaller movf TmpReg1,W
> addwf TmpReg2,W
> btfsc STATUS,Z
> goto zero
> bcf STATUS,Z
> decf Storlox
> goto cmp16
>
> larger incf Storlox
> goto cmp16
>
> zero incf Storlox
> goto zero
>
> I realy need help on this
>
> Marcel Elektronic workshop
> Amsterdam
1998\04\18@170527
by
marcel
|
I still have great difficulty on the folowing
it seems carry does not affect high byte
i am also not shure on testing for zero
i realy need help on this.
I am reading 12 bit of data from an potentiometer when it is in the
middle
it should give something like 0x0800 "hex"
when i turn left it decreases and when i turn right it increases
I can get the data msb first in the registers datahi and datalo but
the LTC1286 allows also to read LSB first
Maximum icrement or decrement must be no more than 0x7F
Can annyone help me with this?
Storlox equ 0x10
Storhix equ 0x11
;Storloy equ 0x12
;Storhiy equ 0x13
TmpReg1 equ 0x14
TmpReg2 equ 0x15
datalo equ 0x16
datahi equ 0x17
movlw 0x30
movwf datalo
movlw 0x01
movwf datahi
movlw 0x20
movwf Storlox
movlw 0x01
movwf Storhix
clrf TmpReg1
clrf TmpReg2
sub16
movf datalo,W ; subtract lsbs
subwf Storlox,W
movwf TmpReg1
movf datahi,W ; subtract msbs
btfss status,C ; including any carry
incfsz Storhix,W
subwf datahi,W
movwf TmpReg2
btfsc status,C ; new smaller?
goto smaller ; yes
goto larger ; no
smaller movf TmpReg1,W
addwf TmpReg2,W
btfsc STATUS,Z
goto zero
bcf STATUS,Z
decf Storlox
goto sub16
larger incf Storlox
goto sub16
zero incf Storlox
goto sub16
I am totaly confused with carry's not going well
this makes me think to do somting in two complement like this
also totaly confusing
Storlox equ 0x10
Storhix equ 0x11
;Storloy equ 0x12
;Storhiy equ 0x13
TmpReg1 equ 0x14
TmpReg2 equ 0x15
datalo equ 0x16
datahi equ 0x17
movlw 0x30 ; new lowByte
movwf datalo ;
movlw 0x01 ; new highByte
movwf datahi
movlw 0x20 ; old lowByte
movwf Storlox
movlw 0x01 ; old highByte
movwf Storhix
clrf TmpReg1 ; Store diff
clrf TmpReg2 ; Store diff
comf datalo,W ; two complement lowbyte
addlw 0x01
movwf datalo
;btfsc STATUS,C
;incfsz datahi
comf datahi,W ;two complement higbyte
addlw 0x01
movwf datahi
cmp16
movf datalo,W ; datalo>W
addwf Storlox,W ; add oldlobyte
movwf TmpReg1 ; store difference
movf datahi,W ; get new higbyte
btfsc STATUS,C ; test carry ifso
incfsz Storhix,W ; incf oldhighbyte
addwf Storhix,W
movwf TmpReg2
btfss STATUS,C
goto smaller ; yes
goto larger ; no
smaller movf TmpReg1,W
addwf TmpReg2,W
btfsc STATUS,Z
goto zero
bcf STATUS,Z
decf Storlox
goto cmp16
larger incf Storlox
goto cmp16
zero nop ; incf Storlox
goto zero
I realy need help on this
Marcel Elektronic workshop
Amsterdam
1998\04\18@171115
by
marcel
|
marcel wrote:
{Quote hidden}> I still have great difficulty on the folowing
> it seems carry does not affect high byte
> i am also not shure on testing for zero
> i realy need help on this.
> I am reading 12 bit of data from an potentiometer when it is in the
> middle
> it should give something like 0x0800 "hex"
> when i turn left it decreases and when i turn right it increases
>
> I can get the data msb first in the registers datahi and datalo but
> the LTC1286 allows also to read LSB first
>
> Maximum icrement or decrement must be no more than 0x7F
>
> Can annyone help me with this?
>
> Storlox equ 0x10
> Storhix equ 0x11
> ;Storloy equ 0x12
> ;Storhiy equ 0x13
> TmpReg1 equ 0x14
> TmpReg2 equ 0x15
> datalo equ 0x16
> datahi equ 0x17
>
> movlw 0x30
> movwf datalo
> movlw 0x01
> movwf datahi
> movlw 0x20
> movwf Storlox
> movlw 0x01
> movwf Storhix
> clrf TmpReg1
> clrf TmpReg2
>
> sub16
>
> movf datalo,W ; subtract lsbs
> subwf Storlox,W
> movwf TmpReg1
> movf datahi,W ; subtract msbs
> btfss status,C ; including any carry
> incfsz Storhix,W
> subwf datahi,W
> movwf TmpReg2
> btfsc status,C ; new smaller?
> goto smaller ; yes
> goto larger ; no
>
> smaller movf TmpReg1,W
> addwf TmpReg2,W
> btfsc STATUS,Z
> goto zero
> bcf STATUS,Z
> decf Storlox
> goto sub16
>
> larger incf Storlox
> goto sub16
>
> zero incf Storlox
> goto sub16
>
> I am totaly confused with carry's not going well
> this makes me think to do somting in two complement like this
> also totaly confusing
>
> Storlox equ 0x10
> Storhix equ 0x11
> ;Storloy equ 0x12
> ;Storhiy equ 0x13
> TmpReg1 equ 0x14
> TmpReg2 equ 0x15
> datalo equ 0x16
> datahi equ 0x17
>
> movlw 0x30 ; new lowByte
> movwf datalo ;
> movlw 0x01 ; new highByte
> movwf datahi
> movlw 0x20 ; old lowByte
> movwf Storlox
> movlw 0x01 ; old highByte
> movwf Storhix
> clrf TmpReg1 ; Store diff
> clrf TmpReg2 ; Store diff
>
> comf datalo,W ; two complement lowbyte
> addlw 0x01
> movwf datalo
> ;btfsc STATUS,C
> ;incfsz datahi
> comf datahi,W ;two complement higbyte
> addlw 0x01
> movwf datahi
>
> cmp16
> movf datalo,W ; datalo>W
> addwf Storlox,W ; add oldlobyte
> movwf TmpReg1 ; store difference
> movf datahi,W ; get new higbyte
> btfsc STATUS,C ; test carry ifso
> incfsz Storhix,W ; incf oldhighbyte
> addwf Storhix,W
> movwf TmpReg2
> btfss STATUS,C
> goto smaller ; yes
> goto larger ; no
>
> smaller movf TmpReg1,W
> addwf TmpReg2,W
> btfsc STATUS,Z
> goto zero
> bcf STATUS,Z
> decf Storlox
> goto cmp16
>
> larger incf Storlox
> goto cmp16
>
> zero nop ; incf Storlox
> goto zero
>
> I realy need help on this
>
> Marcel Elektronic workshop
> Amsterdam
More... (looser matching)
- Last day of these posts
- In 1998
, 1999 only
- Today
- New search...