Prototype program of AD and DA using classes in UIT_ADDA. This program uses interrupt of ADC for ST Nucleo F401RE. UIT_ADDA のクラスを使った AD および DA のためのプログラムの雛形.ADC の割り込みを使うバージョン.ST Nucleo F401 用.
main.cpp
- Committer:
- MikamiUitOpen
- Date:
- 2014-10-30
- Revision:
- 5:aa0810bc0a76
- Parent:
- 4:c195f4d49c91
- Child:
- 6:82cc56bd6307
File content as of revision 5:aa0810bc0a76:
//-------------------------------------------------------------- // 割り込みを使って AD DA を行う場合の雛形1(入力:1 チャンネル) // Analog Input : A0 // Analog Output: MCP4922 using SPI // 2014/10/23, Copyright (c) 2014 MIKAMI, Naoki //-------------------------------------------------------------- #include "mbed.h" #include "ADC_Interrupt.hpp" // for ADC using interrupt #include "DAC_MCP4922.hpp" // for DAC MCP4922 #include "ScfClockTim3.hpp" // for clock supplied to SCF using namespace Mikami; const int FS_ = 10000; // Sampling frequency: 10 kHz ADC_Intr adc_(A0, FS_); // for AD DAC_MCP4922 myDac_; // for DA uint16_t a2_ = 0; uint16_t a21_ = 0; float vol_ = 1.0f; // Interrupt service routine for ADC void AdcIsr() { float xn = adc_.Read(); // Read from A0 myDac_.Write(xn); // to DAC } int main() { ScfClockTim3(420000); // cutoff frequency: 4.2 kHz adc_.SetIntrVec(AdcIsr); // Assign ISR for ADC interrupt while (true) {} }