FIR filter using DSP instructions for ST Nucleo F401RE.
Dependencies: UITDSP_ADDA mbed
Diff: main.cpp
- Revision:
- 8:d226de4c3951
- Parent:
- 6:f005cc78b9aa
--- a/main.cpp Sat Nov 15 06:09:37 2014 +0000 +++ b/main.cpp Mon Nov 16 02:24:22 2015 +0000 @@ -2,21 +2,19 @@ // FIR フィルタ,基本的な構造, 固定小数点演算用 DSP 命令を使う // 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 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() { @@ -42,7 +40,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 }