bill
July 20, 2006, 2:56pm
1
do not exist
Well, i’m very interested in this function, but as i have allready wrote, i not a asm person.
I’ve located the MIOS_AIN_Pin7bitGet function in src/mios_ain.inc
;; --------------------------------------------------------------------------
;; FUNCTION: MIOS_AIN_Pin7bitGet
;; C_DECLARATION: unsigned char MIOS_AIN_Pin7bitGet(unsigned char pin)
;; DESCRIPTION: returns 7-bit value of AIN input ....
;; --------------------------------------------------------------------------
MIOS_AIN_Pin7bitGet
andlw 0x3f
lfsr FSR1, MIOS_AIN_RESULT_L_00
addwf FSR1L, F
movff INDF1, MIOS_PARAMETER1
bsf FSR1L, 6
movff INDF1, MIOS_PARAMETER2
;; note: a multiplication would work faster, but would overwrite PRODL/PRODH
rrf MIOS_PARAMETER2, F
rrf MIOS_PARAMETER1, F
rrf MIOS_PARAMETER2, F
rrf MIOS_PARAMETER1, F
rrf MIOS_PARAMETER1, W
andlw 0x7f
movwf MIOS_PARAMETER1
return
But i’m dont know how to understand it :-\
Can a clever person tell me what to change ? (i suppose it must be pretty simple)
Thanks !!!
T.K
July 20, 2006, 4:06pm
2
Just remove the two first (!) rrf’s + the “andlw 0x7f”
Best Regards, Thorsten.
bill
July 20, 2006, 4:39pm
3
Wow, so fast ! Thanks
So, is it a good idea to add it into mios_ain.inc or should i use the function as ‘standalone’
If i want to add it to MIOS, what changes should i do to the mios_vectors.inc ???
Thanks
T.K
July 20, 2006, 5:11pm
4
Never add such custom functions into MIOS, it makes your application incompatible.
Just write the function into a seperate .c or .asm or .inc file, this can be distributed very easily.
On the other hand: in my own applications, I don’t call functions for such special conversions at all. I mostly do the conversion directly, which is faster.
In C you only need to write “value >> 2” to get the same effect, so why creating a function?
Best Regards, Thorsten.
T.K
July 20, 2006, 5:13pm
5
P.S.: see map.h of the “analog_toolbox” application
bill
July 20, 2006, 6:18pm
6
In C you only need to write “value >> 2” to get the same effect, so why creating a function?
I did not think about it ! ( i’m still new to “>>” )
i did not think about the compatibily too, but hey, you are definitely right !
I guess it’s a newbe behavior : no to see the obvious.
Thanks a lot !!!