完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
电子发烧友论坛|
所以我有这个任务去做,这是我的教授给我的。我读了作业,然后去了PIC16F83的数据表,这是我们正在使用的MCU。阅读他的任务,他说TMR0中断链接到程序内存位置0x04,并且我为那个位置分配了一个GOTO。很好,但是在数据表中提到了什么?另外,如果我想使用另一个中断,可能是端口中断?我该在哪里为那个中断设置GOTO?我想我可能会把GOTO放在某个普通的中断子程序上,在0x04,在那个子程序中我要检查所有的中断标志。数据表在哪里提到这个?我检查了TMR0部分和PULTB部分,没有提到任何一个。
以上来自于百度翻译 以下为原文 So I have this assignment to do that was given to me by my professor. I read the assignment and then went to the datasheet for the PIC16F883, which is the MCU we're using. Reading his assignment, he said that the TMR0 interrupt is linked to program memory location 0x04 and that I have assign a GOTO for that location. Fine, but where in the data sheet is this mentioned? Also, what if I want to use another interrupt, maybe the PORTB interrupt? Where do I place a GOTO for that interrupt? Im thinking maybe I'm to place a GOTO, to some general interrupt subroutine, at 0x04 and in that subroutine I'm to check for all the interrupt flags? Where in the datasheet do it mention this? I checked the TMR0 section and the PORTB section and it doesn't mention any of that. |
|
相关推荐
19个回答
|
|
|
是的,只有一个中断向量。查看图2-1:程序内存映射。也请查看第14.3章用图14-7中断:中断逻辑来查看除了设置一个特殊中断(T0IE,GIE)之外,还必须设置哪些位。我不明白为什么要在中断位置放置GOTO。通常,在复位向量处放置一个GOTO以跳过中断代码。也许有助于用MPLAB(…/MPLABX/V4.01/MPASMX/模板)查看PIC的模板
以上来自于百度翻译 以下为原文 Yes, there is only one interrupt vector. View FIGURE 2-1: PROGRAM MEMORY MAP. Also view Chapter 14.3 Interrupts with FIGURE 14-7: INTERRUPT LOGIC to see what bits you have to set in addition to enable a special interrupt (T0IE, GIE). I don't understand why to place a GOTO at the interrupt location. Usually you place a GOTO at the reset vector to jump over the interrupt code. Maybe it helps to view the templates for your PIC coming with MPLAB (../MPLABX/v4.01/mpasmx/templates) |
|
|
|
|
|
你的教授真的告诉你在0004号地点放一个GOTO吗?这种想法来自于具有多个中断向量的其他处理器。在PIC16设备中,这实际上是一件非常糟糕的事情,因为Goto不应该在数据表中记录的“上下文保存”代码之前执行。
以上来自于百度翻译 以下为原文 Did your professor really tell you to put a GOTO at location 0004? That thinking is from other processors which have multiple interrupt vectors. It is actually a very BAD thing to do in a PIC16 device, because a GOTO should NOT be performed before the "context save" code documented in the datasheet. |
|
|
|
|
|
这不是在数据表中,因为它不是一个要求,实际上增加了中断响应的延迟。ISR(中断服务例程)可以驻留在地址0x04,不需要GOTO。如果你选择把你的ISR放在其他地方(C编译器通常会),那么显然需要一个中断向量的GOTO来立即跳转到ISR,但是这浪费了一个程序字和2个指令时钟来服务中断。但是,在GOTO之前必须进行上下文保存。如果使用中断,那么显然GOTO必须在重置向量(0x00)上跳过ISR(或ISR GOTO)——除非主程序只有4个字:)在(唯一)ISR中,通过测试其中断标志=1 AN,为所有启用中断提供服务。D中断启用位=1(因为如果禁用中断,标志仍然可以变高)。如果一定要始终启用中断,那么就不需要测试启用,但很多人为了安全起见。
以上来自于百度翻译 以下为原文 This is not in the datasheet because it isn't a requirement, and actually adds latency to the interrupt response. The ISR (interrupt service routine) can reside at address 0x04, and then a GOTO is not needed. If you choose to put your ISR somewhere else (and the C compiler generally will) then obviously a GOTO at the interrupt vector is needed to jump immediately to the ISR, but this wastes a program word and 2 instruction clocks in servicing the interrupt. But context saving must be done before the GOTO. If interrupts are used, then obviously a GOTO must be at the reset vector (0x00) to jump over the ISR (or ISR GOTO) - unless your main program is only 4 words :) In the (sole) ISR you service all enabled interrupts by testing their interrupt flag==1 AND interrupt enable bit==1 (because if you disable the interrupt, the flag still can go high). If an interrupt is sure to be enabled all the time, then you need not test the enable, but a lot of people do it anyway for safety. |
|
|
|
|
|
…并且测试启用位,当它一直启用时,浪费程序字和增加延迟的指令时钟。
以上来自于百度翻译 以下为原文 ... and testing the enable bit, when it's enabled all the time, wastes a program word and an instruction clock that adds latency. |
|
|
|
|
|
不管是对还是错,都是“教授”所说的,以获得满分。
以上来自于百度翻译 以下为原文 Right or wrong do exactly what this "professor" said to get full marks. As the assignment was written maybe you can share the exact text. |
|
|
|
|
|
守口如瓶…当使用多于一页的程序存储器时,16F83具有两页。
以上来自于百度翻译 以下为原文 Caveat emptor ... when more than one page of program memory is used, as the 16F883 has two pages. |
|
|
|
|
|
这是很可能的指令留下了不止一个选择的空间,因为任务的一部分是研究和选择最佳路径。
以上来自于百度翻译 以下为原文 It is quite possible the instructions left room for more than one choice as part of the assignment was to research and choose the best path. |
|
|
|
|
|
…或者“教授”不知道他在做什么。我已经被要求在工程实验室期末考试之前评分。长话短说,我们必须修复给学生期末考试的电路和/或代码,以便它能正常工作。
以上来自于百度翻译 以下为原文 ... or the "professor" does not know what's he doing. ;) |
|
|
|
|
|
微笑:我没有想到有教授不知道他们在做什么。
以上来自于百度翻译 以下为原文 Smile: |
|
|
|
|
|
教授知道他们在做什么。教授说话的时候,你在玩你的电话吗?
以上来自于百度翻译 以下为原文 Professors know their sh it. Were you playing with your phone while the professor was talking? |
|
|
|
|
|
…或者“教授”不知道他在做什么。我已经被要求在工程实验室期末考试之前评分。长话短说,我们必须修复给学生们的期末考试的电路和/或代码,以便它能正常工作。我不得不切换到从Chrome到“报价”的边缘……这所学校可能发生了什么?编辑:我按下报价按钮,认为没有发生任何事情,消息被引用,但窗口没有滚动到页面底部的编辑区域,尽管它按预期工作,并引用了帖子。由于ASP游乐场被设计成在微软后端工作,看起来一些新的GRIMMLIs发现了另一种搞乱Chrome的方法。随着Windows 10的发布,兼容了这么多,我非常希望这个小小的争吵结束了。
以上来自于百度翻译 以下为原文 ... or the "professor" does not know what's he doing. ;) I had to switch to edge from chrome to "quote" ... And what school might this have happened at ? edit: I pressed the quote button and thought nothing had happened, the message was quoted but the window did not scroll to the edit area at the bottom of the page though it worked as expected and quoted the post. As asp playground is designed to work on a Microsoft back end it looks like some new gremlins have found yet another way to mess up chrome. With the release of Windows 10 that was compatible with so much more I had high hopes this petty squabbling was over... |
|
|
|
|
|
那是一个社区学院,位于我以前的工作场所附近。那个“教授”的妻子当时为我的老板工作,我们被要求帮助完成实验室期末考试。
以上来自于百度翻译 以下为原文 It was a community college located near my former former workplace. The wife of that "professor" worked for my boss at the time, and we were asked to help grade the lab finals. |
|
|
|
|
|
我很好奇我应该注意什么样的学校,我可能会遇到简历或简历。
以上来自于百度翻译 以下为原文 I was curious what school I should watch out for on resumes/CVs I might run into. |
|
|
|
|
|
我也注意到了这一点。(起初,我以为是福巴。
以上来自于百度翻译 以下为原文 I have noticed this too. :( At first, I thought it was fubar. |
|
|
|
|
|
我宁愿不叫它,但它是十多年前的事了。
以上来自于百度翻译 以下为原文 ;) I rather not name it, but it was over a decade ago. |
|
|
|
|
|
好啊。让我直截了当。复位向量是0x00,对吗?程序存储器中的中断位置在0x04右?我应该把我所有的中断代码放在ORG 0x04下吗?这就是中断代码的起点吗?我的印象是,在程序存储器中只有一行用于服务中断,这就是为什么他有一个GOTO。我在中断代码之前放置一个GOTO以跳过它,如果没有中断的话。什么是上下文保存?我还没有读过有关中断的内容。在我的教授示例代码中,他在服务中断代码之前保存WRG的值,并在完成时恢复它。上下文保存吗?有人问我教授上课时我在上课时是否在上课。答案是否定的。我们所有的实验任务都是PDF的。我不是在网上发布PDF。教授在PDF中非常具体地提到了在那个时候放置GOTO。也有一些示例代码,这肯定会让事情有所好转。
以上来自于百度翻译 以下为原文 Ok. Let me get this straight. The reset vector is 0x00 right? The interrupt location in program memory is at 0x04 right? I should put ALL my interrupt code right under a ORG 0x04? This is where the interrupt code starts? I was under the impression there was only one line in program memory for the service interrupts and that's why he had a GOTO there. I place a GOTO before the interrupt code to jump over it if there are no interrupts? What is context saving? I haven't read up on interrupts yet. In my professors example code, he saves the value of the WREG before the service interrupt code and restores it when it's done. Is that context saving? Someone here asked if I was on my phone in class while the professor was talking... the answer is no. All of our lab assignments are PDF's. I'm not posting the PDF online. The professor was very specific in the PDF about placing a GOTO at that point. There was some example code as well. This definitely clears things up a bit. |
|
|
|
|
|
对。我不确定我甚至会使用“vector”这个词。当它被重置时,PIC跳到地址0000,并开始从那个地址执行代码。这将是一个坏印象。你有代码存储器从地址0000到闪存的顶部。它是连续的。这是回到前面。如果你使用中断(并且在那里有一个中断服务例程在位置0004),那么你的重置代码必须跳过位置0004。因此,如果需要,您可以在GOTO之前有三个其他指令的空间。如果您不使用中断,那么就不需要跳过位置0004。您的启动代码可以从地址0000开始,并继续通过位置0004。这是其中的一部分。您还必须保存状态寄存器,以及中断可能更改的任何其他寄存器。在访问任何存储的内存位置之前,您还需要选择银行0(或任何其他已知的银行)。在执行任何GOTO或呼叫指令之前,您还需要清除PCLASE寄存器。这意味着PCLATE也必须保存。这都是在数据表的中断部分中记录的。在你提问之前,你真的应该先读一读。你的教授不必在PIC16设备上编码一个真实世界的应用程序,或者至少不是一个需要使用一个以上代码存储器的页面。对于小型程序,可以忽略PCLAST,因为它总是。如果你记录了你用PCLAX所做的事情,或者为什么你可以安全地忽略它,那就值得一些奖励。
以上来自于百度翻译 以下为原文 Yes. I'm not sure I'd even use the word "vector". The PIC does jump to address 0000 when it is reset, and start executing code from that address. That would be a bad impression. You have code memory from address 0000 up to the top of FLASH memory. It is continuous. That is back to front. If you are using interrupts (and therefor have an interrupt service routine at location 0004), then your reset code has to jump over location 0004. You therefore have room for three other instructions before the GOTO, if needed. If you are not using interrupts, then there is no need to jump over location 0004. Your startup code can just start at address 0000, and continue through location 0004. That is one part of it. You also have to save the STATUS register, and any other registers that your interrupt could change. You also need to select bank 0 (or any other known bank) before you access any banked memory locations. You also need to clear the PCLATH register before you execute any GOTO or CALL instructions. That means PCLATH has to be saved also. This is all documented in the interrupt section of the datasheet. You really should read that FIRST, before asking questions here. Your professor must not have had to code a real world application on a PIC16 device then, or at least not one that required using more than one page of code memory. For small programs, it is possible to ignore PCLATH, as it will always be zero. If you document what you are doing with PCLATH, or why you can safely ignore it, that should be worth some bonus points. |
|
|
|
|
|
在我问问题之前,我没有读过中断,因为我认为我现在不需要读。我只是带着我在实验作业中读到的东西出去。这不仅仅是一个实验任务,它是一个教训。所以,在开始这项任务之前,我要先读一下中断。我认为有人说,检查中断使位是浪费时间。当我在阅读实验室作业时,我也在想同样的事情。这是真的,检查启用位是浪费时间吗?我想是的。我只需要检查/清除旗子。你认为他为什么要我们检查启用位?
以上来自于百度翻译 以下为原文 I didn't read up on interrupts before asking questions here because I didn't think I needed to read it right now. I was just going forth with what I was reading in my lab assignment. It's not just a lab assignment, it's a lesson. So yea. I'm going to read up on interrupts before I even get started with this assignment. Also... I think someone said that checking for the interrupt enable bits is a waste of time. I was thinking the same thing when I was reading through my lab assignment. Is this true that checking for the enable bits is a waste of time? I'm thinking yes. I just need to check/ clear the flags. Why do you think he would want us to check for the enable bits? |
|
|
|
|
|
我怀疑没有办法把这个概念教给那些没有花费几天的时间去寻找当中断服务程序在你不期望的时候执行的错误,或者当你的系统因为中断抖动而被锁定的时候。UPT服务的要求非常简单,测试中断使能标志似乎是浪费时间。这是更好的方式来做这个测试,也可以使发现错误在您的应用程序的其他部分更容易当您可以禁用个别中断源。如果这些原因是没有意义的哟。现在,也许当你获得一些经验时,理解就会到来。
以上来自于百度翻译 以下为原文 I suspect that there is no way to teach this concept to someone that has not spent several days looking for bugs caused when interrupt service routine execute when you do not expect them to, or when your system live-locks due to interrupt thrashing. The assignments that most students get have interrupt service requirements so simple that testing the interrupt enable flags appears to be a waste of time. It is better style to do this test, also it can make finding bugs in other parts of your application easier when you can disable individual interrupt sources. If these reasons make no sense to you at present perhaps when you gain some experience the understanding will come. |
|
|
|
|
只有小组成员才能发言,加入小组>>
MPLAB X IDE V6.25版本怎么对bootloader和应用程序进行烧录
475 浏览 0 评论
5794 浏览 9 评论
2334 浏览 8 评论
2224 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3530 浏览 3 评论
1125浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
1098浏览 1评论
我是Microchip 的代理商,有PIC16F1829T-I/SS 技术问题可以咨询我,微信:A-chip-Ti
873浏览 1评论
MPLAB X IDE V6.25版本怎么对bootloader和应用程序进行烧录
475浏览 0评论
/9
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2025-12-2 17:04 , Processed in 1.193600 second(s), Total 108, Slave 91 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191

淘帖
4974