You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi Peter,
I try fir.py with MicroPython 1.17 on NUCLEO-L476RG board.
There is a problem only when the number of coefficients is a multiple of 4.
For exemple :
coeffs = array.array('i', (100, 100, 100, 100))
ncoeffs = len(coeffs)
data = array.array('i', [0]*(ncoeffs +3))
data[0] = ncoeffs
data[1] = 0
fir(data, coeffs, 1) # 100 OK
fir(data, coeffs, 0) # 100 OK
fir(data, coeffs, 0) # 100 OK
fir(data, coeffs, 0) # 134492960 bug
coeffs = array.array('i', (0, 100, 100, 100, 100)) works !
The text was updated successfully, but these errors were encountered:
Thanks for the report. I've pushed an update to fix this.
It was a classic array bounds error, performing one iteration too many and accessing a coefficient value from the location after the end of the array. This actually occurred regardless of the number of coefficients. A quirk of the array module caused the value in this location to be zero except when len(coeffs) % 4 == 0. This caused the bug only to be apparent under those conditions.
Hi Peter,
I try fir.py with MicroPython 1.17 on NUCLEO-L476RG board.
There is a problem only when the number of coefficients is a multiple of 4.
For exemple :
coeffs = array.array('i', (100, 100, 100, 100))
ncoeffs = len(coeffs)
data = array.array('i', [0]*(ncoeffs +3))
data[0] = ncoeffs
data[1] = 0
fir(data, coeffs, 1) # 100 OK
fir(data, coeffs, 0) # 100 OK
fir(data, coeffs, 0) # 100 OK
fir(data, coeffs, 0) # 134492960 bug
coeffs = array.array('i', (0, 100, 100, 100, 100)) works !
The text was updated successfully, but these errors were encountered: