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: main.cpp
- Revision:
- 1:9dcccb399f0b
- Parent:
- 0:6069c0f2a245
- Child:
- 3:f7923b9e8611
diff -r 6069c0f2a245 -r 9dcccb399f0b main.cpp
--- a/main.cpp Tue Nov 21 11:24:25 2017 +0000
+++ b/main.cpp Tue Nov 21 19:13:17 2017 +0000
@@ -5,13 +5,41 @@
AD9833 gen; // AD9833 object. Defaults to 25MHz internal reference frequency
AD9850 dds; // AD9850 object.
+DigitalOut GENLED(PC_7); //LED for AD9833 output
+DigitalOut DDSLED(PC_13); //LED for AD9850 output
+
double GENfreq = 10000; //frequency for the AD9833
-double DDSfreq = 10000000; //frequency for the AD9850
+double DDSfreq = 10000; //frequency for the AD9850
double DDStrimFreq = 124999500; //frequency used by AD9850 to calibrate
int DDSphase = 0; //phase for the AD9850
+Thread thread; //create thread to allow simultaneous LED blink and DDS output
+
+//AD9833 LED thread
+void GENBlinkThread() {
+ while (true) {
+ GENLED = !GENLED;
+ if(GENfreq != DDSfreq){
+ Thread::wait(1000/GENfreq);
+ }else{
+ Thread::wait(1500/GENfreq); //changed the thread wait time so that it will not equal the other thread
+ }
+ }
+}
+
+//AD9850 LED thread
+void DDSBlinkThread() {
+ while (true) {
+ DDSLED = !DDSLED;
+ Thread::wait(1000/DDSfreq);
+ }
+}
+
int main() {
-
+
+ thread.start(callback(GENBlinkThread));
+ thread.start(callback(DDSBlinkThread));
+
// Sequence to follow to generate waveform using AD9833
gen.Begin(); // The loaded defaults are 1000 Hz SINE_WAVE using REG0
// The output is OFF, Sleep mode is disabled
@@ -25,5 +53,6 @@
dds.Begin(); //begin generating for the AD9850
dds.CalibrateDDS(DDStrimFreq); //calibrate to match crystal oscillator
dds.SetDDSFrequency(DDSfreq, DDSphase);
+
+ while(1);
}
-