Jump to content

Recommended Posts

Posted

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 !!!

Posted

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

Posted

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.

Posted
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 !!!

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...