Sampling rate done. 96kS/s

pull/3/head
Clyne 4 years ago
parent 27060ea3c8
commit 829c4b5dcb

@ -556,7 +556,7 @@
* @note The default is @p FALSE.
*/
#if !defined(CH_DBG_ENABLE_ASSERTS)
#define CH_DBG_ENABLE_ASSERTS FALSE
#define CH_DBG_ENABLE_ASSERTS TRUE
#endif
/**

@ -42,17 +42,17 @@
#define STM32_VOS STM32_VOS_RANGE1
#define STM32_PVD_ENABLE FALSE
#define STM32_PLS STM32_PLS_LEV0
#define STM32_HSI16_ENABLED TRUE
#define STM32_HSI16_ENABLED FALSE
#define STM32_LSI_ENABLED TRUE
#define STM32_HSE_ENABLED FALSE
#define STM32_LSE_ENABLED TRUE
#define STM32_MSIPLL_ENABLED TRUE
#define STM32_MSIRANGE STM32_MSIRANGE_48M
#define STM32_LSE_ENABLED FALSE
#define STM32_MSIPLL_ENABLED FALSE
#define STM32_MSIRANGE STM32_MSIRANGE_8M
#define STM32_MSISRANGE STM32_MSISRANGE_4M
#define STM32_SW STM32_SW_PLL
#define STM32_PLLSRC STM32_PLLSRC_HSI16
#define STM32_PLLM_VALUE 4
#define STM32_PLLN_VALUE 80
#define STM32_PLLSRC STM32_PLLSRC_MSI
#define STM32_PLLM_VALUE 2
#define STM32_PLLN_VALUE 72
#define STM32_PLLP_VALUE 7
#define STM32_PLLQ_VALUE 6
#define STM32_PLLR_VALUE 4
@ -63,13 +63,13 @@
#define STM32_MCOSEL STM32_MCOSEL_NOCLOCK
#define STM32_MCOPRE STM32_MCOPRE_DIV1
#define STM32_LSCOSEL STM32_LSCOSEL_NOCLOCK
#define STM32_PLLSAI1N_VALUE 44
#define STM32_PLLSAI1N_VALUE 24
#define STM32_PLLSAI1P_VALUE 7
#define STM32_PLLSAI1Q_VALUE 6
#define STM32_PLLSAI1R_VALUE 8
#define STM32_PLLSAI2N_VALUE 72
#define STM32_PLLSAI1Q_VALUE 2
#define STM32_PLLSAI1R_VALUE 4
#define STM32_PLLSAI2N_VALUE 24
#define STM32_PLLSAI2P_VALUE 7
#define STM32_PLLSAI2R_VALUE 6
#define STM32_PLLSAI2R_VALUE 2
/*
* Peripherals clock sources.
@ -87,7 +87,7 @@
#define STM32_LPTIM2SEL STM32_LPTIM2SEL_PCLK1
#define STM32_SAI1SEL STM32_SAI1SEL_OFF
#define STM32_SAI2SEL STM32_SAI2SEL_OFF
#define STM32_CLK48SEL STM32_CLK48SEL_MSI
#define STM32_CLK48SEL STM32_CLK48SEL_PLLSAI1
#define STM32_ADCSEL STM32_ADCSEL_PLLSAI1
#define STM32_SWPMI1SEL STM32_SWPMI1SEL_PCLK1
#define STM32_DFSDMSEL STM32_DFSDMSEL_PCLK2

@ -138,6 +138,7 @@ static wxString file_header (R"cpp(
#include <cstdint>
using adcsample_t = uint16_t;
constexpr unsigned int SIZE = 4000;
adcsample_t *process_data(adcsample_t *samples, unsigned int size);

@ -38,7 +38,7 @@ static ADCConversionGroup adc_group_config = {
};
constexpr static const GPTConfig gpt_config = {
.frequency = 8000000,
.frequency = 2400000,
.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, 2);
gptStartContinuous(gptd, 25);
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, 2);
gptStartContinuous(gptd, 25);
}
void read_set_operation_func(operation_t operation_func)
@ -113,7 +113,7 @@ namespace adc
val = ADC_SMPR1_SMP_AN5(ADC_SMPR_SMP_24P5);
break;
case rate::R47P5:
val = ADC_SMPR1_SMP_AN5(ADC_SMPR_SMP_47P5);////
val = ADC_SMPR1_SMP_AN5(ADC_SMPR_SMP_47P5);
break;
case rate::R92P5:
val = ADC_SMPR1_SMP_AN5(ADC_SMPR_SMP_92P5);

@ -28,7 +28,7 @@ constexpr static const DACConversionGroup dac_group_config = {
};
constexpr static const GPTConfig gpt_config = {
.frequency = 440000,
.frequency = 2400000,
.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, 5);
gptStartContinuous(gptd, 25);
}
void write_stop()

@ -19,7 +19,7 @@
#include <array>
constexpr unsigned int MAX_SAMPLE_BUFFER_SIZE = 8000;//2048;
constexpr unsigned int MAX_SAMPLE_BUFFER_SIZE = 8000;
enum class RunStatus : char
{
@ -240,25 +240,25 @@ THD_FUNCTION(conversionThread, arg)
std::copy(samples, samples + halfsize, &dac_samples[0]);
} else if (message == MSG_CONVSECOND) {
if (elf_entry)
samples = elf_entry(&adc_samples[adc_samples.size() / 2], halfsize);
samples = elf_entry(&adc_samples[halfsize], halfsize);
if (!samples)
samples = &adc_samples[adc_samples.size() / 2];
samples = &adc_samples[halfsize];
std::copy(samples, samples + halfsize, &dac_samples[dac_samples.size() / 2]);
} else if (message == MSG_CONVFIRST_MEASURE) {
chTMStartMeasurementX(&conversion_time_measurement);
if (elf_entry)
samples = elf_entry(&adc_samples[adc_samples.size() / 2], halfsize);
samples = elf_entry(&adc_samples[0], halfsize);
chTMStopMeasurementX(&conversion_time_measurement);
if (!samples)
samples = &adc_samples[adc_samples.size() / 2];
std::copy(samples, samples + halfsize, &dac_samples[dac_samples.size() / 2]);
samples = &adc_samples[0];
std::copy(samples, samples + halfsize, &dac_samples[0]);
} else if (message == MSG_CONVSECOND_MEASURE) {
chTMStartMeasurementX(&conversion_time_measurement);
if (elf_entry)
samples = elf_entry(&adc_samples[adc_samples.size() / 2], halfsize);
samples = elf_entry(&adc_samples[halfsize], halfsize);
chTMStopMeasurementX(&conversion_time_measurement);
if (!samples)
samples = &adc_samples[adc_samples.size() / 2];
samples = &adc_samples[halfsize];
std::copy(samples, samples + halfsize, &dac_samples[dac_samples.size() / 2]);
}
}

Loading…
Cancel
Save