How to convert integer number to Q1.15 format?
Hello,
I am using STM32G491 controller for my application. I am trying to use FMAC module for FIR filter implementation for my application. I am referring the STM32G4-Peripheral-Filter_Math_Accelerator_FMAC.pdf FMAC pdf document. I have also referred the FMAC example sample code https://github.com/STMicroelectronics/STM32CubeG4/tree/master/Projects/NUCLEO-G474RE/Examples/FMAC/FMAC_FIR_DMAToIT
As the FMAC module accepts input buffer in q1.15 format.
I have used below formula to convert int16_t value to q1.15 format.
Number = 100;
/First , normalization
float v1_f = 100/32767.0;
//second, convert the normalized results into Q Format
v1_q15 = int16_t(V1_f *0x8000) +0.5;
placed this v1_q15 value as the buffer element. Is the above formula for q1.15 conversion is correct? I am not getting the expected output which I have calculated from the FIR filter formula.
Can any one support me to convert the integer value to q1.15 format and q1.15 format output to integer number? Any help would be appreciated.
Thanks in advance
Kirti
