本帖最后由 三石田叶子青青 于 2019-1-14 17:12 编辑
stm32f103zet6 RTC能从待机模式唤醒 不能从停止模式唤醒?
代码:
int main(void)
{
/* USER CODE BEGIN 1 */
/* USER CODE END 1 */
/* MCU Configuration--------------------------------------------------------*/
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();
/* USER CODE BEGIN Init */
/* USER CODE END Init */
/* Configure the system clock */
SystemClock_Config();
/* USER CODE BEGIN SysInit */
RtcClock_Config();
MY_RTC_Init();
/* USER CODE END SysInit */
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_USART1_UART_Init();
/* USER CODE BEGIN 2 */
RTC_Alarm_Set(2019,1,14,16,55,00);
RTC_Alarm_IT_Enable(&hrtc);
printf("Start!
");
/* USER CODE END 2 */
/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1)
{
HAL_Delay(500);
HAL_GPIO_TogglePin(LED_GPIO_Port, LED_Pin); //灭
HAL_Delay(500);
HAL_GPIO_TogglePin(LED_GPIO_Port, LED_Pin); //亮
HAL_Delay(500);
HAL_GPIO_TogglePin(LED_GPIO_Port, LED_Pin); //灭
HAL_Delay(500);
HAL_GPIO_TogglePin(LED_GPIO_Port, LED_Pin); //亮
HAL_Delay(500);
//SleepMode();
StopMode_IT();
//StandbyMode();
RTC_Alarm_IT_Enable(&hrtc);
/* 检测系统是否是从待机模式启动的 */
if (__HAL_PWR_GET_FLAG(PWR_FLAG_SB) != RESET)
{
printf("待机唤醒复位
");
/* 清除待机标志位 */
__HAL_PWR_CLEAR_FLAG(PWR_FLAG_SB);
}
else
{
printf("系统是上电启动
");
}
RTC_Get();
printf("%2d年%2d月%2d日 ------ ", calendar.w_year, calendar.w_month, calendar.w_date);
printf("%2d点%2d分%2d秒 ------ ", calendar.hour, calendar.min, calendar.sec);
printf("星期%d
", calendar.week);
//StandbyMode();
// HAL_GPIO_TogglePin(SIGNAL_GPIO_Port, SIGNAL_Pin);
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
}
/* USER CODE END 3 */
}
HAL_StatusTypeDef RTC_Alarm_IT_Enable(RTC_HandleTypeDef *hrtc)
{
/* Process Locked */
__HAL_LOCK(hrtc);
hrtc->State = HAL_RTC_STATE_BUSY;
__HAL_RTC_ALARM_EXTI_CLEAR_FLAG();
/* Clear flag alarm A */
__HAL_RTC_ALARM_CLEAR_FLAG(hrtc, RTC_FLAG_ALRAF);
/* Configure the Alarm interrupt */
__HAL_RTC_ALARM_ENABLE_IT(hrtc,RTC_IT_ALRA);
/* RTC Alarm Interrupt Configuration: EXTI configuration */
__HAL_RTC_ALARM_EXTI_ENABLE_IT();
__HAL_RTC_ALARM_EXTI_ENABLE_RISING_EDGE();
hrtc->State = HAL_RTC_STATE_READY;
__HAL_UNLOCK(hrtc);
return HAL_OK;
}
怀疑是EXTI17没配置好,不知道是哪出问题?
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
一周热门 更多>