# help pwm 89c2051 programming

Status
Not open for further replies.

#### novschopin

##### New Member
can anyone help me on this by giving me example??or mayb help me to edit this wrong code?? thank u!

#### Attachments

• 11.5 KB Views: 204

#### Papabravo

##### Well-Known Member
What is wrong with it? It looks just fine to me?

#### novschopin

##### New Member
after i compile it there are errors......how??
help me pls.

#### Papabravo

##### Well-Known Member
That's an easy question to answer. You are using a different assembler that the one used by the original author of the code. I'm amazed that you would think tha all assemblers follow the same rules. Nevertheless, in order to help you we need to know what assembler you are using, and what errors it is producing. Then we can suggest ways in which to edit the code so that it assembles properly with your assembler. Depending on how many errors you started with thei may be either easy or hard.

BTW: I could not assemble it with the IAR 8051 Assembler so you are not alone.

#### eblc1388

##### Active Member
novschopin said:
after i compile it there are errors......how??
help me pls.
Code:
                       Input  Filename : code-1.txt
Output Filename : code-1.obj

45          0000             mode_byte       SET       r0       ;holds the current mode
***** UNDEFINED SYMBOL *****
46          0000             on_reg          SET       r1       ;motor on dwell
***** UNDEFINED SYMBOL *****
47          0000             timer1          SET       r2       ;timer/counter register
***** UNDEFINED SYMBOL *****
48          0000             timer2          SET       r3       ;timer/counter register
***** UNDEFINED SYMBOL *****
86   000B   02 00 00         timer0_int:   jmp timer0_more         ;needs more room
***** UNDEFINED SYMBOL *****
***** UNDEFINED SYMBOL *****
135   0123   12 00 00                       call loadt0             ;reset the timer
***** UNDEFINED SYMBOL *****

Lines Assembled :  233             Assembly Errors :  7
The first four errors occured because Registers R0..R7 can be switched and do not have fix addresses. One have to use absolute addressing instead, like "mode_byte SET 000h" for example.

Don't use address 08h~0Fh as it is the default stack location.

The remaining three errors related to the interrupt handling routine of Timer0 and subsequent operation related to Timer0 but the required coding is not found/included in the ASM program.

#### Papabravo

##### Well-Known Member
In your assembler you have to verify that it understands what the SET pseudo operation is doing. Then you have to make sure that the symbols R0 and R1 are defined.

The reason for the other errors may have to do with how your assembler handles labels. If you see the label, followed by a colon, followed by and opcode you might want to insert a newline after the colon and make sure the opcode does not start in column 1

Which assembler are you using by the way?

Status
Not open for further replies.