STM32F446 内蔵の DAC から出力する際に,補間フィルタを利用し,標本化周波数を入力の際の4倍の標本化周波数で出力するためのライブラリ.このライブラリを登録した際のプログラム: Demo_DSP_ADDA_Multirate. Library for outputting from built-in DAC in STM32F446 using interpolation filter at sampling frequency of 4 times in case of input.
Dependencies: Array_Matrix DSP_ADDA
Dependents: Demo_DSP_ADDA_Multirate DSP_AD_DA_Multirate DSP_GraphicEqualizerB DSP_VariableLHpfB ... more
Diff: MultirateLiPh.hpp
- Revision:
- 1:6f582d9e27b4
- Parent:
- 0:79c0b1e2fd10
- Child:
- 2:aa092bbc8877
--- a/MultirateLiPh.hpp Mon May 25 06:13:53 2020 +0000 +++ b/MultirateLiPh.hpp Mon May 25 12:49:15 2020 +0000 @@ -21,7 +21,7 @@ public: // コンストラクタ MultirateLiPh(); - + virtual ~MultirateLiPh() { delete adc_; } // 標本化の実行開始 @@ -35,7 +35,6 @@ // AD変換の結果を取り出す float Input() { return xn_; } - // 補間用フィルタを実行し,処理結果を出力用バッファへ書き込む void Output(float yn); @@ -47,29 +46,29 @@ static DspAdc_Intr *adc_; // AD変換器のオブジェクトのポインタ static DspDac dac_; // DA変換器のオブジェクト - + static Array<float> buf_; // DA変換器に出力するデータ用バッファ static int indexR_; // buf_ から読み出す際のインデックス static float xn_; // AD変換器から入力されたデータ int indexW_; // buf_ へ書き込む際のインデックス - + // 補間用フィルタ用 const int FIR_LOOP_; // FIR フィルタのループの数 const int CENTER_; // 補間処理をしない信号の位置 Array<float> un_; // FIR フィルタの遅延器に対応するバッファ - Array<float> h1_, h2_, h3_; // FIR フィルタの係数 + const Array<float> h1_, h2_, h3_; // FIR フィルタの係数 // 補間用フィルタ用の係数(デフォルト) static const int ORDER_; static const float HK1_[], HK2_[], HK3_[]; // 引数を 0 ~ (アップサンプリング倍率-1) の間でカウントアップ - static inline int ModIndex(int &index) - { return ++index & MASK_BUF_; } + static int ModIndex(int &index) + { return index = ++index & MASK_BUF_; } // ADC 変換終了割り込みに対する割り込みサービス・ルーチン static void AdcIsr(); - + // 補間用 FIR フィルタ float Interpolator(const float hk[]) const; };