AD靠外部定时器T2CC2触发 ,触发扫描8通道,DMA传输,传输完成进中断,DMA中断里有个IO电平翻转,为什么我改变sampletime后 示波器看TIM2-CH2和IO电平翻转的波形 2个时间差没变 (示波器是单触)
AD频率 9M
部分代码:
TIM2:
TIM_SelectSlaveMode(TIM2, TIM_SlaveMode_Gated ); //TIM2-ch2 波,上升沿触发AD采样
TIM_SelectInputTrigger(TIM2, TIM_TS_ITR2);
TIM_SelectOutputTrigger(TIM2, TIM_TRGOSource_Update );
TIM_TimeBaseStructure.TIM_Period =7;
TIM_TimeBaseStructure.TIM_Prescaler = 1;
TIM_TimeBaseStructure.TIM_ClockDivision = 0;
TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
TIM_TimeBaseInit(TIM2, &TIM_TimeBaseStructure);
TIM_OCInitStructure.TIM_OCMode = TIM_OCMode_PWM1;
TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable;
TIM_OCInitStructure.TIM_Pulse = 5;
TIM_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_Low;
TIM_CtrlPWMOutputs(TIM2, ENABLE);//DISABLE//ENABLE
TIM_OC2Init(TIM2, &TIM_OCInitStructure);
ADC:
ADC_InitStructure.ADC_Mode = ADC_Mode_Independent;
ADC_InitStructure.ADC_ScanConvMode = ENABLE;
ADC_InitStructure.ADC_ContinuousConvMode = DISABLE;
ADC_InitStructure.ADC_ExternalTrigConv = ADC_ExternalTrigConv_T2_CC2;
ADC_InitStructure.ADC_DataAlign = ADC_DataAlign_Right;
ADC_InitStructure.ADC_NbrOfChannel = 8;
ADC_Init(ADC1, &ADC_InitStructure);
ADC_RegularChannelConfig(ADC1, PIN_0, 1, ADC_SampleTime_71Cycles5);
ADC_RegularChannelConfig(ADC1, PIN_0, 2, ADC_SampleTime_71Cycles5);
ADC_RegularChannelConfig(ADC1, PIN_0, 3, ADC_SampleTime_71Cycles5);
ADC_RegularChannelConfig(ADC1, PIN_0, 4, ADC_SampleTime_71Cycles5);
ADC_RegularChannelConfig(ADC1, PIN_0, 5, ADC_SampleTime_71Cycles5);
ADC_RegularChannelConfig(ADC1, PIN_0, 6, ADC_SampleTime_71Cycles5);
ADC_RegularChannelConfig(ADC1, PIN_0, 7, ADC_SampleTime_71Cycles5);
ADC_RegularChannelConfig(ADC1, PIN_0, 8, ADC_SampleTime_71Cycles5);
ADC_DMACmd(ADC1, ENABLE); ADC_Cmd(ADC1, ENABLE);
ADC_ResetCalibration(ADC1);
while(ADC_GetResetCalibrationStatus(ADC1));
ADC_StartCalibration(ADC1);
while(ADC_GetCalibrationStatus(ADC1));
ADC_ExternalTrigConvCmd(ADC1,ENABLE);
|
|