can any one tell me what this export symbol XDEF LF_II function doing.?,i couldnt understand from assembly codes,please
thanks in advance
Dear peg,bigmac help me,please
(actually for rms current calculation, this library function is used in one program ,i want to know what this fn doing)
here i have attached the LF_II code
As far as I can judge, the sub-routine seems to be calculating the "mean-squared" value of the 10-bit Iac_10b unsigned value, and placing the 20-bit result within an assumed 24-bit variable Iac_LFR. The filtering algorithm (to obtain the mean) is unknown to me.
The code is poorly written on at least two counts -
The following comments describe what each section of code seems to be doing. Perhaps others may be able to explain the filtering method.
; Square 10-bit value: result -> IX ; Calculate IX += IY ; Right shift IY by 6 places ; Calculate IY = IX - IY ; SECOND FILTER ; Calculate IT = IY - IZ ; Right shift IT by 6 places
; Calculate IZ += IT; IR = IZ
; Right shift IR by 6 places ; Calculate Iac_LFR = IR + 2 (20-bit result)Regards,
I made a further attempt to understand the operation of the filter algorithm, and it appears that a standard form of filter is actually used, that gives results close to a single RC circuit in the analog domain. In fact the filter is applied twice, to give the effect of two cascaded CR circuits with equal time constants.
The registers IY and IZ are the filtered values, that must remain static, and must be initialised. Also keep in mind that shift right 6 places is identical to divide by 64. So the calculation of each updated filtered value may be derived.
IY = IX + IY*63/64
IZ = IY + IZ*63/64
Each filtered value is 64 times greater than the final mean (20-bit) value. This is why IZ needs to be divided by 64. I am not sure why the final value has then been incremented by 2.
I also observe that the dword registers IX, IR and IT are for temporary use only, and only a single register (say IX) is actually necessary. This should reduce the dedicated RAM requirement to 12 bytes.
I have attempted to "clean up" the code, but the attached code remains untested so there might possibly be some overlooked errors.
great explanation,thank you so much bigmac,
after test this code again i will contact you!
Retrieving data ...