需要帮助编写程序
我正在上微处理课程,并且在编写一个程序时遇到一些麻烦,该程序将在移动到下一个端口之前将端口中的值保存两秒钟。
任何人都可以帮助这更有意义吗?
我曾想过使用 NOP 但意识到这有点不切实际,我尝试过 ACALL DELAY 但由于某种原因它作为未知命令拉起。
我现在很困惑,希望能得到任何帮助。
我正在使用时钟为 11 MHz 的 DS89C450,我尝试询问教授,他告诉我这是小菜一碟,你应该没问题,但阅读和编写代码对我来说是全新的,我只是这样做过两周。当我看这本书的时候,它几乎就像是用中文写的,很难理解它,我的同学和我一样被难住了,我想我最后的办法就是在网上询问可能有类似经历的人问题或有更多洞察力的人可能能够为我指明正确的方向。
我知道我需要为每个端口加载指定的值,我的问题在于端口的切换给它们带来了 2 秒的延迟。
我的程序看起来像这样 MOV P0、#33H MOV P1、#7FH MOV P2、B7H MOV P3、EFH 因此,随着这四个端口加载这些值,我需要 P0 转到 P1、P1-P2 等。 P3 其值需要转到 P0 并全部循环。我打算使用 SJMP 将其循环回到开始位置,以便程序始终运行
在执行此操作时,有两秒的延迟,其中每个值仅在每个端口中停留两秒,这仍然是模糊的,其余的听起来正确吗?
I am taking a class in microprocessing, and having some trouble writing a program that will hold a value in a port for two seconds before moving on to the next port.
Can any one help this make more sense?
I have thought of using NOP but realized thats a bit unrealistic, I have tried ACALL DELAY but for some reason its pulling up as an unknown command.
I am stumped at this point and would appreciate any help I could get.
I am using the DS89C450 With a clock of 11 MHz, i've tried asking the professor and he tells me its a peice of cake you should have this no problem, but reading and writing code is breand new to me ive only been doing it for two weeks. when i look at the book its almost like it written in chinese its hard to make sense of it, my fellow class mates are just as stummped as i am, i figured my final resort would be to ask someone online that might of had a similar problem or someone who has a little more insight that might be able to pont me in the right direction.
I know i need to load each port with the specified value my problems lies in the switching of the ports giving them the 2 second delay.
My program look likes this MOV P0, #33H MOV P1, #7FH MOV P2, B7H MOV P3, EFH so with these four ports being loaded with these values i need P0 to go to P1, P1-P2 and so on when getting to P3 its value needs to go to P0 and loop it all. i was going to use SJMP to loop it back to the start so the program is always running
While doing this there is the two second delay where each value only stays in each port for only two seconds thats what still fuzzy, does the rest sound right ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我在 PIC 16f84 微控制器中做了类似的事情
来实现延迟,你有两种方法,要么使用中断,要么使用循环,
因为你知道每秒指令数,你可以使用循环来生成所需数量的指令, 所需的时间
此链接说明了如何确定循环索引 (您可能需要如果需要所需的指令数量,则嵌套循环..在 PIC 中,我必须制作 100 万条指令才能延迟 1 秒)
i have done something similar in PIC 16f84 micro-controller
to make a delay you have 2 ways either use interrupts or loops
since you know the Instructions_per_second you can use a loop to generate the required number of instructions that takes the required time
this link illustrates how to determine the loop indexes (as you might need nested loops if the number of instructions required is required .. in PIC i had to make 1 million instruction to make a delay of 1 second)
我从来没有用那个特定的芯片做过这个(而且我不知道它支持的汇编语法),但是伪代码方法是这样的:
我认为这就是你真正需要的结构。根据我对 8051 汇编的 10 分钟阅读,延迟循环如下所示:
I've never done this with that particular chip (and I don't know the assembly syntax it supports), but a pseudocode approach would be something like this:
I think this is all you really need for structure. Based on my 10 minute reading on 8051 assembly, the delay loop would look like: