lcd interfacing

Discussion in 'Embedded Systems and Microcontrollers' started by saaiim, Sep 13, 2015.

  1. saaiim

    Thread Starter New Member

    Sep 13, 2015
    1
    0
    I have problem interfacing lcd and keypad with 89s52 Microcontroller
    i have problem interfacing lcd and keypad with 89s52 Microcontroller
    it display 1234567 but not displaying ABCD

    Code (ASM):
    1.  
    2. rs equ P3.5
    3.        rw equ P3.4
    4.        en equ P3.3
    5.            ORG 00H
    6.     BACK:    MOV R7,#0H
    7.              MOV A,#38H
    8.              ACALL COMNWRT
    9.              ACALL DELAY1
    10.              MOV A ,#0EH
    11.              ACALL COMNWRT
    12.              ACALL DELAY1
    13.              MOV A,#01
    14.              ACALL COMNWRT
    15.              ACALL DELAY1
    16.              MOV A,#06
    17.              ACALL COMNWRT
    18.              ACALL DELAY1
    19.              MOV A,#80H
    20.              ACALL COMNWRT
    21.              ACALL DELAY1
    22.             MOV P2,#0FFH
    23.      K1:    MOV P0,#0H
    24.               MOV A,P2
    25.               ANL A,#00001111B
    26.               CJNE A,#00001111B,K1
    27.              
    28.      K2:    ACALL DELAY
    29.             MOV A,P2
    30.             ANL A,#00001111B
    31.             CJNE A,#00001111B,OVER
    32.          
    33.             SJMP K2
    34.     OVER:   ACALL DELAY
    35.             MOV A,P2
    36.             ANL A,#00001111B
    37.             CJNE A,#00001111B,OVER1
    38.          
    39.             SJMP K2
    40.     OVER1:  MOV P0,#11111110B
    41.             MOV A,P2
    42.             ANL A,#00001111B
    43.             CJNE A,#00001111B,ROW_0
    44.             MOV P0,#11111101B
    45.             MOV A,P2
    46.             ANL A,#00001111B
    47.             CJNE A,#00001111B,ROW_1
    48.             MOV P0,#11111011B
    49.             MOV A,P2
    50.             ANL A,#00001111B
    51.             CJNE A,#00001111B,ROW_2
    52.             MOV P0,#11110111B
    53.             MOV A,P2
    54.             ANL A,#00001111B
    55.             CJNE A,#00001111B,ROW_3
    56.          
    57.             LJMP K2
    58.     ROW_0:  MOV DPTR,#KCODE0
    59.             SJMP FIND
    60.     ROW_1:  MOV DPTR,#KCODE1
    61.             SJMP FIND
    62.     ROW_2:  MOV DPTR,#KCODE2
    63.             SJMP FIND
    64.     ROW_3:  MOV DPTR,#KCODE3
    65.             SJMP FIND
    66.     FIND:  
    67.             RRC A
    68.             JNC MATCH
    69.             INC DPTR
    70.             SJMP FIND
    71.      MATCH: CLR A
    72.             MOVC A,@A+DPTR
    73.             MOV P1,A
    74.             CALL DATA1
    75.             INC R7
    76.             CJNE R7,#0FH,K1
    77.             MOV A,#01H
    78.              ACALL COMNWRT
    79.              ACALL DELAY1
    80.             LJMP BACK
    81.     DELAY:
    82.             MOV R3,#255
    83.     HERE2:  MOV R4,#120
    84.     HERE:   DJNZ R4,HERE
    85.             DJNZ R3,HERE2
    86.             RET
    87.    DELAY1:
    88.              MOV R3,#255
    89.     HERE1:   DJNZ R3,HERE1
    90.              RET        
    91.    COMNWRT:
    92.              MOV P1,A
    93.              CLR P3.5
    94.              CLR P3.4
    95.              SETB P3.3
    96.              ACALL DELAY
    97.              CLR P3.3
    98.              RET
    99.    DATA1:    
    100.              SETB P3.5
    101.              CLR P3.4
    102.              SETB P3.3
    103.              ACALL DELAY
    104.              CLR P3.3
    105.              RET
    106.      KCODE0: DB '1','2','3','A'
    107.      KCODE1: DB '4','5','6','B'
    108.      KCODE2: DB '7','8','9','C'
    109.      KCODE3: DB '*','0','#','D'
    110.      END
    111.  
    Moderators note: Pleas use code tags for pieces of code​
     
    Last edited by a moderator: Sep 13, 2015
  2. shteii01

    AAC Fanatic!

    Feb 19, 2010
    3,394
    497
    No comments? Really? Do you think anyone is stupid enough to try to figure out your program for you? You want help? Provide eFing documentation!
     
  3. joeyd999

    AAC Fanatic!

    Jun 6, 2011
    2,689
    2,750
    And I love his use of literals. Makes the code clear as mud.
     
  4. djsfantasi

    AAC Fanatic!

    Apr 11, 2010
    2,810
    834
    Sorry it's taken me so long to reply. I thought I'd check in. I estimate that I'm about 2% through understanding your code. But I had to stop because I got a headache.

    Lol. Nothing personal, but it really is unrealistic to expect someone to go through your code when it is undocumented and the values therein are literals. Not all of us program in assembly
     
  5. shteii01

    AAC Fanatic!

    Feb 19, 2010
    3,394
    497
Loading...