Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Embedded PIC18XXX能进入深度睡眠吗?_Embedded_Sleep_Microcontroller_Pic_Microchip - Fatal编程技术网

Embedded PIC18XXX能进入深度睡眠吗?

Embedded PIC18XXX能进入深度睡眠吗?,embedded,sleep,microcontroller,pic,microchip,Embedded,Sleep,Microcontroller,Pic,Microchip,我正在学习深度睡眠模式,所以我下载了以下内容来查看深度睡眠的示例。该代码是为PIC18F46J50编写的,但我没有。我正在看代码,我注意到与该图片相关的以下配置设置 Deep Sleep BOR: DSBOREN = OFF Disabled DSBOREN = ON Enabled Deep Sleep Watchdog Timer: DSWDTEN = OFF Disabled DSWDTEN = ON Enabled Deep Sleep Watchdog

我正在学习深度睡眠模式,所以我下载了以下内容来查看深度睡眠的示例。该代码是为PIC18F46J50编写的,但我没有。我正在看代码,我注意到与该图片相关的以下配置设置

Deep Sleep BOR:
 DSBOREN = OFF
 Disabled  
DSBOREN = ON
 Enabled  

Deep Sleep Watchdog Timer:
 DSWDTEN = OFF
 Disabled  
DSWDTEN = ON
 Enabled  

Deep Sleep Watchdog Postscaler:
 DSWDTPS = 2
 1:2 (2.1 ms)  
DSWDTPS = 8
 1:8 (8.3 ms)  
DSWDTPS = 32
 1:32 (33 ms)  
DSWDTPS = 128
 1:128 (132 ms)  
DSWDTPS = 512
 1:512 (528 ms)  
DSWDTPS = 2048
 1:2,048 (2.1 seconds)  
DSWDTPS = 8192
 1:8,192 (8.5 seconds)  
DSWDTPS = K32
 1:32,768 (34 seconds)  
DSWDTPS = K131
 1:131,072 (135 seconds)  
DSWDTPS = K524
 1:524,288 (9 minutes)  
DSWDTPS = M2
 1:2,097,152 (36 minutes)  
DSWDTPS = M8
 1:8,388,608 (2.4 hours)  
DSWDTPS = M33
 1:33,554,432 (9.6 hours)  
DSWDTPS = M134
 1:134,217,728 (38.5 hours)  
DSWDTPS = M536
 1:536,870,912 (6.4 days)  
DSWDTPS = G2
 1:2,147,483,648 (25.7 days)  
但是,在PIC18F87J11上,我没有看到类似的配置这是否意味着我无法让照片进入深度睡眠状态?

