views:

85

answers:

2

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 ?

A: 

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
Harper Shelby
so your saying acall delay right ? when i tried that approach earlier it told me ACALL dakay was an unknown command?
Kyle
My program look likes this
Kyle
I have no idea what "acall delay" means. In x86 assembler, I'd load CX with my value, put a label and loop instruction that points to it on the same line, and voila - delay loop.
Harper Shelby
i appreciate your help im still confused but thank you for your time im not sure what CX is or the label and loop instruction, this is all very new to me and im not sure if im even asking the right question? im trying to read diagrams from other programs and make them relate to this one and all of the programs have an ACALL in them are you using assembly language?
Kyle
Yes - this is MASM syntax from x86 assembly - it's the only one I've done much with.
Harper Shelby
we are using the 8051 by intel sound familar?
Kyle
what does CX stand for? it that like a port?
Kyle
@Kyle, CX is a register, as should be clear from the fact that something is being moved in. You move a countdown value into it, then loop until it reaches zero. The LOOP is evidently an instruction or macro that tests for CX being zero, and otherwise executes the jump and decrements CX. (No, I don't know x86, but this is obvious to anybody with some sort of assembler experience.)
David Thornley
@Kyle: updated the x86 style loop to be 8051 friendly (assuming the docs I read were correct).
Harper Shelby
A: 

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)

Ahmed Kotb