![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
FIR filter using fixed point arithmetic operations for ST Nucleo F401RE.
Dependencies: UITDSP_ADDA mbed
Diff: main.cpp
- Revision:
- 8:abd11816e480
- Parent:
- 6:bb0e5ef9befe
--- a/main.cpp Sat Nov 15 06:07:42 2014 +0000 +++ b/main.cpp Mon Nov 16 02:23:51 2015 +0000 @@ -2,21 +2,19 @@ // FIR フィルタ,基本的な構造, 固定小数点演算を使う // Analog Input : A0 // Analog Output: MCP4922 using SPI -// 2014/11/12, Copyright (c) 2014 MIKAMI, Naoki +// 2015/11/16, Copyright (c) 2015 MIKAMI, Naoki //-------------------------------------------------------------- -#include "mbed.h" - -#include "ADC_Base.hpp" // for ADC not using interrupt -#include "DAC_MCP4922.hpp" // for DAC MCP4922 +#include "ADC_BuiltIn.hpp" // for ADC not using interrupt +#include "DAC_MCP4921.hpp" // for DAC MCP4921, MCP4922 #include "Coefficients_200_LPF_Fixed.hpp" using namespace Mikami; const int FS_ = 12000; // Sampling frequency: 12 kHz const uint16_t OFFSET = 2047; // Correspond to "0" -ADC_Base adc_(A0, FS_); // for AD -DAC_MCP4922 myDac_; // for DA +ADC_BuiltIn adc_(A0, FS_); // for AD +DAC_MCP4921 myDac_; // for DA int main() { @@ -39,7 +37,7 @@ xn[k] = xn[k-1]; // move input signals // rounding and devide by 32768 + DC offset - uint16_t yOut = ((yn + 0x8000) >> 15) + OFFSET; + uint16_t yOut = ((yn + 0x4000) >> 15) + OFFSET; //----------------------------------------------- myDac_.Write(yOut); // Write to DAC }