/*
/*
 **  Author: Dan1138
 **  Date: 2011-AUGUST-14
 **  File: main.c 
 **  Target: PIC18F46J50
 **  OS: Win7, 64-bit
 **  MPLAB: 8.73a
 **  Compiler: C18v3.40
 **  Description: 
 **    Sleep mode example that toggles RA0
 **    output bit on wake up from sleep.
 **
 **    If deep sleep mode is working RA0 changes every 8.5 seconds.
 **    If sleep mode is working RA0 changes every 1.024 seconds.
 */

 #include <p18cxxx.h> 

 #pragma config WDTEN = OFF          /* Disabled - Controlled by SWDTEN bit                                                       */
 #pragma config PLLDIV = 2           /* Divide by 2 (8 MHz oscillator input)                                                      */
 #pragma config STVREN = ON          /* Reset on stack overflow/underflow enabled                                                 */
 #pragma config XINST = OFF          /* Instruction set extension and Indexed Addressing mode disabled (Legacy mode)              */
 #pragma config CPUDIV = OSC1        /* No CPU system clock divide                                                                */
 #pragma config CP0 = OFF            /* Program memory is not code-protected                                                      */
 #pragma config OSC = INTOSCPLL      /* INTOSC with PLL enabled(S/W control), port function on RA6 and RA7, INTOSCPLL used by USB */
 #pragma config T1DIG = OFF          /* Secondary Oscillator clock source may not be selected                                     */
 #pragma config LPT1OSC = OFF        /* Timer1 oscillator configured for higher power operation                                   */
 #pragma config FCMEN = OFF          /* Fail-Safe Clock Monitor disabled                                                          */
 #pragma config IESO = OFF           /* Two-Speed Start-up disabled                                                               */
 #pragma config WDTPS = 1            /* 1:1                                                                                       */
 #pragma config DSWDTOSC = INTOSCREF /* DSWDT uses INTOSC/INTRC as reference clock                                                */
 #pragma config RTCOSC = T1OSCREF    /* RTCC uses T1OSC/T1CKI as reference clock                                                  */
 #pragma config DSBOREN = OFF        /* Zero-Power BOR disabled in Deep Sleep (does not affect operation in non-Deep Sleep modes) */
 #pragma config DSWDTEN = ON         /* Deep Sleep Watchdog Timer Enabled                                                         */
 #pragma config DSWDTPS = 8192       /* 1:8,192 (8.5 seconds)                                                                     */
 #pragma config IOL1WAY = OFF        /* The IOLOCK bit (PPSCON<0>) can be set and cleared as needed                               */
 #pragma config MSSP7B_EN = MSK7     /* 7 Bit address masking                                                                     */
 #pragma config WPFP = PAGE_31      /* Write Protect Program Flash Page 31                                                       */
 #pragma config WPEND = PAGE_WPFP    /* Write/Erase protect Flash Memory pages starting at page WPFP[5:0]                         */
 #pragma config WPCFG = OFF          /* Write/Erase Protection of last page Disabled                                              */
 #pragma config WPDIS = OFF          /* WPFP[5:0], WPEND, and WPCFG bits ignored                                                  */

 void
 InterruptHandlerHigh (
     void
     );

 void 
 InterruptHandlerLow (
     void
     );

 /*
 ** High priority interrupt vector
 */

 #pragma code InterruptVectorHigh = 0x08
 void
 InterruptVectorHigh (void)
 {
    _asm  goto InterruptHandlerHigh  _endasm
 }

 /*
 ** Low priority interrupt vector
 */
 #pragma code InterruptVectorLow=0x18 
 void 
 InterruptVectorLow (void) 
 {
     _asm goto InterruptHandlerLow _endasm 
 }

 /* return to the default code section */ 
 #pragma code 

 /*
 **   High priority interrupt handlers
 */

 #pragma interrupt InterruptHandlerHigh

 void
 InterruptHandlerHigh (
     void
     )
 {
     /* hang here if we get an unhandled interrupt */
     for( ; ; );
 }

 /*
 ** Low priority interrupt handlers
 */
 #pragma interruptlow InterruptHandlerLow

 void 
 InterruptHandlerLow (
     void
     )
 { 
     /* hang here if we get an unhandled interrupt */
     for( ; ; );
 }

 /*
 ** Initialize this PIC hardware
 */
 void
 PICInit(
     void
     )
 {
     OSCCON = 0x70;          /* Use Primary clock source selected by config bits */
     OSCTUNEbits.PLLEN = 1;  /* Use PLL to make Fosc clock run at 48MHz */

     ANCON0  = 0xFF;         /* Turn off all analog inputs */
     ANCON1  = 0x1F;
     CM1CON  = 0x00;
     CM2CON  = 0x00;

 /*  UnLock Registers */
  EECON2 = 0x55;
  EECON2 = 0xAA;
  PPSCONbits.IOLOCK = 0;
 /*  Unlock ends */

     RPINR1  = 0x1F;         /* INT1    <= Not mapped */
     RPINR2  = 0x1F;         /* INT2    <= Not mapped */
     RPINR3  = 0x1F;         /* INT3    <= Not mapped */
     RPINR4  = 0x1F;         /* T0CLKI  <= Not mapped */
     RPINR6  = 0x1F;         /* T3CKI   <= Not mapped */
     RPINR7  = 0x1F;         /* CCP1    <= Not mapped */
     RPINR8  = 0x1F;         /* CCP2    <= Not mapped */
     RPINR12 = 0x1F;         /* T1G     <= Not mapped */
     RPINR13 = 0x1F;         /* T3G     <= Not mapped */
     RPINR16 = 0x1F;         /* RX2/DT2 <= Not mapped */
     RPINR17 = 0x1F;         /* CK2     <= Not mapped */
     RPINR21 = 0x1F;         /* SDI2    <= Not mapped */
     RPINR22 = 0x1F;         /* SCK2IN  <= Not mapped */
     RPINR23 = 0x1F;         /* SS2IN   <= Not mapped */
     RPINR24 = 0x1F;         /* FLT0    <= Not mapped */

     RPOR0   = 0x00;         /* unmap all outputs */
     RPOR1   = 0x00;
     RPOR2   = 0x00;
     RPOR3   = 0x00;
     RPOR4   = 0x00;
     RPOR5   = 0x00;
     RPOR6   = 0x00;
     RPOR7   = 0x00;
     RPOR8   = 0x00;
     RPOR9   = 0x00;
     RPOR10  = 0x00;
     RPOR11  = 0x00;
     RPOR12  = 0x00;
     RPOR13  = 0x00;
     RPOR17  = 0x00;
     RPOR18  = 0x00;
     RPOR19  = 0x00;
     RPOR20  = 0x00;
     RPOR21  = 0x00;
     RPOR22  = 0x00;
     RPOR23  = 0x00;
     RPOR24  = 0x00;

 /*  Lock Registers */
  EECON2 = 0x55;
  EECON2 = 0xAA;
  PPSCONbits.IOLOCK = 1;
 /*  Lock Registers ends */

     TRISA   = 0xFF;         /*RA0-7 are digital inputs */
     TRISB   = 0xFF;         /*RB0-7 are digital inputs */
     TRISC   = 0xFF;         /*RC0-7 are digital inputs */
     TRISD   = 0xFF;         /*RD0-7 are digital inputs */
     TRISE   = 0xFF;         /*RE0-2 are digital inputs */

     RCONbits.IPEN = 1;      /* Enable High/Low interrupt priority model. */

     if(WDTCONbits.DS)
     {
         /* handle stuff specific to wake up from deep sleep */

         /* Make RA0 an out bit */
         TRISA &= ~0x01; 
         LATA  &= ~0x01; 
     }
     WDTCONbits.DS = 0;

     if(DSCONLbits.RELEASE)
     {
         /* restore LATA state from before deep sleep wakup */
         TRISA &= ~0x01; 
         LATA = PORTA;

         /* clear deep sleep I/O config lock out */
         DSCONLbits.RELEASE = 0; 
     }
     else
     {
         /* Make RA0 an out bit */
         TRISA &= ~0x01; 
         LATA  &= ~0x01; 
     }
 }

 void
 main( 
     void 
     )
 {
     /* Disable interrupts */
     INTCONbits.GIEH = 0;

     /* Initial this hardware */
     PICInit();

     ClrWdt();

     /* toggle output bit RA0 on wake from deep sleep */
     LATA ^= 0x01; 

     /* prepare to enter deep sleep */
     INTCONbits.GIEH = 0;    /* disable interrupts */
     WDTCONbits.SWDTEN = 1;  /* turn on the watch dog timer */
     DSCONLbits.ULPWDIS = 1; /* disable ULP wake up */
     DSCONLbits.DSBOR = 0;   /* disable Brownout wake up */
     DSCONHbits.DSULPEN = 0; /* disable ULP pull up */
     DSCONHbits.RTCWDIS = 1; /* disable RTCC wake up */
     WDTCONbits.REGSLP = 1;  /* turn off core regulator for deep sleep */
     OSCCONbits.IDLEN = 0;   /* enter sleep mode, not idle */

     /* Check the generated code, the SLEEP instruction 
     ** must be the next instruction after the DSEN bit
     ** is set in the DSCONH register.
     ** If not you must use inline assembly or call
     ** an assembly function to enter deep sleep
     */
     /* go to deep sleep, DSWDT or reset is the only way out in this demo */
     DSCONHbits.DSEN = 1;
     Sleep();

     /* wait here forever */
     /* do a conventional sleep mode if we did not enter deep sleep */
     for( ; ; )
     {
         if(!DSCONHbits.DSEN)
         {   
             Sleep();    /* go to sleep */
             Nop();      /* in general it's best to do nothing for one or */
             Nop();      /* two instruction cycles after a WDT wake up    */
             /* toggle output bit RA0 on wake from sleep */
             LATA ^= 0x01; 
         }
     }
 }
