CQpub0 Mikami / Mbed 2 deprecated ADC_DAC_Hello

Dependencies:   DSProcessingIO mbed

Fork of DAC_Test by CQpub0 Mikami

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main_ADDA.cpp Source File

main_ADDA.cpp

00001 //--------------------------------------------------------------
00002 //  Test program of DacDual class
00003 //
00004 //      Copyright (c) 2014 MIKAMI, Naoki, 2014/07/14
00005 //--------------------------------------------------------------
00006 
00007 #include "mbed.h"
00008 #include "AdcInternal.hpp"
00009 #include "MCP4922Dual.hpp"
00010 
00011 using namespace Mikami;
00012 
00013 const float FS_ = 10.0e3f;  // sampling frequency: 10 kHz
00014 
00015 Adc adc_;       // default, input: A0
00016 DacDual dacAB_; // object of DacDual class
00017 Ticker timer_;  // for timer interrupt
00018 
00019 // Called every 0.1 ms
00020 void TimerIsr()
00021 {
00022     float value = adc_.Read();  // AD
00023     
00024     // pin14 : Inphase 
00025     // pin10 : Out-of-phase
00026     dacAB_.Write(value, -value);
00027 }
00028 
00029 int main()
00030 {
00031     timer_.attach_us(&TimerIsr, 1.0e6f/FS_);
00032 
00033     while (true) {} // infinite loop
00034 }