需要帮助编写程序

发布于 2024-09-28 15:56:11 字数 616 浏览 4 评论 0原文

我正在上微处理课程,并且在编写一个程序时遇到一些麻烦,该程序将在移动到下一个端口之前将端口中的值保存两秒钟。

任何人都可以帮助这更有意义吗?
我曾想过使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

倦话 2024-10-05 15:56:11

我在 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)

旧情勿念 2024-10-05 15:56:11

我从来没有用那个特定的芯片做过这个(而且我不知道它支持的汇编语法),但是伪代码方法是这样的:

Load initial values into ports
Initialize counter with (delay in seconds * clock ticks per second) / (clock ticks in loop)
While counter != 0
    Decrement counter 
Swap port values:
    P3 -> temp, P2 -> P3, P1 -> P2, P0 -> P1, temp -> P0
Loop (4 times?)

我认为这就是你真正需要的结构。根据我对 8051 汇编的 10 分钟阅读,延迟循环如下所示:

          MOV A, b6h ; ~91 ticks/sec @ 11 ms/tick 
DELAY:    DEC A
          JNZ DELAY ; NOP-type delay loop

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:

Load initial values into ports
Initialize counter with (delay in seconds * clock ticks per second) / (clock ticks in loop)
While counter != 0
    Decrement counter 
Swap port values:
    P3 -> temp, P2 -> P3, P1 -> P2, P0 -> P1, temp -> P0
Loop (4 times?)

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:

          MOV A, b6h ; ~91 ticks/sec @ 11 ms/tick 
DELAY:    DEC A
          JNZ DELAY ; NOP-type delay loop
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文