**作者:丹1138 **日期:2011年8月14日 **文件:main.c **目标:PIC18F46J50 **操作系统:Win7,64位 **MPLAB:8.73a **编译器:C18v3.40 **说明: **切换RA0的睡眠模式示例 **从睡眠中醒来时的输出位。 ** **如果深度睡眠模式工作,RA0每8.5秒更改一次。 **如果睡眠模式工作,RA0每1.024秒更改一次。 */ #包括 #pragma config WDTEN=OFF/*禁用-由SWDTEN位控制*/ #pragma config PLLDIV=2/*除以2(8 MHz振荡器输入)*/ #pragma config STVREN=ON/*启用堆栈溢出/下溢复位*/ #pragma config XINST=OFF/*指令集扩展和索引寻址模式已禁用(传统模式)*/ #pragma config CPUDIV=OSC1/*无CPU系统时钟划分*/ #pragma config CP0=OFF/*程序内存不受代码保护*/ #pragma config OSC=INTOSCPLL/*INTOSC启用PLL(S/W控制),RA6和RA7上的端口功能,USB使用的intoscpl*/ #pragma config T1DIG=OFF/*可能未选择次级振荡器时钟源*/ #pragma config LPT1OSC=OFF/*定时器1振荡器配置为高功率运行*/ #pragma config FCMEN=OFF/*禁用故障保护时钟监视器*/ #pragma config IESO=OFF/*禁用双速启动*/ #pragma config WDTPS=1/*1:1*/ #pragma config DSWDTOSC=INTOSCREF/*DSWDT使用INTOSC/INTRC作为参考时钟*/ #pragma config RTCOSC=T1OSCREF/*RTCC使用T1OSC/T1CKI作为参考时钟*/ #pragma config DSBOREN=OFF/*在深度睡眠中禁用零功率BOR(不影响非深度睡眠模式下的操作)*/ #pragma config DSWDTEN=ON/*深度睡眠看门狗定时器已启用*/ #pragma config DSWDTPS=8192/*1:8192(8.5秒)*/ #pragma config IOL1WAY=OFF/*可以根据需要设置和清除IOLOCK位(PPSCON)*/ #pragma config MSSP7B_EN=MSK7/*7位地址屏蔽*/ #pragma config WPFP=PAGE_31/*写保护程序闪存第31页*/ #pragma config WPEND=PAGE_WPFP/*从第WPFP[5:0]页开始写入/擦除保护闪存页*/ #pragma config WPCFG=OFF/*最后一页的写/擦除保护已禁用*/ #pragma config WPDIS=OFF/*WPFP[5:0],忽略WPEND和WPCFG位*/ 无效的 中断器( 无效的 ); 无效的 断续器( 无效的 ); /* **高优先级中断向量 */ #杂注代码中断向量高=0x08 无效的 中断向量高(无效) { _asm goto InterruptHandlerHigh\u endasm } /* **低优先级中断向量 */ #pragma代码InterruptVectorLow=0x18 无效的 中断向量低(无效) { _asm goto INTERRUPTHANDERLOW\u endasm } /*返回默认代码部分*/ #布拉格码 /* **高优先级中断处理程序 */ #pragma中断处理器高 无效的 中断器( 无效的 ) { /*如果我们遇到未处理的中断,请挂在这里*/ 对于(;); } /* **低优先级中断处理程序 */ #pragma interruptlow InterruptHandlerLow 无效的 断续器( 无效的 ) { /*如果我们遇到未处理的中断,请挂在这里*/ 对于(;); } /* **初始化这个PIC硬件 */ 无效的 皮尼特( 无效的 ) { OSCCON=0x70;/*使用配置位选择的主时钟源*/ OSCTUNEbits.PLLEN=1;/*使用PLL使Fosc时钟以48MHz的频率运行*/ ANCON0=0xFF;/*关闭所有模拟输入*/ ANCON1=0x1F; CM1CON=0x00; CM2CON=0x00; /*解锁寄存器*/ EECON2=0x55; EECON2=0xAA; PPSCONbits.IOLOCK=0; /*解锁端*/
RPINR1=0x1F;/*INT1短语“深度睡眠”在该数据表中只出现一次,这似乎是一个错误。因此,深度睡眠不受支持,你会说?根据这些信息,你的猜测和我的一样好。我非常确定,如果它支持某个功能,该功能将出现在数据表中。我几乎肯定深度睡眠不受支持,我查看了其他pic数据et和它谈论深度睡眠,不同于我的图片。并且有一个关于深度睡眠的完整部分,而87J11不支持深度睡眠。我认为可以肯定地说,您的部分不支持深度睡眠。请通过增加您的合作伙伴,帮助消除关于StackOverflow是免费代码编写服务的误解