Hi, >Tony, it looks clear to me except the following one: >> Lets see if we can do something about the output/64 part. >> Ok, if we represent the input ( 10 bits ) in 8q8 format >> ( or really 8q2 but as we use two bytes 8q8 is more correct ) >> i.e 'multiply' (leftshift 6 times) the input value by 64. >> We achive for d'376' the value 0x5E00 and for d'978' 0xF480 >> the diff is 0x9680 or d'602'*64 as you stated. > shifting left 6 times equ multiplying with 2^6 =3D 64, >better than my x100 multiply. How can be done this with two 8 bit >register? First the 8q8 is not really correct way of decribing what I meant, hmm..maybe I should think first :) anyway here goes: Well I think you should be able to to use the 'left justify' of the 10 bit pic ad module. I.e. from the datasheets: ( from 18C452 ) ADCON1 register: bit 7 - ADFM = 1 - Right justified 6 msbits of ADRESH are read as 0's 0 - Left justified 6 lsbits of ADRESL are read as 0's So in essence setting this bit to '0' means that the 16 bit result ( which of only 10 contains valid data ) will be ad result*64 if read as a normal 16 bit integer. I.e. = ADFM =3D 1, input d'512' -> ADRESH =3D HIGH(512), ADRESL =3D LOW(512) ADFM =3D 0, input d'512' -> ADRESH =3D HIGH(512<<6), ADRESL =3D LOW(512<<= 6) Which is what we needed, an multiply with 64. But generally you could do this: Val_16 RES 2 ; declare a 16 bit variable ; load the value 512 into 16 bit variable MOVLW HIGH(D'512) MOVWF Val_16 MOVLW LOW(D'512) MOVWF Val_16 ; multiply with 64, i.e leftshift 6 times ; assuming input will always be 10 bits or less ;**** one way :) BCF STATUS,C ; clear carry initially ; *2 RLF Val_16+1 ; shift out top bit into carry RLF Val_16 ; shift in carry into lowest bit ; *4 RLF Val_16+1 ; shift out top bit into carry RLF Val_16 ; shift in carry into lowest bit ; *8 RLF Val_16+1 ; shift out top bit into carry RLF Val_16 ; shift in carry into lowest bit ; *16 RLF Val_16+1 ; shift out top bit into carry RLF Val_16 ; shift in carry into lowest bit ; *32 RLF Val_16+1 ; shift out top bit into carry RLF Val_16 ; shift in carry into lowest bit ; *64 RLF Val_16+1 ; shift out top bit into carry RLF Val_16 ; shift in carry into lowest bit ; we are done 13 instructions ; val_16 now is 512*64 =3D 0x8000 ; ** or to save an instruction SWAPF Val_16,F ; swap nibbles, i.e. multiply with 16 SWAPF Val_16+1,W ; prepare next nibble ANDLW 0x0F ; mask out lowest nibble ( top from original byte ) IORWF Val_16,F ; set bottom nibble SWAPF Val_16+1,F ; prepare lowest nibble MOVLW 0xF0 ANDWF Val_16+1,F ; Val_16 now is original value*16 BCF STATUS,C ; clear carry RLF Val_16+1 ; shift out top bit into carry RLF Val_16 ; shift in carry into lowest bit ; *64 RLF Val_16+1 ; shift out top bit into carry RLF Val_16 ; shift in carry into lowest bit I think :) = /Tony Thank's, Vasile = Tony K=FCbek, Flintab AB = =B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2= =B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2= =B2=B2=B2=B2=B2=B2=B2=B2=B2=B2 E-mail: tony.kubek@flintab.com =B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2= =B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2= =B2=B2=B2=B2=B2=B2=B2=B2=B2=B2 -- http://www.piclist.com hint: PICList Posts must start with ONE topic: [PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads