#### Because of the Thanksgiving holiday in the U.S., TI E2E design support forum responses may be delayed the week of Nov. 21. Thank you for your patience.

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.

Part Number: TMS320F2808

Dear team:

When testing the project with the following code, my customer found that when a floating-point data is given to the parameter lBalanceBRFXn, the running result of the program is correct.

When a fixed-point data is given to the parameter lbalancebrfxn, the output result after the program runs is 0.

Here is the code:

```#define lB0 16560587
#define lB1 -33075803
#define lB2 16560587
#define lA1 -33075803
#define lA2 16343958

long long lBalanceBRFXn;
long long lBalanceBRFYn;
long long lBalanceBRFXn_1;
long long lBalanceBRFXn_2;
long long lBalanceBRFYn_1;
long long lBalanceBRFYn_2;

lBalanceBRFYn = (lBalanceBRFXn * lB0)>>24 + (lBalanceBRFXn_1 * lB1)>>24 + (lBalanceBRFXn_2 * lB2)>>24
- (lBalanceBRFYn_1 *lA1)>>24 - (lBalanceBRFYn_2 * lA2)>>24;
//
lBalanceBRFYn_2 = lBalanceBRFYn_1;
lBalanceBRFYn_1 = lBalanceBRFYn;
lBalanceBRFXn_2 = lBalanceBRFXn_1;
lBalanceBRFXn_1 = lBalanceBRFXn;```

Best regards

• Hi,

It looks like the code you shared is in fixed point. Did you make sure to appropriately change the data types to float and also the #define values?
What is the fixed point format in terms of Q value? Are the values fed the same? Are you accounting for overflow/underflow?

-Shantanu

• Hi Shantanu:

What is the fixed point format in terms of Q value?

Format is Q24.

Are the values fed the same?

Customer's Original value is:

lB0  = 0.987087899425535
lB1 =  -1.97147149483059
lB2 =  0.987087899425535
lA1 =  -1.97147149483059
lA2 =  0.974175798851069

After conversion to Q16:

lB0 =  16560587
lB1 = -33075803
lB2 =16560587
lA1 = -33075803
lA2 = 16343958

Are you accounting for overflow/underflow?

The customer confirms that there will be no overflow/underflow after calculation. Even if the customer uses a longer "long long" integer, there is no overflow.

The following code is a notch filter that can filter out 150Hz. If the customer uses floating-point operation, it can be output normally.

```lBalanceBRFXn = 100+50*sin(2*pi*150*iCnt/18000)；

lBalanceBRFYn = lBalanceBRFXn * lB0 + lBalanceBRFXn_1 * lB1 + lBalanceBRFXn_2 * lB2
- lBalanceBRFYn_1 * lA1- lBalanceBRFYn_2 * lA2;

lBalanceBRFYn_2 = lBalanceBRFYn_1;
lBalanceBRFYn_1 = lBalanceBRFYn;
lBalanceBRFXn_2 = lBalanceBRFXn_1;
lBalanceBRFXn_1 = lBalanceBRFXn;```

If you use fixed point instead, the output is 0. The code is as follows:

```lBalanceBRFXn = 100+50*sin(2*pi*150*iCnt/18000)；

lBalanceBRFYn = (lBalanceBRFXn * lB0)>>24 + (lBalanceBRFXn_1 * lB1)>>24 + (lBalanceBRFXn_2 * lB2)>>24
- (lBalanceBRFYn_1 *lA1)>>24 - (lBalanceBRFYn_2 * lA2)>>24;
/
lBalanceBRFYn_2 = lBalanceBRFYn_1;
lBalanceBRFYn_1 = lBalanceBRFYn;
lBalanceBRFXn_2 = lBalanceBRFXn_1;
lBalanceBRFXn_1 = lBalanceBRFXn;```

Best regards

• In addition, in the user's Guide of iir32 filter, is the output in the table subject to q30 calibration?

• Hi,

Apologies for the delay. If you are using the library filter method, the output format is fixed. However in this code, it looks like you are implementing the filter yourself.

Are you using the fixed point/IQMath libraries? If so, please confirm whether the correct library is being used with the correct processor options (fpu32, etc).

Are you using any optimisation while compiling the code? If so, please turn it off and try.

If the answers to the above are no, please share a screenshot of the disassembly for both cases (fixed point and floating point) so we can further debug it.

-Shantanu