Input buffer = 1000 samples
Output buffer = 100 samples
process time = 936us @ 80MHz with STM32L412KB
Program:
// Define variables
q31_t pSrc[1000];
q31_t pDst[1000];
q31_t pCoeffs[] = { 1943208, 464978, 305641, -49046, -638438, -1497324,
-2650941, -4109235, -5862456, -7878098, -10098245, -12435856,
-14770057, -16950103, -18809941, -20144286, -20744894,
-20388173, -18853952, -15933574, -11440900, -5223349, 2827034,
12763159, 24575302, 38187347, 53451404, 70147061, 87988766,
106625888, 125658165, 144643853, 163116013, 180598380,
196623003, 210748070, 222574464, 231761399, 238041130,
241228017, 241228017, 238041130, 231761399, 222574464,
210748070, 196623003, 180598380, 163116013, 144643853,
125658165, 106625888, 87988766, 70147061, 53451404, 38187347,
24575302, 12763159, 2827034, -5223349, -11440900, -15933574,
-18853952, -20388173, -20744894, -20144286, -18809941,
-16950103, -14770057, -12435856, -10098245, -7878098, -5862456,
-4109235, -2650941, -1497324, -638438, -49046, 305641, 464978,
1943208, };
q31_t pState[1000 + 80];
arm_fir_decimate_instance_q31 S;
uart_init();
while (1) {
// Initialize buffer pSrc
for (int i = 0; i < 1000; i++)
pSrc[i] = 0;
for (int i = 0; i < 500; i++)
pSrc[i] = 10000000;
// Process data
arm_fir_decimate_init_q31(&S, 80, 10, pCoeffs, pState, 1000);
GPIOA->BSRR = (1 << 3); // Set PA3
arm_fir_decimate_q31(&S, pSrc, pDst, 1000);
GPIOA->BRR = (1 << 3); // Reset PA3
// Output data
for (int i = 0; i < 100; i++) {
printf("%ld\r\n", pDst[i]);
while(uart_sending());
}
HAL_Delay(2000);
}
Attached: output response to a step signal
9048
-140025
-933846
1473627
11115434
19592287
20790631
20040573
19984258
19984258
19984258
19984258
19984258
19984258
19984258
19984258
19984258
19984258
19984258
19984258
19984258
19984258
19984258
19984258
19984258
19984258
19984258
19984258
19984258
19984258
19984258
19984258
19984258
19984258
19984258
19984258
19984258
19984258
19984258
19984258
19984258
19984258
19984258
19984258
19984258
19984258
19984258
19984258
19984258
19984258
19975209
20124282
20918103
18510631
8868823
391970
-806373
-56316
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0