STM32F103RC示波器&&

2019-10-14 21:02发布

本帖最后由 STM129 于 2017-3-5 00:57 编辑

STM32F103RC示波器&& STM32F103C8T6
做个示波器试验,程序是东拼西凑来的,现在也只显示了个筐图

在拼凑来的程序中有个变量不会改,改过几次都不行:volatile u16 ADCConvertedValue[SAMPDEPTH];//AD转换缓冲区。
这个数组块想改成两个块来循环采集数据,以便检测信号的跳变触动,若按照示波器的方法就会漏检

/* 示波器的AD采集 */
#include "Oscilloscope.h"
#include "stm32f10x.h"
#include "lcd.h"
volatile u16 ADCConvertedValue[SAMPDEPTH];//AD转换缓冲区
/*-----------------------------------------



void ADC1_Mode_Config(void)
{
//配置DMA
DMA_InitTypeDef DMA_csh;
ADC_InitTypeDef ADC_csh;
TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure;
NVIC_InitTypeDef NVIC_InitStructure;
DMA_DeInit(DMA1_Channel1);          //DMA复位,通道1
DMA_csh.DMA_PeripheralBaseAddr = ADC1_DR_Address;  //ADC1地址
DMA_csh.DMA_MemoryBaseAddr = (unsigned int)ADCConvertedValue;  //内存地址
DMA_csh.DMA_DIR = DMA_DIR_PeripheralSRC;  
DMA_csh.DMA_BufferSize = SAMPDEPTH;         //缓冲大小为采样深度
DMA_csh.DMA_PeripheralInc = DMA_PeripheralInc_Disable;  //外设地址固定
DMA_csh.DMA_MemoryInc = DMA_MemoryInc_Enable;    //内存地址自增
DMA_csh.DMA_PeripheralDataSize = DMA_PeripheralDataSize_HalfWord;  
DMA_csh.DMA_MemoryDataSize = DMA_MemoryDataSize_HalfWord;
DMA_csh.DMA_Mode = DMA_Mode_Circular;       //循环传输
DMA_csh.DMA_Priority = DMA_Priority_High;      //DMA优先级高
DMA_csh.DMA_M2M = DMA_M2M_Disable;
DMA_Init(DMA1_Channel1,&DMA_csh);        //写入DMA1配置参数
DMA_Cmd(DMA1_Channel1,ENABLE);          //使能DMA1通道1
DMA_ITConfig(DMA1_Channel1,DMA_IT_TC,ENABLE);   //使能DMA CH1中断
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1);
NVIC_InitStructure.NVIC_IRQChannel = DMA1_Channel1_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);


------------------------------------------*/
void DMA1_Channel1_IRQHandler()
{

    DMA_ClearFlag(DMA1_FLAG_TC1); //清除DMA传输完成中断
   TIM_Cmd(TIM3,DISABLE);  //关闭TIM3
}
附程序


友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。