This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

MOV PORT, A not working appropriately.

I'm running this code:

;; Test 8 operations
MOV R0,#08
LOOP: MOV A,P2
JB P1.1, L
RR A
JMP CONT
L: RL A
CONT: MOV P2,A
MOV P2,A
DJNZ R0,LOOP
END

And when I execute (MOV P2,A) it just moves to the latch, not to the pins. So that when I read it again I'll a wrong result.

Parents
  • Do we have to guess that you have some random generic 8051 chip?

    No interest at all to tell us?

    No interest at all to tell if the processor supports configuration of in/out for a port or just output with a weak pull-up?

    No reason to tell us if there is something magic that makes your processor require two MOV P2,A after each other?

    No reason to tell us how confusing you think it is for the processor to look at a bit on a port to decide if it should rotate left or right and then write back the result of the rotation to the bit that decides what rotation direction to use? Your sw comments doesn't exactly tell what _you_ think should happen when the code is run...

Reply
  • Do we have to guess that you have some random generic 8051 chip?

    No interest at all to tell us?

    No interest at all to tell if the processor supports configuration of in/out for a port or just output with a weak pull-up?

    No reason to tell us if there is something magic that makes your processor require two MOV P2,A after each other?

    No reason to tell us how confusing you think it is for the processor to look at a bit on a port to decide if it should rotate left or right and then write back the result of the rotation to the bit that decides what rotation direction to use? Your sw comments doesn't exactly tell what _you_ think should happen when the code is run...

Children
  • This is my Keil info:

    IDE-Version:
    µVision V4.72.9.0
    Copyright (C) 2013 ARM Ltd and ARM Germany GmbH. All rights reserved.

    License Information:
    eduardo reis
    home
    LIC=----

    Tool Version Numbers:
    Toolchain: PK51 Prof. Develpers Kit Version: 9.52.0.0
    Toolchain Path: C:\Keil\C51\BIN
    C Compiler: C51.Exe V9.52.0.0
    Assembler: A51.Exe V8.02b
    Linker/Locator: BL51.Exe V6.22
    Librarian: LIB51.Exe V4.29
    Hex Converter: OH51.Exe V2.7.0.0
    CPU DLL: S8051.DLL V3.91.0.0
    Dialog DLL: DP51.DLL V2.62.0.1

    The target is:
    AT89C52

    And my ASM file is just that one.

    I just had this exercise: read from one port, rotate according to a pin from another port.

    What is weird is that in another project/ exercice. This one:

    ORG 0000
    JMP 0100
    ORG 0100

    LOOP3: MOV R0,#7
    LOOP1: CLR C
    MOV A,P1
    RRC A
    MOV P1,A ;It works here
    DJNZ R0,LOOP1

    MOV R0,#7
    LOOP2: CLR C
    MOV A,P1
    RLC A
    MOV P1,A ;but not here
    DJNZ R0,LOOP2

    END