完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
嗨,我是一个新的编程MCU,目前我正在使用中断来唤醒PIC16LF1619从睡眠模式,我使用XC8和MPLAB V3.60,下面是我的尝试代码:空主(空){//Stultin初始化;Time1In IIT;Py1BITS.TMR1IE=1;;/启用Time1 IncBist.Peee=1;//启用外围设备AL中断TMR1H=0x00;TMR1L= 0x00;ItCONBITI.GIE=1;//启用全局中断T1CONTITS。TMR1ON=1;//启动定时器TISISC=0;//执行主程序(1){LaPE();//Le77LAT=1;}空隙中断(空隙){if(TMR1IF=1)}{LeD6LaLAT= 1;;/执行ISR任务TMR1IF=0;}(ADIF==1);{……} LED就一直亮着。我不知道我做错了什么。有人能帮我弄清楚这个吗?
以上来自于百度翻译 以下为原文 Hi I am new to program a MCU, currently I am working on using interrupt to wake pic16lf1619 from sleep mode I am using xc8 and mplab v3.60 ,below is my attempting code: void main(void) { // SYSTEM_Initialize; timer1_init; PIE1bits.TMR1IE = 1; // enable timer1 INTCONbits.PEIE = 1; // enable peripheral interrupt TMR1H = 0X00; TMR1L = 0X00; INTCONbits.GIE = 1; //enable global interrupt T1CONbits.TMR1ON = 1; //start timer TRISC = 0; //perform main program while(1) { SLEEP(); // LED7_LAT=1; } } void interruptISR(void){ if(TMR1IF==1) { LED6_LAT = 1; //perform ISR tasks TMR1IF = 0; } if(ADIF==1){ //... .. } } the LED just stays on.I don't know what I am doing wrong.Can someone help me figure out this please |
|
相关推荐
17个回答
|
|
这并不指定中断服务。
以上来自于百度翻译 以下为原文 This does NOT specify an interrupt service. void interruptISR(void){ try void interrupt ISR(void){ |
|
|
|
嗨,谢谢你的回复。当我写:空中断ISR(无效),我得到这个:MUC.C:104:错误:(1506)多个中断功能(γISR和YEXTUTTION中断管理器)定义在中断级别1。
以上来自于百度翻译 以下为原文 Hi thank you for replying.When I write:void interrupt ISR(void), I get this :main.c:104: error: (1506) multiple interrupt functions (_ISR and _INTERRUPT_InterruptManager) defined at interrupt level 1. |
|
|
|
看起来你有两个中断功能。你的LED保持不变,因为你的代码在邮政1不关闭LED。
以上来自于百度翻译 以下为原文 Look like you have two interrupt functions. Your LED stays on because your code in Post #1 does not turn the LED off. |
|
|
|
你用MCC写代码吗?如果是这样,你就应该提到它了。看来MCC已经创建了一个中断服务例程,您应该使用它。
以上来自于百度翻译 以下为原文 Are you using MCC to write your code? If so, you should have mentioned it. It appears that MCC has already created an interrupt service routine, and you should be using that. |
|
|
|
任何人都可以解决这个问题来帮助我。任何资源,示例将有助于学习和解决这个问题。如果我可以陈述这个问题,再次:我正在尝试使用中断(TMR1)唤醒PIC16LF1619从睡梦中。我想知道我是否需要一个外部时钟或内部时钟将是鞠。很好,请帮忙
以上来自于百度翻译 以下为原文 Is anyone might have solve this issue to help me out.any resources , example will be helpful to learn and solve this.if I can state the issue, again:I am trying to use interrupt(TMR1) to wake up a pic16lf1619 from sleep.and was wondering if I will need an external clock or internal clock will be just fine.Help please |
|
|
|
请阅读数据表。它清楚地说明了在什么情况下这会起作用。请记住,在睡眠操作期间,系统时钟被关闭。如果TMR1键合到这个时钟源…它停止计数!考虑使用WDT唤醒处理器休眠。
以上来自于百度翻译 以下为原文 Please read the data sheet. It cleary states in what situations this would work. Remember that during a sleep operation the system clock is turned off. If TMR1 is bonded to this clock source ... It stops counting! Consider using the WDT to wake the processor from sleep. |
|
|
|
不管你使用哪一个时钟,你都可以这样做。你只需要让一个中断服务程序工作正常。你忽略了我关于MCC的问题。注意,如果你唯一的目标是从睡眠中醒来,你甚至不需要使用中断服务。读一下睡眠是如何工作的。如果中断被禁用(GIE=0),它将从睡眠指令之后开始运行。请参阅“数据表中的7.3个睡眠中断”。
以上来自于百度翻译 以下为原文 It doesn't matter which clock you use, you can do it either way. You just have to get an interrupt service routine working correctly. You ignored my question about MCC. Note, if your only aim is to wake up from sleep, you don't even need to use an interrupt service. Read about how sleep works again. If interrupts are disabled (GIE=0), it will just start running from after the sleep instruction. See: "7.3 Interrupts During Sleep" in the datasheet. |
|
|
|
+1i集中在中断问题上,忘记了这一点。提出的代码永远不会写入T1CON寄存器中的TMR1CS位。默认值是0B00,它选择FoC/ 4,它将在休眠模式下停止,因此唤醒将永远不会发生。如果Y,尝试将其更改为0B11(LFIFTSC)。你希望计时器在睡眠模式下计数。
以上来自于百度翻译 以下为原文 +1 I was concentrating on the interrupt problem, and forgot about this. The code presented is never writing to the TMR1CS bits in the T1CON register. The default value is 0b00, which selects Fosc/4, which will stop in sleep mode, so the wakeup will never occur. Try changing them to 0b11 (LFINTOSC) if you want to the timer to count in sleep mode. |
|
|
|
只需知道,我也有MCC中断运行。现在关闭没有更多的错误。这是我现在使用之前,你的新评论:空main(空隙){//StultIn初始化;Py1BITS.TMR1IE=1;//启用Time1 ItCONBITS。Peee=1;//启用外围中断TMR1H=0x00;TMR1L=0x00;ItCONBITI. GIE=1;//启用全局中断T1CONTITS。TMR1ON=1;/start计时器TISISC=0;TrISA=0;//执行主程序(1){//SalePoE();Re7O7 LAT=1;}空隙中断ISR(空隙){if(pRI1BIT.TMR1IF=1){PrI1IF=0;IF(Py1BIT.TMR1IE=1){{Le66LAT= 1;/Primo)}。RM ISR任务,{ DelayyMs(10000);LeD6LaLat= 0;γ-DelayyMS(10000);TMR1H=0x80;TMR1L= 0x00;} }我只想先看一下,如果中断工作,我看到它正在工作。我将带您的建议看何时替换睡眠();指令,如果它醒来,如果不是,我将使用看门狗T。做这个工作。谢谢你的回复。保持状态
以上来自于百度翻译 以下为原文 Just figure out that I had MCC interrupt running as well.I turn off now there is no more error.This is what I am using now before your new comment: void main(void) { // SYSTEM_Initialize; PIE1bits.TMR1IE = 1; // enable timer1 INTCONbits.PEIE = 1; // enable peripheral interrupt TMR1H = 0X00; TMR1L = 0X00; INTCONbits.GIE = 1; //enable global interrupt T1CONbits.TMR1ON = 1; //start timer TRISC = 0; TRISA = 0; //perform main program while(1) { // SLEEP(); LED7_LAT = 1; } } void interrupt ISR(void){ if (PIR1bits.TMR1IF==1) { PIR1bits.TMR1IF=0; if ( PIE1bits.TMR1IE==1) { LED6_LAT = 1; //perform ISR tasks __delay_ms(10000); LED6_LAT = 0; __delay_ms(10000); TMR1H = 0x80; TMR1L = 0x00; } } } I just wanted to see first if the interrupt was working , I see it working.I will take ur advice to see when replace the SLEEP(); instruction see if it wakes up if not I will use the watch dog to do the job.Thanks for the reply.Keep status |
|
|
|
|
|
|
|
不管是从睡眠模式中醒来还是让MCU在睡眠中醒来,并用指令醒来。
以上来自于百度翻译 以下为原文 is there anyway to provide the time to wake up from sleep mode or leave the mcu in sleep and wake up with an instruction |
|
|
|
看门狗定时器具有从1毫秒到256秒(标称)的超时周期。
以上来自于百度翻译 以下为原文 The watchdog timer has a time-out period from 1 ms to 256 seconds (nominal). |
|
|
|
假设代码来考虑会发生什么…免责声明:代码包含不存在的命令,不打算运行或什么,目的是要考虑会发生什么。
以上来自于百度翻译 以下为原文 Hypothetical code to think about what would happen... Disclaimer: The code contains commands that do not exist and is not intended to run or whatever, the intention is to think about what would happen. ... SLEEP Delay_ms (250) WAKE_UP ... |
|
|
|
不多。WDT将帮助您。查看关于设置WDT的数据表,因为您不能像定时器那样设置它。你可以启用/禁用它。它必须被配置为当烧录时写入到芯片中的位/秒。
以上来自于百度翻译 以下为原文 Not much. WDT will help you. Look at the datasheet about setting up the WDT since you can't set it like you can with a timer. You can en/disable it. It has to be configured as bit/s written into the chip when burning. |
|
|
|
大家好,感谢之前的回复,这是有帮助的。我正在做不同的项目,只是为了实践。这个想法是创建一个倒计时或计数时钟,一旦光传感器检测到光就停止计数。我使用PIC16LF1619,在这一点上,我正在读取数据表和P。我想知道是否有人可以帮助建立代码或数据表旁边的任何资源,这有助于理解和实现这一实践。
以上来自于百度翻译 以下为原文 Hi everyone, Thanks for the previous reply, it was helpful. I am working on different project just in order to practice.the idea is to create a countdown or count up clock that will stop counting once the light sensor detect light.I am using pic16lf1619,at this point I am reading the data sheet and putting ideas together.I was wondering if anyone may help on the code set up or any resources beside the data sheet that may help to understand and get this practice accomplish |
|
|
|
从睡眠中醒来,您只能使用外部中断有线到一个int端口,这是因为OSC是关闭的。
以上来自于百度翻译 以下为原文 To wake up from SLEEP you can only use external interrupt wired to one of the INT ports, this is because the osc is off. |
|
|
|
不,有很多来源可以从睡眠中醒来。WDT,具有外部时钟、比较器、MSSP、UART等的TMR1。
以上来自于百度翻译 以下为原文 No, there are many sources to wake from sleep. WDT, TMR1 with external clock, comparators, MSSP, UART, etc. |
|
|
|
只有小组成员才能发言,加入小组>>
5244 浏览 9 评论
2035 浏览 8 评论
1955 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3214 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2261 浏览 5 评论
779浏览 1评论
673浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
599浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
683浏览 0评论
580浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-25 20:45 , Processed in 1.648343 second(s), Total 112, Slave 95 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号