diff --git a/package.json b/package.json index 9ab4389..5b2b724 100755 --- a/package.json +++ b/package.json @@ -2,5 +2,5 @@ "name": "framework-arduino-lpc176x", "description": "Arduino Wiring-based Framework (LPC176x CMSIS 5)", "url": "https://www.arduino.cc/en/Main/Software", - "version": "0.2.1" + "version": "0.2.2" } diff --git a/system/lpc176x/adc.h b/system/lpc176x/adc.h index f7cee54..4393789 100644 --- a/system/lpc176x/adc.h +++ b/system/lpc176x/adc.h @@ -298,9 +298,9 @@ struct ADC { }; struct LowpassFilter { - uint32_t data_delay = 0x7FFF << ADC_LOWPASS_K_VALUE; + uint32_t data_delay = 0xFFFFFFFF; [[gnu::always_inline]] inline uint16_t update(uint16_t value) { - data_delay = data_delay - (data_delay >> ADC_LOWPASS_K_VALUE) + value; + data_delay = data_delay == 0xFFFFFFFF ? value << ADC_LOWPASS_K_VALUE : data_delay - (data_delay >> ADC_LOWPASS_K_VALUE) + value; return (uint16_t)(data_delay >> ADC_LOWPASS_K_VALUE); } };