//Enter a stop mode
//Request to enter STOP mode with regulator in low power mode, wake by any exit interrupt
IWDG_WriteAccessCmd(IWDG_WriteAccess_Enable);
IWDG_SetReload(0xffe);
IWDG_ReloadCounter();
谢谢你的回复,我试过了关闭中断还是不行。见鬼了,不知道哪里出问题了,看手册就要求三条(WFI (Wait for Interrupt) or WFE (Wait for Event) while:
– SLEEPDEEP = 0 and
– SLEEPONEXIT = 0
Refer to the Cortex-M4®F System Control register)
void DMA1_Channel1_IRQHandler(void)
{
float Voltage = 0; //电压变量
float Thermistor = 0; //热敏电阻阻值变量
int Temp = 0; //热敏电阻测出的温度变量
if(DMA_GetITStatus(DMA1_IT_TC1))
{
//电压采样处理
Voltage = g_ADCConvertedValue[2]*3.3/4096;
#if DEBUG
/*if(++g_Printf_Count > 300)
{
g_Printf_Count = 0;
printf("Voltage = %f\n", Voltage);
}*/
#endif
Voltage *= VOLTAGE_FACTOR;
Voltage += 0.35;
if(Voltage < voltage_sill) //电压值低于阀值
{
if(++g_VoltageLow_Count > 10 )
{
g_VoltageLow_Count = 0;
g_VoltageLow_Flag = 1; //设置电压过低的标志
g_VoltageLow_Flag_backup = 1; //设置电压过低标志的备份
}
g_VoltRecovery_Count = 0;
}
else if(Voltage > voltage_sill + 0.5)
{
if(g_VoltageLow_Flag_backup) //电压过低标志的备份置1表示电压曾经过低,现在表示电压恢复
{
if(++g_VoltRecovery_Count > 10 )
{
g_VoltRecovery_Count = 0;
g_VoltageLow_Flag_backup = 0;
g_VoltageLow_Flag = 2;
}
}
else
{
g_VoltRecovery_Count = 0;
}
g_VoltageLow_Count = 0;
}
else
{
g_VoltRecovery_Count = 0;
g_VoltageLow_Count = 0;
}
//热敏电阻采样处理,根据计算公式可得Rt = R1*U0/(2*U1-U0),
//或者Rt = R1*U0/(Vcc-U0)
if(2*g_ADCConvertedValue[1] > g_ADCConvertedValue[0])
{
Thermistor = (float)(10.0*g_ADCConvertedValue[0]/(2*g_ADCConvertedValue[1]-g_ADCConvertedValue[0]));
Temp = ThermalLookUp(Thermistor); //从热敏电阻阻值查表得到相应温度
if(Temp < HEAT_TEMPERATURE2) //低于二级温度阀值
{
if(++g_ThermalCount > 200) //当时间超过2秒时,应该设置加热标志
{
g_ThermalCount = 0;
g_ThermalHeat_Flag = 2;
}
}
else if(Temp < HEAT_TEMPERATURE1)
{
if(++g_ThermalCount > 200)
{
g_ThermalCount = 0;
g_ThermalHeat_Flag = 1;
}
}
else
{
g_ThermalCount = 0;
g_ThermalHeat_Flag = 0;
}
#if DEBUG
//if(++g_Printf_Count > 200)
//{
// g_Printf_Count = 0;
// printf("Vol0 = %f,Vol1 = %f\n",g_ADCConvertedValue[0]*3.3/4096,g_ADCConvertedValue[1]*3.3/4096);
// printf("Thermistor = %f\n", Thermistor);
// printf("Temperature = %d\n", Temp);
//}
#endif
}
else
{
g_ThermalCount = 0;
g_ThermalHeat_Flag = 0;
}
DMA_ClearITPendingBit(DMA1_IT_GL1);
}
}
#if DEBUG
printf("S M\n");
#endif
RTC_Configuration();
//PWR_BackupAccessCmd(ENABLE); //使能RTC和后备寄存器访问
//RTC_ITConfig(RTC_IT_ALR, ENABLE);
//RTC_WaitForLastTask();
//RTC_ClearFlag(RTC_FLAG_SEC);
//while (RTC_GetFlagStatus(RTC_FLAG_SEC) == RESET);
//RCC_ClearFlag();
//set the all GPIO as general GPIO 、remap IRDA in EXIT0 and disable TIM4 interrupt
lowLevelGPIOCfg();
ADC_Cmd(ADC1, DISABLE);
DMA_Cmd(DMA1_Channel1, DISABLE);
WireControl_EXTI_Enable();
GPIO_ResetBits(Led_Power, Led_Power_Pin);
//GPIO_SetBits(Led_Power, Led_Power_Pin);
BKP_WriteBackupRegister(BKP_DR3, 0xFFFF); //设置为睡眠状态
#if DEBUG
GPIO_SetBits(GPS_ON,GPS_ON_Pin);
#endif
//Enter a stop mode
//Request to enter STOP mode with regulator in low power mode, wake by any exit interrupt
IWDG_WriteAccessCmd(IWDG_WriteAccess_Enable);
IWDG_SetReload(0xffe);
IWDG_ReloadCounter();
GPIO_SetBits(LED_SD1_G, LED_SD1_G_Pin);
GPIO_SetBits(LED_SD2_G, LED_SD2_G_Pin);
GPIO_SetBits(LED_CAM1, LED_CAM1_Pin);
GPIO_SetBits(LED_CAM2, LED_CAM2_Pin);
mcu_iwdg_flag = 1;
delay_ms(RESET_INTERVAL);
EXTI_ClearITPendingBit(ACC_EXTI_Line | EXTI_Line0 | EXTI_Line17 | EXTI_Line11);
PWR_EnterSTOPMode(PWR_Regulator_LowPower,
PWR_STOPEntry_WFI);
GPIO_ResetBits(LED_SD1_G, LED_SD1_G_Pin);
GPIO_ResetBits(LED_SD2_G, LED_SD2_G_Pin);
GPIO_ResetBits(LED_CAM1, LED_CAM1_Pin);
这个是我进入睡眠的代码,
PWR_EnterSTOPMode(PWR_Regulator_LowPower, PWR_STOPEntry_WFI);
这里是进入睡眠的地方,睡眠需要注意的是,睡眠前清理一下中断悬挂
EXTI_ClearITPendingBit(ACC_EXTI_Line | EXTI_Li.....
,配置好外部中断。
如果睡眠之前有独立看门狗的话,需要另外的处理。
谢谢你的回复,我明白你的意思,但是我现在的问题是调用进入睡眠的库函数就是进不到睡眠,请问你的主程序中进入睡眠是怎么进去的吗?我的进入睡眠的代码如下:
RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR, ENABLE);
PWR_DeInit();
PWR_BackupAccessCmd(DISABLE);
SCB->SCR &= 0xFFFFFFF0;
// SCB->SCR &= ~((uint32_t)SCB_SCR_SLEEPDEEP_Msk);
NVIC_SystemLPConfig(NVIC_LP_SLEEPDEEP,DISABLE);
NVIC_SystemLPConfig(NVIC_LP_SLEEPONEXIT,DISABLE);
PWR_EnterSleepMode(PWR_SLEEPEntry_WFE);
// __WFE;
不知道那里出问题了,就是进不了睡眠。求帮忙指点,谢谢!
我先看看,又不明白的再请教你,谢谢你了!
你的这个里面没有写怎么进入睡眠,还有进入之后怎么唤醒?在DMA中断中检测电压低于阈值多长时间置标志位,高于设定阈值请标志位,但始终没有写怎么进入睡眠。
你这个不是进入stop mode的?我想做的是进入sleep mode 的。还有你这个是在stm32f302上实现的吗?
我用的是 stm32rbt6
我想,stopmode 和你那个sleep mode实现上 应该差不多吧。
你就做个简单的小程序,仅仅做个sleep mode 的功能看能不能实现。
谢谢你的回复,我试过了关闭中断还是不行。见鬼了,不知道哪里出问题了,看手册就要求三条(WFI (Wait for Interrupt) or WFE (Wait for Event) while:
– SLEEPDEEP = 0 and
– SLEEPONEXIT = 0
Refer to the Cortex-M4®F System Control register)
楼主是否在线调试模式下测试?
PWR_CurrentConsumption.rar
2015-8-25 11:16 上传
点击文件名下载附件
下载积分: ST金币 -13.63 KB, 下载次数: 4, 下载积分: ST金币 -1