]> code.bitgloo.com Git - clyne/stmdsp.git/commitdiff
stable signal handling towards 100kHz
authorClyne Sullivan <clyne@bitgloo.com>
Wed, 26 Aug 2020 01:01:08 +0000 (21:01 -0400)
committerClyne Sullivan <clyne@bitgloo.com>
Wed, 26 Aug 2020 01:01:08 +0000 (21:01 -0400)
gui/wxmain.hpp
source/adc.cpp
source/dac.cpp

index 05faf70533e75781b0f0118523edd9c90675b339..d694734d927bf80a0c5b381cc5b788716e25712e 100644 (file)
@@ -100,7 +100,8 @@ public:
         auto button = dynamic_cast<wxButton *>(ce.GetEventObject());
 
         if (!m_render_timer->IsRunning()) {
-            m_device = new stmdsp::device(m_device_combo->GetStringSelection().ToStdString());
+            if (m_device == nullptr)
+                m_device = new stmdsp::device(m_device_combo->GetStringSelection().ToStdString());
             if (m_device->connected()) {
                 m_device->continuous_start();
                 m_device_samples_future = std::async(std::launch::async,
@@ -116,8 +117,8 @@ public:
             m_device->continuous_stop();
             button->SetLabel("Single");
 
-            delete m_device;
-            m_device = nullptr;
+            //delete m_device;
+            //m_device = nullptr;
         }
     }
 
@@ -129,10 +130,11 @@ public:
             if (wxFileInputStream file_stream (/*dialog.GetPath()*/file); file_stream.IsOk()) {
                 auto size = file_stream.GetSize();
                 auto buffer = new unsigned char[size];
-                auto device = new stmdsp::device(m_device_combo->GetStringSelection().ToStdString());
-                if (device->connected()) {
+                if (m_device == nullptr)
+                    m_device = new stmdsp::device(m_device_combo->GetStringSelection().ToStdString());
+                if (m_device->connected()) {
                     file_stream.ReadAll(buffer, size);
-                    device->upload_filter(buffer, size);
+                    m_device->upload_filter(buffer, size);
                 }
             }
         }
index 1f65e685ee55095449be8e7dc4908d9a8296236b..c912a7e21915b0320139fb69b4c7f00617a92cdc 100644 (file)
@@ -29,7 +29,7 @@ static void adc_read_callback(ADCDriver *);
     .cfgr2 = 0,
     .tr1 = ADC_TR(0, 4095),
     .smpr = {
-        ADC_SMPR1_SMP_AN5(ADC_SMPR_SMP_247P5), 0
+        ADC_SMPR1_SMP_AN5(ADC_SMPR_SMP_2P5), 0
     },
     .sqr = {
         ADC_SQR1_SQ1_N(ADC_CHANNEL_IN5),
@@ -38,7 +38,7 @@ static void adc_read_callback(ADCDriver *);
 };
 
 constexpr static const GPTConfig gpt_config = {
-    .frequency = 1000000,
+    .frequency = 4000000,
     .callback = nullptr,
     .cr2 = TIM_CR2_MMS_1, /* TRGO */
     .dier = 0
@@ -65,7 +65,7 @@ namespace adc
         adc_is_read_finished = false;
         adc_group_config.circular = false;
         adcStartConversion(adcd, &adc_group_config, buffer, count);
-        gptStartContinuous(gptd, 100); // 10kHz
+        gptStartContinuous(gptd, 2);
         while (!adc_is_read_finished);
         return buffer;
     }
@@ -77,7 +77,7 @@ namespace adc
         adc_operation_func = operation_func;
         adc_group_config.circular = true;
         adcStartConversion(adcd, &adc_group_config, buffer, count);
-        gptStartContinuous(gptd, 100); // 10kHz
+        gptStartContinuous(gptd, 2);
     }
     
     void read_stop()
index 644689e87c5db335197ade99806fe043f8bee275..6d5950e20a948d8515d986ef456cdb42e0596f70 100644 (file)
@@ -28,7 +28,7 @@ constexpr static const DACConversionGroup dac_group_config = {
 };
 
 constexpr static const GPTConfig gpt_config = {
-  .frequency = 1000000,
+  .frequency = 4000000,
   .callback = nullptr,
   .cr2 = TIM_CR2_MMS_1, /* TRGO */
   .dier = 0
@@ -48,7 +48,7 @@ namespace dac
     void write_start(dacsample_t *buffer, size_t count)
     {
         dacStartConversion(dacd, &dac_group_config, buffer, count);
-        gptStartContinuous(gptd, 100);
+        gptStartContinuous(gptd, 2);
     }
     
     void write_stop()