hi，has anyone used Matlab coder to generate C code for a filter? Here is the thing: I tried to filter the same audio signal using Hamming window-based FIR bandpass filter, the filter is designed by Matlab DSP tool box. Then I used Matlab coder to generate the corresponding C code for deploying the filter on the MCU. But I found that the filtering in Matlab and that in MCU has differences, I think the result from Matlab is correct. Is the filter C code generated by Matlab not reliable? Maybe I should try ARM DSP library
You have differences in the transient, but the steady-state looks the same therefore it is probably a memory initialization problem in the C-code
Here are a few things to check :
Are you sure your input is exactly the same? Make sure your input buffer is properly initialized in the C-code.
You probably have some kind of data buffer to store the previous samples. Again make sure the data is properly initialized. If the data buffer is not properly initialized you will likely have garbage in the data buffer instead of having '0' in the data buffer which would explain why the transient is different.
The Matlab coder generates 3 user functions, Initialize, Step and Terminate. Make sure you call Initialize once, before make any call to Step.