November 17, 200619 yr A MODULE_VAR like COM_FREQUENCY normally returns a BCD value for the frequency, less the most significant digit.For example, if the COM1 frequency is currently 118.25, then MODULE_VAR com_frequency = { COM_FREQUENCY }; lookup_var(&com_frequency); UINT32 bcd = com_frequency.var_value.d;would set bcd == 0x1825. Now, what if you enable 25 KHz tuning, by setting COM_RADIO_25_KHZ_TUNABLE true?Does this just mean the final digit can now be '2' or '7' in addition to '0' or '5', and you interpret that to me .025 MHz or .075 MHz?
November 17, 200619 yr Author Moderator Yep.... That's precisely what you do. For my fully-featured Collins RTU (Radio Tuning Unit) I developed string-based BCD2DEC() and DEC2BCD() functions to handle this situation.As it turns out, it's actually a lot faster than using the typical bit-shifing conversion function... ;) Fr. Bill AOPA Member: 07141481 AARP Member: 3209010556 Avsim Board of Directors | Avsim Forums Moderator
November 18, 200619 yr Author Moderator >Oh? Did you profile it or eyeball that measurement? :DI reasoned it out using logical thinking... fewer operations equals faster execution... ;)If both methods are 'translated' to assembly equivalents, the string method requires less than one-third of the operations as the bit-shifing method. Fr. Bill AOPA Member: 07141481 AARP Member: 3209010556 Avsim Board of Directors | Avsim Forums Moderator
Create an account or sign in to comment