I need help with a math question.
I'm reading an analog input, and now also on the micro 8-bit analog converters are 10/12 bit. When I read the value I have to do an average, and would be good to use the shift (I read all the posts on the subject), 1, 2, etc.. that is left to right for the various mathematical operations to base 2. over the integers.
In C there is the << and >> they do also on the integers, and the long, do not know if there are special commands in asembler that they do, but usually the shift is much more compact in code that division or multiplication.
Any help is welcome, Thaks, Marco
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anobium good evening
Thanks as always for your assistance, I have seen this command, and also rotate, but only work on bytes, I downloaded the manual of AVR assembler and I'm investigating but as you know at this level is quite difficult for me.
In the meantime, if anyone has some more information, so be it. Thanks, Marco
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
' using uf_shift to ensure we do not clash with any potential PUBLIC method.
Function uf_shift_long ( l_invar as Long , l_rotateval, l_direction ) as Long
and, then today. I remembered the code from the F1 Evaluation Port of last year.
This has an average function.... this may help.
~~~~~
Dim g_average As Long
Functioninput_pot(OptionalccountAsbyte=2)aswordg_average=0forlloop=1toccountg_average=[Long]g_average+[Long]ReadAD10(ADCPort)nextg_average=[Long]g_average/[Long]lloopinput_pot=g_average' use the three LED'stoshowtheADCvalueselectcaseg_averagecase<200setled1offsetled2offsetled3offsetled4offcase<400setled1onsetled2offsetled3offsetled4offcase<600setled1onsetled2onsetled3offsetled4offcase<800setled1onsetled2onsetled3onsetled4offcase=>800setled1onsetled2onsetled3onsetled4onendselect
End Function
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello
I need help with a math question.
I'm reading an analog input, and now also on the micro 8-bit analog converters are 10/12 bit. When I read the value I have to do an average, and would be good to use the shift (I read all the posts on the subject), 1, 2, etc.. that is left to right for the various mathematical operations to base 2. over the integers.
In C there is the << and >> they do also on the integers, and the long, do not know if there are special commands in asembler that they do, but usually the shift is much more compact in code that division or multiplication.
Any help is welcome, Thaks, Marco
This may help. http://gcbasic.sourceforge.net/help/average.htm
There is a function that will average two numbers.
Anobium
Anobium good evening
Thanks as always for your assistance, I have seen this command, and also rotate, but only work on bytes, I downloaded the manual of AVR assembler and I'm investigating but as you know at this level is quite difficult for me.
In the meantime, if anyone has some more information, so be it. Thanks, Marco
Two functions I have in my own utils.h file, uf_shift and uf_shift_long. You need the two defines.
Usage example: w_addrH = uf_shift ( w_addr, 8, >> )
~~~~
define << 0
define >> 1
' using uf_shift to ensure we do not clash with any potential PUBLIC method.
Function uf_shift ( l_invar as word , l_rotateval, l_direction ) as word
end function
' using uf_shift to ensure we do not clash with any potential PUBLIC method.
Function uf_shift_long ( l_invar as Long , l_rotateval, l_direction ) as Long
end function
Thanks Anobium
This night I study this
and, then today. I remembered the code from the F1 Evaluation Port of last year.
This has an average function.... this may help.
~~~~~
Dim g_average As Long
End Function