
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA | RCC_AHBPeriph_GPIOC | RCC_AHBPeriph_GPIOF, ENABLE); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_2 | GPIO_Pin_3 | GPIO_Pin_4 | GPIO_Pin_5 | GPIO_Pin_6 | GPIO_Pin_7 ; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AN; GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL ; GPIO_Init(GPIOA, &GPIO_InitStructure); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_2 | GPIO_Pin_3 | GPIO_Pin_4; GPIO_Init(GPIOC, &GPIO_InitStructure); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2 | GPIO_Pin_4; GPIO_Init(GPIOF, &GPIO_InitStructure); //ADC Init RCC_ADCCLKConfig(RCC_ADC12PLLCLK_Div1); RCC_AHBPeriphClockCmd(RCC_AHBPeriph_ADC12, ENABLE); ADC_StructInit(&ADC_InitStructure); /* Calibration procedure */ ADC_VoltageRegulatorCmd(ADC1, ENABLE); ADC_VoltageRegulatorCmd(ADC2, ENABLE); vTaskDelay(10); ADC_SelectCalibrationMode(ADC1, ADC_CalibrationMode_Differential); ADC_StartCalibration(ADC1); ADC_SelectCalibrationMode(ADC2, ADC_CalibrationMode_Differential); ADC_StartCalibration(ADC2); while(ADC_GetCalibrationStatus(ADC1) != RESET ); calibration_value1 = ADC_GetCalibrationValue(ADC1); while(ADC_GetCalibrationStatus(ADC2) != RESET ); calibration_value2 = ADC_GetCalibrationValue(ADC2); /* ADC Dual mode configuration */ ADC_CommonInitStructure.ADC_Mode = ADC_Mode_RegSimul; ADC_CommonInitStructure.ADC_Clock = ADC_Clock_AsynClkMode; ADC_CommonInitStructure.ADC_DMAAccessMode = ADC_DMAAccessMode_1; ADC_CommonInitStructure.ADC_DMAMode = ADC_DMAMode_Circular; ADC_CommonInitStructure.ADC_TwoSamplingDelay = 10; ADC_CommonInit(ADC1, &ADC_CommonInitStructure); /* */ ADC_InitStructure.ADC_ContinuousConvMode = ADC_ContinuousConvMode_Disable;//ADC_ContinuousConvMode_Enable; ADC_InitStructure.ADC_Resolution = ADC_Resolution_12b; ADC_InitStructure.ADC_ExternalTrigConvEvent = ADC_ExternalTrigConvEvent_5;//Event5 = TIM4_CC4 event Event12 = TIM4_TROG event ADC_InitStructure.ADC_ExternalTrigEventEdge = ADC_ExternalTrigEventEdge_RisingEdge; ADC_InitStructure.ADC_DataAlign = ADC_DataAlign_Right; ADC_InitStructure.ADC_OverrunMode = ADC_OverrunMode_Disable; ADC_InitStructure.ADC_AutoInjMode = ADC_AutoInjec_Disable; ADC_InitStructure.ADC_NbrOfRegChannel = 4; ADC_Init(ADC1, &ADC_InitStructure); ADC_InitStructure.ADC_ExternalTrigEventEdge = ADC_ExternalTrigEventEdge_None; ADC_Init(ADC2, &ADC_InitStructure); /* ADC1 regular channel7 and channel8 configuration */ ADC_RegularChannelConfig(ADC1, ADC_Channel_1, 1, ADC_SampleTime_61Cycles5); ADC_RegularChannelConfig(ADC1, ADC_Channel_2, 2, ADC_SampleTime_61Cycles5); ADC_RegularChannelConfig(ADC1, ADC_Channel_3, 3, ADC_SampleTime_61Cycles5); ADC_RegularChannelConfig(ADC1, ADC_Channel_4, 4, ADC_SampleTime_61Cycles5); ADC_RegularChannelConfig(ADC1, ADC_Channel_5, 5, ADC_SampleTime_61Cycles5); ADC_RegularChannelConfig(ADC1, ADC_Channel_6, 6, ADC_SampleTime_61Cycles5);//与ADC2共用CH6,错时使用 ADC_RegularChannelConfig(ADC1, ADC_Channel_7, 7, ADC_SampleTime_61Cycles5); ADC_RegularChannelConfig(ADC1, ADC_Channel_8, 8, ADC_SampleTime_61Cycles5); ADC_RegularChannelConfig(ADC2, ADC_Channel_1, 1, ADC_SampleTime_61Cycles5); ADC_RegularChannelConfig(ADC2, ADC_Channel_2, 2, ADC_SampleTime_61Cycles5); ADC_RegularChannelConfig(ADC2, ADC_Channel_3, 3, ADC_SampleTime_61Cycles5); ADC_RegularChannelConfig(ADC2, ADC_Channel_4, 4, ADC_SampleTime_61Cycles5); ADC_RegularChannelConfig(ADC2, ADC_Channel_9, 5, ADC_SampleTime_61Cycles5); ADC_RegularChannelConfig(ADC2, ADC_Channel_10, 6, ADC_SampleTime_61Cycles5); ADC_RegularChannelConfig(ADC2, ADC_Channel_5, 7, ADC_SampleTime_61Cycles5); ADC_RegularChannelConfig(ADC2, ADC_Channel_6, 8, ADC_SampleTime_61Cycles5);//与ADC1共用CH6,错时使用 ADC_SelectDifferentialMode(ADC1, ADC_Channel_1, ENABLE); //差分通道 ADC_SelectDifferentialMode(ADC1, ADC_Channel_3, ENABLE); ADC_SelectDifferentialMode(ADC1, ADC_Channel_5, ENABLE); ADC_SelectDifferentialMode(ADC1, ADC_Channel_7, ENABLE); ADC_SelectDifferentialMode(ADC2, ADC_Channel_1, ENABLE); //差分通道 ADC_SelectDifferentialMode(ADC2, ADC_Channel_3, ENABLE); ADC_SelectDifferentialMode(ADC2, ADC_Channel_9, ENABLE); ADC_SelectDifferentialMode(ADC2, ADC_Channel_5, ENABLE); /* Configures the ADC DMA */ ADC_DMAConfig(ADC1, ADC_DMAMode_Circular); /* Enable the ADC DMA */ ADC_DMACmd(ADC1, ENABLE); /* Enable ADC1 and ADC2 */ ADC_Cmd(ADC1, ENABLE); ADC_Cmd(ADC2, ENABLE); /* wait for ADC1 ADRDY */ while(!ADC_GetFlagStatus(ADC1, ADC_FLAG_RDY)); /* wait for ADC2 ADRDY */ while(!ADC_GetFlagStatus(ADC2, ADC_FLAG_RDY)); vTaskDelay(10); //DMA Init RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA1, ENABLE); DMA_InitStructure.DMA_PeripheralBaseAddr = ADC_CDR_ADDRESS; DMA_InitStructure.DMA_MemoryBaseAddr = (uint32_t)&ADCDualConvertedValue; DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralSRC; DMA_InitStructure.DMA_BufferSize = 300*4; DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable; DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable; DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Word; DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_Word; DMA_InitStructure.DMA_Mode = DMA_Mode_Circular; DMA_InitStructure.DMA_Priority = DMA_Priority_Medium; DMA_InitStructure.DMA_M2M = DMA_M2M_Disable; DMA_Init(DMA1_Channel1, &DMA_InitStructure); NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1); NVIC_InitStructure.NVIC_IRQChannel = DMA1_Channel1_IRQn; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0x0; NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0x0; NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_Init(&NVIC_InitStructure); DMA_ITConfig(DMA1_Channel1, DMA_IT_TC, ENABLE); DMA_Cmd(DMA1_Channel1, ENABLE); //TIM4 Init RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM4, ENABLE); /* TIM4 configuration ------------------------------------------------------*/ /* Time Base configuration */ TIM_TimeBaseStructInit(&TIM_TimeBaseStructure); TIM_TimeBaseStructure.TIM_Period = 24000-1; //72M/3K = 24K TIM_TimeBaseStructure.TIM_Prescaler = 0; TIM_TimeBaseStructure.TIM_ClockDivision = 0x0; TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up; TIM_TimeBaseInit(TIM4, &TIM_TimeBaseStructure); /* TIM4 channel1 configuration in PWM mode */ TIM_OCInitStructure.TIM_OCMode = TIM_OCMode_PWM2; TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable; TIM_OCInitStructure.TIM_OutputNState = TIM_OutputNState_Disable; TIM_OCInitStructure.TIM_Pulse = 0x0FFF; TIM_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_Low; TIM_OCInitStructure.TIM_OCNPolarity = TIM_OCNPolarity_High; TIM_OCInitStructure.TIM_OCIdleState = TIM_OCIdleState_Set; TIM_OCInitStructure.TIM_OCNIdleState = TIM_OCIdleState_Reset; TIM_OC4Init(TIM4, &TIM_OCInitStructure); TIM_SelectOutputTrigger(TIM4, TIM_TRGOSource_OC4Ref); /* TIM4 counter enable */ TIM_Cmd(TIM4, ENABLE); /* TIM4 main Output Enable */ TIM_CtrlPWMOutputs(TIM4, ENABLE); ADC_StartConversion(ADC1); 采集直流数据,采集变化非常大。采集值有100左右的变化。 另外,如果不添加 ADC_StartConversion(ADC1);,采集是不会开始的,不知道哪里没有配置好。 |
hrtim里update reset和reset update同时打开不会互相激励吗,另外为什么现在定时器周期值不用-1了
hrtim 下Single-shot Non-retriggerable模式 reset信号到来时Repetition counter会减少吗,手册没说这一点
F334 hrtim pwm输出没有单独的预装载影子寄存器控制位吗
STM32F373 SDAC1+DMA,数据只能更新一次?
STM32F373的VDDSD电压一直处于2.5v左右,其他电压正常,附上原理图,求指导
stm32的同一个定时器,不同的通道,可以不同时的输出pwm波形吗
STM32F334如何配置PB1输出HRTIM同步信号
STM32的上电启动过程
STM32中如何实现数据加密
STM32的I2S外设
我的目标是可以不准,毕竟可以校准的。但不能跳动,要稳。
可以先接个标准的稳定信号先测试下,比如接电池
是的,我的信号是电池。
单通道采集同样的情况,能过确认的是外部电压是稳定的,没有变化。