Hi, i have used IIR filters on mcu.
y[j]=B[0]*x[j]+B[1]*x[j-1]+B[2]*x[j-2]-A[1]*y[j-1]-A[2]*y[j-2]; A,B coefficients were from matlab, And it worked.
Your code looks good. But filter to work, for(;;) cycle must sample at 10kHzrate as you chosen in matlab. And now i dont see any timing in code, that means that it samples as fast as it can. Maybe thats a problem. I think that coefficients are correlated with sampling frequency, in matlab [B,A]=butter(order,Wn,'type'), Wn=0:1, Wn = fcutoff/fsampling. Nice oscilloscope thought.