完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
整体代码,首先一开始led周期为2s的闪烁到十秒之后进入slepp模式,配置为外部PA0唤醒,但是唤醒之后从头开始执行,一直在while里面循环打印,没有
没有在去启动时钟,很纳 // See LICENSE for license details. #include #include #include #include "nuclei_sdk_soc.h" #include "nuclei_sdk_hal.h" int set=0; int tmp ; int flag; int flag_p; /** @brief configure the GPIO ports @param[in] none @param[out] none @retval none */ void drv_cfg_init_gpio_led () { rcu_periph_clock_enable (RCU_GPIOA); rcu_periph_clock_enable (RCU_AF); gpio_init (GPIOA, GPIO_MODE_OUT_PP, GPIO_OSPEED_50MHZ, GPIO_PIN_1); } void rtc_configuration(void) { rcu_periph_clock_enable(RCU_BKPI); rcu_periph_clock_enable(RCU_PMU); pmu_backup_write_enable(); bkp_deinit(); rcu_osci_on(RCU_LXTAL); rcu_osci_stab_wait(RCU_LXTAL); rcu_rtc_clock_config(RCU_RTCSRC_LXTAL); rcu_periph_clock_enable(RCU_RTC); rtc_register_sync_wait(); rtc_lwoff_wait(); rtc_interrupt_enable(RTC_INT_SECOND); rtc_lwoff_wait(); rtc_prescaler_set(32767); rtc_lwoff_wait(); } void cfg_init_exit () { //rcu_periph_clock_enable(RCU_GPIOA); //rcu_periph_clock_enable(RCU_AF); gpio_init(GPIOA, GPIO_MODE_IN_FLOATING, GPIO_OSPEED_2MHZ, GPIO_PIN_0); ECLIC_EnableIRQ(EXTI0_IRQn); //ECLIC_Register_IRQ (EXTI0_IRQn, ECLIC_NON_VECTOR_INTERRUPT, ECLIC_NEGTIVE_EDGE_TRIGGER, 1, 2, NULL); ECLIC_SetLevelIRQ(EXTI0_IRQn,1); ECLIC_SetPriorityIRQ(EXTI0_IRQn,1); gpio_exti_source_select(GPIOA, GPIO_PIN_0); exti_init(EXTI_0, EXTI_INTERRUPT, EXTI_TRIG_FALLING); exti_interrupt_flag_clear(EXTI_0); } void time_display(uint32_t timevar) { uint32_t thh = 0, tmm = 0, tss = 0; /* compute hours */ thh = timevar / 3600; /* compute minutes */ tmm = (timevar % 3600) / 60; /* compute seconds */ tss = (timevar % 3600) % 60; printf(" Time: %0.2d:%0.2d:%0.2drn", thh, tmm, tss); } void RTC_IRQHandler(void) { //printf("6 n"); if(rtc_flag_get(RTC_FLAG_SECOND)!= RESET) { //printf("7 n"); rtc_flag_clear(RTC_FLAG_SECOND); tmp=rtc_counter_get(); if(set==0) { gpio_bit_reset (GPIOA, GPIO_PIN_1); set=1; flag=flag+2; printf("flag %d n",flag); //printf("8 n"); } else { gpio_bit_set (GPIOA, GPIO_PIN_1); set=0; //printf("9 n"); } if(flag>=10) { flag_p=1; rtc_interrupt_disable(RTC_INT_SECOND); } } } int main (void) { cfg_init_exit (); flag=0; drv_cfg_init_gpio_led (); //printf("1 n"); gpio_bit_set (GPIOA, GPIO_PIN_1); //printf("2 n"); ECLIC_Register_IRQ (RTC_IRQn, ECLIC_NON_VECTOR_INTERRUPT, ECLIC_LEVEL_TRIGGER, 1, 3, NULL); //printf("3 n"); rtc_configuration(); //printf("4 n"); exti_interrupt_flag_clear (EXTI_0); rtc_interrupt_enable(RTC_INT_SECOND); __enable_irq (); pmu_wakeup_pin_enable(); //printf("5 n"); while(1) { time_display(tmp); if (flag_p==1) { gpio_bit_set (GPIOA, GPIO_PIN_1); rtc_interrupt_disable(RTC_INT_SECOND); printf("sleepn"); pmu_to_sleepmode(WFI_CMD); exti_interrupt_flag_clear (EXTI_0); // clear EXTI lines pending flag printf ("waken"); rtc_interrupt_enable(RTC_INT_SECOND); flag=0; } } } |
|
相关推荐
|
|
只有小组成员才能发言,加入小组>>
在软件SDK中选择不同的下载模式时,是哪个部件更改了QSPI0中寄存器的值?
382 浏览 2 评论
cmt_instret_ena的使能为什么要排除branch等指令造成流水线冲刷的情况?
529 浏览 1 评论
e203 rom启动仅仅是引导到itcm执行指令吗?flash启动就是加载指令到itcm中吗?
550 浏览 1 评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-25 20:43 , Processed in 0.666688 second(s), Total 76, Slave 59 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号