完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
你好!我想知道如果我使用HIMOTSC(FoSC/4)时钟,我是否可以使用time1唤醒睡眠?(我尝试过没有成功)如果没有,有另一个计时器能做到这一点吗?感谢亚历山大
以上来自于百度翻译 以下为原文 Hi! I was wondering if I could use the Timer1 to wake-up from sleep if I use the HFINTOSC (FOSC/4) clock ? (I have tried without any success) If not is there another timer that could do that? thanks in advance Alexandros |
|
相关推荐
17个回答
|
|
检查数据表的第9部分,讨论瞌睡模式。如果设置正确,一个启用源的中断会唤醒CPU的瞌睡(请再次参阅数据表)。外围设备,包括Time1,继续在瞌睡模式下运行。
以上来自于百度翻译 以下为原文 Check section 9 of the datasheet, it discusses DOZE mode. An interrupt from an enabled source will wake the CPU from DOZE if the settings are correct (see data sheet again). The peripherals, including timer1, continue to operate in DOZE mode. |
|
|
|
你好!我发现了我的错误!我已经设置了Ty0CON1寄存器,而不是T1CON寄存器。现在我的代码工作如预期。我必须注意到,使用16MHz的系统时钟,以FoSC/4为内部时钟的最大Time1周期IGET和1:8的预分频器(大约)131Ms。我希望PIC从瞌睡睡眠模式E唤醒。2秒。所以我要么使系统时钟1MHz,要么使用来自实时时钟设备DS323的32 kHz时钟信号,并将其设置为T1CON寄存器。如果我去第二个解决方案,我如何注入一个32 kHz的时钟刺激?我知道我必须做一些刺激。谢谢。
以上来自于百度翻译 以下为原文 Hi! I have spotted my mistake! I had set the T0CON1 register instead of the T1CON register. Now my code works as expected. I have to note thogh that using a 16MHz system clock the maximum timer1 period I get with Fosc/4 as the internal clock and the prescaler as 1:8 is (roughly) 131ms. I want the PIC to wake up from Doze Sleep mode every 2 seconds. So I either make the system clock 1MHz or I use the 32KHz clock signal from the Real Time Clock device DS3231 with the appropriate settings to T1CON register. If I go for the second solutions how do I inject a clock stimulus of 32KHz? I know I have to do something in Stimulus. thanks |
|
|
|
您可以更改时钟的Time1到LFIFTSC(31千赫),并获得更长的延迟。这个OSC在瞌睡期间工作。
以上来自于百度翻译 以下为原文 You can change the clock for timer1 to the LFINTOSC (31khz) and get longer delays. This osc operates during DOZE. |
|
|
|
嗨,我已经改变了Time1到LimtoSc(13kHz)的时钟源,PIC并没有从睡眠中醒来。它应该每2秒醒来一次。有什么想法吗?
以上来自于百度翻译 以下为原文 Hi. I have changed the clock source for timer1 to LFINTOSC (31KHz). MOVLW B'11000101' MOVWF T1CON PIC doesn't wake up from sleep. It was supposed to wake up every 2 seconds. Any thoughts? |
|
|
|
只在瞌睡模式下工作,你确定你不是在使用睡眠吗?
以上来自于百度翻译 以下为原文 Only works in DOZE mode, are you sure you are not using SLEEP instead? |
|
|
|
|
|
|
|
MIN。这是我的密码,亚历克斯
以上来自于百度翻译 以下为原文 main.asm #if 0 $History: main.asm $ ; ; ***************** Version 0 ***************** ; 10-12-17 Alexandros Stefanidis ; Version 0 is using PIC18LF18325 ; This is for the Temperature+RTC meter #endif ; ====================================================================== ; Included files #include "project.inc" ; ********************************************************************** ; External access to linked files EXTERN Set_Default_IO, Set_Peripherals ; .asm ; Code Here ; ********************************************************************** ; Set configuration bits ; setup to use the 16MHz internal oscillator __CONFIG _CONFIG1, _FEXTOSC_OFF & _RSTOSC_HFINT1 & _CLKOUTEN_OFF & _CSWEN_ON & _FCMEN_OFF ; ------------------------------------------------------------------------------------------------------------------------- __CONFIG _CONFIG2, _MCLRE_ON & _PWRTE_OFF & _WDTE_SWDTEN & _LPBOREN_OFF & _BOREN_OFF & _BORV_LOW & _PPS1WAY_ON & _STVREN_ON & _DEBUG_OFF ; ------------------------------------------------------------------------------------------------------------------------ __CONFIG _CONFIG3, _WRT_OFF & _LVP_ON ; ------------------------------------------------------------------------------------------------------------------------ __CONFIG _CONFIG4, _CP_OFF & _CPD_OFF ;Specify the System clock frequency in Hz #define FOSC 16000000 ; Specify the Peripheral clock frequency in Hz #define FCYC (FOSC/4) ; ID __idlocs _IDLOC0, 0x1 ;IDLOC register 0 will be ;programmed to 1. __idlocs _IDLOC1, 0x2 ;IDLOC register 1 will be ;programmed to 2. __idlocs _IDLOC2, 0x3 ;IDLOC register 2 will be ;programmed to 3. __idlocs _IDLOC3, 0x4 ;IDLOC register 3 will be ; ********************************************************************** ; ; Start of code ; ; Put ISR context save storage in the Common bank INT_VAR UDATA_SHR W_TEMP RES 1 ; w register for context saving (ACCESS) STATUS_TEMP RES 1 ; status used for context saving BSR_TEMP RES 1 ; bank select used for ISR context saving ;------------------------------------------------------------------------------ ; RESET VECTOR ;------------------------------------------------------------------------------ POR CODE 0x0000 ; processor reset vector ;BANKSEL NVMADR ;CLRF NVMADRL ; First silicon does not do this on POR ;CLRF NVMADRH ;BANKSEL 0 GOTO Main ; go to IDATA initializer ;------------------------------------------------------------------------------ ; INTERRUPT SERVICE ROUTINE ;------------------------------------------------------------------------------ INTRV CODE 0x0004 ; Run the Interrupt Service Routine ISR: BANKSEL RC1REG MOVF RC1REG,W BANKSEL PIR1 BTFSC PIR1,TMR1IF BCF PIR1,TMR1IF RETFIE ;------------------------------------------------------------------------------ ; MAIN PROGRAM ;------------------------------------------------------------------------------ ; ;****************************************************************************** ; Data space MAIN_UDATA UDATA MAIN_IDATA IDATA ;****************************************************************************** ; Start of main program ; MAIN_CODE CODE ; let linker place main program Main: Power_Up ; A test to check if the HF-INTOSC oscillator frequency is stable BANKSEL OSCSTAT1 BTFSS OSCSTAT1,HFOR Goto Power_Up ; Set 'safe' I/O CALL Set_Default_IO ; Enable UART peripheral module, enable UART interrupts CALL Set_Peripherals ; Leave in bank 0 ; A bit of a delay to allow the power supply to come up properly ; Defined as Power-up Timer Period = 1ms ; A 1ms delay ;PU_Delay ;Dly32 D'200' Loop1 NOP ; Put the device to sleep BANKSEL CPUDOZE BSF CPUDOZE,IDLEN NOP SLEEP NOP ;Turn on Timer Tmr1IF_check BANKSEL PIR1 BTFSC PIR1,TMR1IF GOTO Tmr1IF_check GOTO Loop1 END ; No (more) instructions io.asm ; Included files #include "project.inc" ; ********************************************************************** PROG CODE ; Set safe i/o for ThermometerRTC Meter Ver.A Set_Default_IO BANKSEL PORTA MOVLW 0x08 ; RA0 - not used MOVWF PORTA ; RA1 - not used ; RA2 - not used BANKSEL LATA ; RA3 - MCLR used as input MOVLW 0x08 ; RA4 - not used MOVWF LATA ; RA5 - not used BANKSEL ANSELA ; CLRF ANSELA ;digital I/O BANKSEL TRISA MOVLW 0x08 MOVWF TRISA BANKSEL PORTC MOVLW B'00000000' ; RC0 - SCL1 - I2C Clock 1 MOVWF PORTC ; RC1 - SDA1 - I2C Data 1 ; RC2 - not used BANKSEL LATC ; RC3 - not used MOVLW B'00000000' ; RC4 - TX - EUSART asynchronous output MOVWF LATC ; RC5 - RX - EUSART asynchronous input BANKSEL ANSELC ; CLRF ANSELC BANKSEL TRISC MOVLW B'10000000' MOVWF TRISC BANKSEL RC4PPS MOVLW B'00010100' ;Make RC4 pin EUSART TX MOVWF RC4PPS RETURN ; ====================================================================== Set_Peripherals BANKSEL WPUA ;BANK 4 MOVLW B'00000000' MOVWF WPUA MOVLW B'00000000' MOVWF WPUC ;----------------------------------------------------------------------- BANKSEL ODCONA ;BANK 5 MOVLW B'00000000' MOVWF ODCONA MOVLW B'00000000' MOVWF ODCONC ;----------------------------------------------------------------------- BANKSEL SLRCONA ;BANK 6 MOVLW B'00000000' MOVWF SLRCONA MOVLW B'00000000' MOVWF SLRCONC ;----------------------------------------------------------------------- BANKSEL INLVLA ;BANK 7 MOVLW B'00000000' MOVWF INLVLA MOVLW B'00000000' MOVWF INLVLC ;----------------------------------------------------------------------- BANKSEL PMD0 ;Selects bank 18 MOVLW B'01000011' ;FVR Module disabled MOVWF PMD0 ;CLKR module disabled ;IOC module disabled MOVLW B'11111101' ;NCO1 module disabled MOVWF PMD1 ;Timer1 Enabled MOVLW B'11111111' ;DAC Module Disabled MOVWF PMD2 ;ADC Module disabled ;Comparator C1 & C2 Disabled MOVLW B'11111111' ;Disabled CWG1 & CWG2 MOVWF PMD3 ;Disabled PWM5 & PWM6 ;Disabled CCP1 & CCP2 & CCP3 & CCP4 MOVLW B'00000000' ;EUSART1 Enabled MOVWF PMD4 ;MSSP1 & MSSP2 Enabled MOVLW B'11111111' ;DSM Disabled MOVWF PMD5 ;CLC1 to CLC4 Disabled ;------------------------------------------------------------------------------- MOVLW B'01100000' ;Oscillator Control register 1 MOVWF OSCCON1 ;HFINTOSC(1MHz) + Clock Divider = 1 Freq_switch BTFSS OSCCON3,NOSCR GOTO Freq_switch MOVLW B'00000000' MOVWF OSCCON2 ;Oscillator Control register 2 MOVLW B'00000000' MOVWF OSCCON3 ;Oscillator Control register 3 MOVLW 0x00 MOVWF OSCEN MOVLW B'00000110' ;HFINTOSC Frequency Selection Register MOVWF OSCFRQ ;16MHz (NOSC = 110) MOVLW B'00000000' ;Oscillator Tuning register MOVWF OSCTUNE ;Center frequency ;----------------------------------------------------------------------- MOVLW B'11000000' ;resides to all banks MOVWF INTCON ;Interrupt Control register ;----------------------------------------------------------------------- BANKSEL PIE0 ;Bank 1 MOVLW B'00000000' ;Peripheral Interrupt Enable register 0 MOVWF PIE0 MOVLW B'00100001' ;Peripheral Interrupt Enable register 1 MOVWF PIE1 ;RCIE=1 - Enables the EUSART receive interrupt ;TMR1IE=1 - Enables the TMR1 interrupt MOVLW B'00000000' ;Peripheral Interrupt Enable register 2 MOVWF PIE2 MOVLW B'00000000' ;Peripheral Interrupt Enable register 3 MOVWF PIE3 ; MOVLW B'00000000' MOVWF PIE4 ; Peripheral Interrupt Enable register 5 ;------------------------------------------------------------------------ BANKSEL PIR0 ;Bank 0 MOVLW B'00000000' ;Peripheral Interrupt Enable register 0 MOVWF PIR0 MOVLW B'00000000' ;Peripheral Interrupt Enable register 1 MOVWF PIR1 ; MOVLW B'00000000' ;Peripheral Interrupt Enable register 2 MOVWF PIR2 MOVLW B'00000000' ;Peripheral Interrupt Enable register 3 MOVWF PIR3 ; MOVLW B'00000000' MOVWF PIR4 ; Peripheral Interrupt Enable register 5 ;------------------------------------------------------------------------ BANKSEL CLKRCON ;Bank 7 MOVLW B'00000000' MOVWF CLKRCON ;------------------------------------------------------------------------ BANKSEL TX1STA ;Bank 3 MOVLW B'00100100' MOVWF TX1STA MOVLW B'10010000' MOVWF RC1STA MOVLW B'00000000' MOVWF BAUD1CON MOVLW B'01100111' MOVWF SP1BRGL MOVLW B'00000000' MOVWF SP1BRGH ;----------------------------------------------------------------------- BANKSEL T0CON0 ;BANK 0 MOVLW B'00000000' MOVWF T0CON0 MOVLW B'00000000' MOVWF T0CON1 MOVLW B'11000101' MOVWF T1CON MOVLW B'00000000' MOVWF T2CON BANKSEL T3CON ;BANK 8 MOVLW B'00000000' MOVWF T3CON MOVLW B'00000000' MOVWF T4CON MOVLW B'00000000' MOVWF T5CON MOVLW B'00000000' MOVWF T6CON ;----------------------------------------------------------------------- BANKSEL WDTCON ;BANK 1 MOVLW B'00000000' MOVWF WDTCON RETURN ; ====================================================================== GLOBAL Set_Default_IO GLOBAL Set_Peripherals ; ===================================================================== END ; No (more) instructions project.inc ; ###################################################################### ; Start of file "project.inc" ; ###################################################################### ; PROJECT - Temperature Meter and RTC data transmitted at 868MHz Ver.A ; SECTION - PCIP PIC Code ; MODULE ; ---------------------------------------------------------------------- ; (c)2017 ; 3 Tirynthos ; Peristeri ; Athens ; 12135 ; Greece ; Tel. (+30) 211 4009773 ; ====================================================================== ; REVISION HISTORY ; ..........................----------------............................ ; Mark the next block as comment by begining with #if 0 and ending with # endif. #if 0 $History: project.inc $ ; ; ***************** Version 0 ***************** ; 10-12-2017 Alexandros Stefanidis ; Version 0 is using PIC16LF18325 #endif ; ====================================================================== ; Listing Directives list P=16LF18325, r=dec, n=0, f=inhx8m, mm=ON, st=ON ; Default number radix is decimal ; f=inhx8m sets the hex file output to inhx8m ; mm=ON prints the memory map in the list file ; st=ON prints the symbol table in the list file errorlevel 0 ; Print all messages, warnings and errors in the list file ; errorlevel -302 ; Suppress "Msg 302: Register not in bank 0. Ensure bank bits are correct." title "TemperatureRTC Meter Ver.A(16LF218325)" subtitle "(c)Alexandros Stefanidis" ;Macro Directives expand ; Print macro expansions in the list file ; Included files #include ;#include "macros.inc" ;=============================================================================== ; Status Bits #define SR_NPD STATUS,NOT_PD ; Power-Down bit #define SR_NTO STATUS,NOT_TO ; Time-Out bit #define SR_Zero STATUS,Z #define SR_DC STATUS,DC #define SR_Carry STATUS,C Ok. So this is my code. Alex |
|
|
|
您的代码是启用空闲模式不瞌睡模式:您必须设置十二位在CPUDOZE,以使瞌睡模式。然而,Time1中断仍然应该唤醒PIC在任一模式(虽然不是在睡觉)。你怎么知道PIC没有醒来?我看不到代码中使用什么作为唤醒的指示器。
以上来自于百度翻译 以下为原文 Your code is enabling the IDLE mode NOT DOZE mode: BSF CPUDOZE, IDLEN You must set the DOZEN bit in CPUDOZE to enable DOZE mode. However the timer1 interrupt should still wake the pic in either mode (not in SLEEP though). How do you know the pic doesn't wake up? I see nothing in your code to use as an indicator that wake-up has occurred. |
|
|
|
你可以使用WDT从睡眠中醒来。这不是很准确。
以上来自于百度翻译 以下为原文 You can use the WDT to wake up from sleep. It is just not very accurate. |
|
|
|
我用模拟器作为调试工具。我只是在设备进入空闲模式之后运行仿真,等到Time1中断发生后,在中断程序中执行恢复。在中断例程中,我放置了一个断点。因此,如果发生了Time1中断,那么中断执行程序中的代码执行应该停止,但这永远不会发生。我已经设定了一次每秒中断一次。
以上来自于百度翻译 以下为原文 Well I am using the Simulator as the debugg tool. I just run the simulation after device has enter idle mode and wait till execution resumes in interrupt routine after the timer1 interrupt occurs. In interrupt routine I have placed a breakpoint. So code execution should stop in interrupt service routine if a Timer1 interrupt has occured. But this never happens. I have set the timer1 to interrupt every 2sec. |
|
|
|
最新消息:我已经在MULL中添加了下面的代码。ASMI已经使用ICD3和UPM2编程了PIC设备,并且我可以看到UPM2的LED(连接到RC2引脚)每2秒切换一次!所以Time1在我的代码中实现了它!那么为什么不能在模拟器模式下工作呢?我必须使用刺激和弹出时钟信号或其他东西吗?亚历山大
以上来自于百度翻译 以下为原文 Latest news: I have added the following code in bold in main.asm Loop1 NOP ; Put the device to sleep BANKSEL CPUDOZE BSF CPUDOZE,IDLEN NOP SLEEP NOP ;Turn on Timer Tmr1IF_check BANKSEL PIR1 BTFSC PIR1,TMR1IF GOTO Tmr1IF_check BANKSEL PORTC MOVLW B'00000100' XORWF PORTC GOTO Loop1 I have programmed the pic device using ICD3 and UPM2 and I can see the led of UPM2 (connected to RC2 pin) toggle every 2 seconds! So timer1 works the way I have implemented it in my code! So why doesn't work out in Simulator mode? Do I have to use the stimulus and eject a clock signal or something else? Alexandros |
|
|
|
Asfar,我可以看到你从来没有启用中断与GIE位。
以上来自于百度翻译 以下为原文 Asfar as I can see you never enable the interrupts with the GIE bit. |
|
|
|
如果你指的是iToCon寄存器的GIT位,那么我就设置它。
以上来自于百度翻译 以下为原文 If you mean the GIE bit of INTOCON register then I do set it. Have a better look at io.asm file I am displaying in previous post. MOVLW B'11000000' ;resides to all banks MOVWF INTCON ;Interrupt Control register |
|
|
|
是的,对不起,我错过了。我通常不使用二进制数来设置SFR,通常使用来自Inc/h文件的位字段名称,使读取这些内容变得容易得多。
以上来自于百度翻译 以下为原文 Yep, sorry I missed that. I do not normally use binary numbers to set SFRs, usually use the bit field names from the inc/h files, makes reading these things so much easier. |
|
|
|
我想知道这是否是模拟器问题,因此把这个问题转移到Simulor论坛。
以上来自于百度翻译 以下为原文 I was wondering if this is a Simulator issue and therefore transfer this issue to the Simulator forum |
|
|
|
当然可以,我很少使用模拟器,他们可能会麻烦太多的时间。
以上来自于百度翻译 以下为原文 Certainly could be, I seldom use simulators, they can be troublesome too much of the time. |
|
|
|
这是一个模拟器问题。请参阅论坛Pasthtp://www. McCHIP.COM/FUMMS/M1024401.ASPX
以上来自于百度翻译 以下为原文 This is a simulator issue. Refer to the forum post http://www.microchip.com/forums/m1029401.aspx |
|
|
|
只有小组成员才能发言,加入小组>>
5178 浏览 9 评论
2003 浏览 8 评论
1931 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3177 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2228 浏览 5 评论
737浏览 1评论
622浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
509浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
635浏览 0评论
533浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-26 13:31 , Processed in 1.745333 second(s), Total 110, Slave 94 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号