打印
[STM32F1]

[求解]新人求问 ADC Sampletime相关

[复制链接]
2089|1
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
zhiqun112|  楼主 | 2014-4-2 10:38 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
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);


沙发
zhiqun112|  楼主 | 2014-4-2 11:35 | 只看该作者
还有个问题,ADC sampletime 采样时间有1.5-239.5 比如我有个需采样信号在7.5这个时间内就能完全采样结束,在这种情况下 如果设置采样时间为239.5的话 它实际采样时间是7.5 还是 239.5?

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

1

主题

9

帖子

1

粉丝