This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TMS320F280023C: IQ format

Part Number: TMS320F280023C


Hi Experts,

We need your help. 

Our customer want to convert 12 bit ADC counts (4096) to IQ24 format. So, if we write (ADCcounts<<12) or we write _IQ12toIQ(ADCcounts), will these both operations give us the same result?

Best regards,

Jonathan

  • Hello Johnathan,

    So, if we write (ADCcounts<<12) or we write _IQ12toIQ(ADCcounts), will these both operations give us the same result?

    This is not how the IQ library works. The different formats such as IQ12 are fixed-point datatypes, so there are bits that need to be reserved for the fractional amount. The first statement of (ADCcounts <<12) will work, since IQ12 uses 12 bits for the fractional precision. However, using _IQ12toIQ(ADCcounts) will not work because this function converts a IQ12 fixed-point datatype (with precision of 12 bits) to whatever the global IQ fixed-point precision is. This assumes the value ADCcounts is already in fixed-point format, which from your question it sounds like this will not be the case. There's no built-in function that converts an integer to IQ (since the purpose of IQmath is that legacy code was built before the FPU).

    If the customer wants to use floating-point datatypes and their code does not already use the IQmath library for legacy reasons, I would recommend to just use floating point data types since the F28002x supports floating-point types with the FPU.

    Best regards,

    Omer Amir

  • Hi Omer,

    I would like to post the customer's feedback here.

    I am very grateful for the post, but I am unable to proceed with my doubt yet. I have one more question regarding the same. If I can get the answer then I will be very grateful to you. My next question in the series is, the ADCs are of 12 bits, so the max count will be 4096. But, I am storing the value in a 16 bit variable, so which IQ conversion format will be used to convert it to _IQ24? _IQ12toIQ(ADC_counts) or _IQ16toIQ(ADC_counts)?

    Please help to elaborate. Thank you so much.

    Best regards,

    Jonathan

  • Hello Johnathan,

    The all the IQ precision datatypes use the long datatype, which is 32 bits. If the customer is using the IQmath library, they should be storing them as such.

    But, I am storing the value in a 16 bit variable, so which IQ conversion format will be used to convert it to _IQ24? _IQ12toIQ(ADC_counts) or _IQ16toIQ(ADC_counts)?

    As I stated before, the IQmath library uses fixed-point datatypes. This means the first portion of bits in the value are reserved for the whole number amount, and the last portion is reserved for the fractional amount (or the precision). The ADC results are NOT fixed-point, so they cannot be used directly in any of the conversion functions, since it is not already an IQ value. The method mentioned before should be sufficient, where the value is shifted left to account for the number of precision bits.

    Best regards,

    Omer Amir