Ultrasonic Audio File Player

Dependencies:   mbed

Fork of TAU_ZOOLOG_Chirp_Generator by Yossi_Students

Revision:
23:6dbd2d20697c
Parent:
21:7aa784deffc8
Child:
25:060831b7aadd
--- a/main.cpp	Sun Apr 15 12:19:19 2018 +0000
+++ b/main.cpp	Wed Apr 25 08:51:50 2018 +0000
@@ -1,6 +1,6 @@
 /*
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% Generate Chirp Signal - 27/03/2018                %
+% Generate WAVE Signal - 25/04/2018                %
 % Arkadi Rafalovich - % Arkadiraf@gmail.com         %
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 % Updates:
@@ -10,13 +10,15 @@
 
 I/O -- PA_5 -- D13 (Status LED, Condition)
 I/O -- PA_6 -- D12 (Toggle Pin, Loop Freq)
+Analog PA_0 -- A0  (Potentiometer)
 
 */
 #include "mbed.h"
-#include "chirp.h"
-#define PULSE_RATE 20.0f // in HZ
+#include "signal.h"
+#define PULSE_RATE 2.0f // in HZ
 #define FREQ_POT_EN // Potentiometer to set PULSE Rate
-#define MIN_FREQ 0.5f //(HZ)
+#define MIN_FREQ 0.1f //(HZ)
+#define SAMPLE_RATE_375_KHZ // basic sample rate is 1Mhz, this mode adds delay in between sample to meet the audio sample rate
 
 float pulseRate=PULSE_RATE;
 // Serial over USB as input device
@@ -92,6 +94,19 @@
                 NOP();
                 NOP();
                 NOP();
+                
+                #ifdef SAMPLE_RATE_375_KHZ
+                // generate delay
+                for (int jj=0; jj<69; jj++) {
+                    NOP();
+                }
+                // micro nops :)
+                NOP();
+                NOP();
+                NOP();
+                //NOP();
+                //NOP();
+                #endif
                 // Output value using DAC
                 // HAL_DAC_SetValue(&hdac1, DAC_CHANNEL_1, DAC_ALIGN_12B_R, ADCValueOut);
                 *(__IO uint32_t *) Dac_Reg = chirpData[ii];