Download Designer Reference Manual
Transcript
Freescale Semiconductor, Inc. LIN Stepper Software Description LIN Stepper Software Implementation UWord16 variable frequencyActLowHigh.Word. This will guarantee the low resolution (necessary to create low steepness frequency ramps). For the frequency-to-period calculation and comparison with required frequency frequencyReq, it is sufficient to use 8-bit information. This allows to use fast calculations like frequency to speed conversion using udiv16_8to16. Then the high byte frequencyActLowHigh.Byte.High is accessed. Freescale Semiconductor, Inc... 6.3.4 Actual Frequency to Period Conversion The conversion from frequency to period requires division. 1 Period = --------------------------Frequency (EQ 19.) For software execution optimized calculation we wrote a special arithmetic function: UWord16 udiv16_8to16(UWord16 x, UByte y) with UWord16 output and UWord16 x, UByte y inputs. It is written in assembler and provides the following calculation: Variable1UWord16 Variable3 = UWord16 -----------------------------------------------UByte Variable3 (EQ 20.) The conversion must take into account the variables scaling: 1 Resolution Period*(UWord16) periodStep = --------------------------------------------------------------------------------------------------------Resolution Frequency*(UByte8) Frequency (EQ 21.) UWord16 ) ( Resolution Frequency/ResolutionPeriod )(UWord16) periodStep = (----------------------------------------------------------------------------------------------------------------------------------(UByte8) Frequency (EQ 22.) So the final calculation using the udiv16_8to16 function is: ( UWord16 ) ( CONVERSION_CONST_PERIOD_FERQ -) (UWord16) periodStep = ------------------------------------------------------------------------------------------------------------------------------------------(UByte8) frequencyActLowHigh.Byte.High (EQ 23.) where: Resolution Period [s] is RESOLUTION_PERIOD_NS*1000000000.0 DRM047 — Rev 0 MOTOROLA Designer Reference Manual LIN Stepper Software Description For More Information On This Product, Go to: www.freescale.com 69