我尝试了基于 STM32F103C8T6 Bluepill 板的不带触摸屏的原始O-Scope 项目(PigOScope),但遇到了一些问题:
我使用了最新的rogerclarkmelbourne/Arduino_STM32 Core 并下载了
pingumacpenguin/STM32-O-Scope 草图。我通过UART从0x08000000地址编译并上传到设备。然后我启动了设备。网格和坐标线显示在屏幕上。屏幕上还显示了低于 0.0 uS/Sample 的铭文等……但是我的探针上来自 PB1 的任何噪声或脉冲信号。为什么不绘制图表?我还尝试在 DMA 激活码功能中记录我在 Usart 中的步骤:
void takeSamples()
{
// This loop uses dual interleaved mode to get the best performance out of
the ADCs
Serial.println("Init DMA");
dma_init(DMA1);
dma_attach_interrupt(DMA1, DMA_CH1, DMA1_CH1_Event);
Serial.println("Enable DMA for ADC");
adc_dma_enable(ADC1);
dma_setup_transfer(DMA1, DMA_CH1, &ADC1->regs->DR, DMA_SIZE_32BITS,
dataPoints32, DMA_SIZE_32BITS, (DMA_MINC_MODE |
DMA_TRNS_CMPLT));// Receive buffer
Serial.println("Set DMA transfer");
Serial.println(maxSamples / 2);
dma_set_num_transfers(DMA1, DMA_CH1, maxSamples / 2);
dma1_ch1_Active = 1;
Serial.println("Enable the channel and start the transfer");
dma_enable(DMA1, DMA_CH1); // Enable the channel and start the transfer.
samplingTime = micros();
Serial.println(samplingTime);
while (dma1_ch1_Active); // SOME BUG OR WHAT.... PROGRAM STOP HERE!!!
samplingTime = (micros() - samplingTime);
Serial.println("Disable DMA");
dma_disable(DMA1, DMA_CH1); //End of trasfer, disable DMA and Continuous
mode.
}
停止中断的事件处理程序
static void DMA1_CH1_Event()
{
dma1_ch1_Active = 0;
}
可变标志停止例行程序
volatile static bool dma1_ch1_Active = 0;
我认为程序一直在使用 while 循环......并且程序在 takeSamples() 函数之外无法工作。
为什么程序不退出循环?