Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: FreqConv.cpp
- Revision:
- 0:f69d3c64978d
- Child:
- 1:d8449dbcde02
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/FreqConv.cpp Mon Jul 28 07:30:22 2014 +0000
@@ -0,0 +1,38 @@
+//--------------------------------------------------------------
+// Frequency converter for Open Campus
+// Copyright (c) 2014 MIKAMI, Naoki, 2014/06/23
+//--------------------------------------------------------------
+
+#include "mbed.h"
+#include "AdcInternal.hpp"
+#include "MCP4921.hpp"
+#include "FrequencyConverter.hpp"
+
+using namespace Mikami;
+
+const float FS_ = 10.0e3f;
+Adc adc_(A0);
+DacMCP4921 dac_;
+
+Ticker timer_; // for timer interrupt
+
+//**********************************************//
+// Change parameters, "100.0f", ex. "-100.0f"
+FrqConvSystem myFrqConv_(100.0f, FS_);
+//**********************************************//
+
+void TimerIsr()
+{
+// float yI, yQ, cosx, sinx;
+
+ float xn = adc_.Read(); // input
+ float yn = myFrqConv_.Execute(xn);
+ dac_.Write(yn); // output
+}
+
+int main()
+{
+ timer_.attach_us(&TimerIsr, 1.0e6f/FS_);
+ while (true) {} // infinite loop
+}
+