![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Prototype program of AD and DA using classes in UIT_ADDA. This program does not use interrupt of ADC for ST Nucleo F401RE. UIT_ADDA のクラスを使った AD および DA のためのプログラムの雛形.ADC の割り込みは使わないバージョン.ST Nucleo F401 用.
Dependencies: UIT_ACM1602NI UIT_ADDA mbed
main.cpp@7:2b1c1c96e7f7, 2014-11-20 (annotated)
- Committer:
- MikamiUitOpen
- Date:
- Thu Nov 20 08:57:59 2014 +0000
- Revision:
- 7:2b1c1c96e7f7
- Parent:
- 4:9cace8ecbf02
- Child:
- 9:c3abdac6cb63
8
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
MikamiUitOpen | 0:fa5a90c45188 | 1 | //-------------------------------------------------------------- |
MikamiUitOpen | 0:fa5a90c45188 | 2 | // 割り込みを使わずに AD DA を行う場合の雛形 |
MikamiUitOpen | 0:fa5a90c45188 | 3 | // Analog Input : A0 |
MikamiUitOpen | 0:fa5a90c45188 | 4 | // Analog Output: MCP4922 using SPI |
MikamiUitOpen | 7:2b1c1c96e7f7 | 5 | // 2014/11/20, Copyright (c) 2014 MIKAMI, Naoki |
MikamiUitOpen | 0:fa5a90c45188 | 6 | //-------------------------------------------------------------- |
MikamiUitOpen | 0:fa5a90c45188 | 7 | |
MikamiUitOpen | 7:2b1c1c96e7f7 | 8 | #include "ADC_Base.hpp" // for ADC not using interrupt |
MikamiUitOpen | 0:fa5a90c45188 | 9 | #include "DAC_MCP4922.hpp" // for DAC MCP4922 |
MikamiUitOpen | 0:fa5a90c45188 | 10 | #include "ACM1602NI.hpp" // for LCD display |
MikamiUitOpen | 0:fa5a90c45188 | 11 | |
MikamiUitOpen | 0:fa5a90c45188 | 12 | using namespace Mikami; |
MikamiUitOpen | 0:fa5a90c45188 | 13 | |
MikamiUitOpen | 1:b4af5a0ad127 | 14 | const int FS_ = 10000; // Sampling frequency: 10 kHz |
MikamiUitOpen | 3:14136cf84042 | 15 | ADC_Base adc_(A0, FS_); // for AD |
MikamiUitOpen | 3:14136cf84042 | 16 | DAC_MCP4922 myDac_; // for DA |
MikamiUitOpen | 0:fa5a90c45188 | 17 | |
MikamiUitOpen | 0:fa5a90c45188 | 18 | int main() |
MikamiUitOpen | 0:fa5a90c45188 | 19 | { |
MikamiUitOpen | 4:9cace8ecbf02 | 20 | myDac_.ScfClockTim3(420000); // cutoff frequency: 4.2 kHz |
MikamiUitOpen | 0:fa5a90c45188 | 21 | |
MikamiUitOpen | 0:fa5a90c45188 | 22 | while (true) |
MikamiUitOpen | 0:fa5a90c45188 | 23 | { |
MikamiUitOpen | 0:fa5a90c45188 | 24 | float xn = adc_.Read(); // Read from A0 |
MikamiUitOpen | 0:fa5a90c45188 | 25 | //----------------------------------------------- |
MikamiUitOpen | 0:fa5a90c45188 | 26 | // Put signal processing program here |
MikamiUitOpen | 0:fa5a90c45188 | 27 | //----------------------------------------------- |
MikamiUitOpen | 0:fa5a90c45188 | 28 | myDac_.Write(xn); // Write to DAC |
MikamiUitOpen | 0:fa5a90c45188 | 29 | } |
MikamiUitOpen | 0:fa5a90c45188 | 30 | } |