2 LCD in serial using interrupts with 8051

Discussion in 'Embedded Systems and Microcontrollers' started by PY01A0080, Mar 18, 2013.

  1. PY01A0080

    Thread Starter Member

    Mar 7, 2013
    42
    3
    Hi,
    i'm trying something very hard for me, i want to connect two 8051 and each one with one LCD (16X2) in serial using Interrupts.

    So after learning interrupts with books, i tried to do something like this,
    i created two projects in keil and one file in Proteus with the design mentioned above.

    so for Transmission:
    Code ( (Unknown Language)):
    1. org 0000h
    2. ljmp main
    3. main:
    4. mov tmod,#29h
    5. mov th1,#0fdh
    6. setb tr1;
    7. mov scon,#50h
    8.  
    9. mov p2,a
    10. mov sbuf,a
    11. jnb ti,$
    12. clr ti
    13. ret
    14.  
    15. mov a,#38h;
    16. lcall led_command
    17. lcall delay
    18. mov a,#0eh;
    19. lcall led_command
    20. lcall delay
    21. mov a,#01h; clear screen
    22. lcall led_command
    23. lcall delay
    24. mov a,#06h; auto-increment
    25. lcall led_command
    26. lcall delay
    27. mov a,#80h; cursor position at 1
    28. lcall led_command
    29. lcall delay
    30. mov a,#'P'
    31. lcall led_data; send P
    32. lcall delay
    33. mov a,#'A'; send A
    34. lcall led_data
    35. lcall delay
    36. Loop: sjmp Loop
    37. led_data:
    38. setb p0.0; RS
    39. clr p0.1; RW
    40. setb p0.2; E
    41. mov p2,a
    42. clr p0.2
    43. ret
    44.  
    45. led_command:
    46. clr p0.0; RS
    47. clr p0.1; RW
    48. setb p0.2; E
    49. mov p2,a
    50. lcall delay
    51. clr p0.2; E
    52. ret
    53. delay:
    54. mov r4,#04h
    55. mov r5,#080h
    56. mov r6,#0ffh
    57. djnz r6,$
    58. djnz r5,$-2
    59. djnz r4,$-4
    60. ret
    61. end
    and the second file for Reception:
    Code ( (Unknown Language)):
    1.  org 0023h
    2. ljmp main
    3. org 0023h
    4. mov a,sbuf
    5. mov p2,a
    6. clr ri
    7. reti
    8.  
    9. main:
    10. lcall led_command
    11. lcall led_data
    12.                                      
    13. mov tmod,#20h            
    14. mov th1,#0fdh            
    15. mov scon,#50h            
    16. setb tr1
    17. mov ie,#90h
    18. sjmp $
    19. end
    so when i try this, nothing's happen but i can see some data going very fastly in the virual terminal.

    do i have to add the same lines for sending data and command in the reception file? or anything else to do here?
    Thank you for your help
    PY01A0080
     
  2. Ian Rogers

    Member

    Dec 12, 2012
    158
    29
    Have you duplicated the LED routines in the second chip???
     
  3. PY01A0080

    Thread Starter Member

    Mar 7, 2013
    42
    3
    Yes , i added these lines:
    in the reception file.

    Code ( (Unknown Language)):
    1. main:
    2. mov a,#38h; Initialization of lcd screen 2X16
    3. lcall led_command
    4. lcall delay
    5. mov a,#0eh; Display on, curson on, cursor blinking OFF
    6. lcall led_command
    7. lcall delay
    8. mov a,#01h; clear screen
    9. lcall led_command
    10. lcall delay
    11. mov a,#06h; auto-increment
    12. lcall led_command
    13. lcall delay
    14. mov a,#80h; cursor position at 1
    15. lcall led_command
    16. lcall delay
    17.  
    18. mov a,#'P'
    19. lcall led_data; send P
    20. lcall delay
    21. mov a,#'A'; send A
    22. lcall led_data
    23. lcall delay
    24.  
    25. led_data:
    26. setb p0.0; RS
    27. clr p0.1; RW
    28. setb p0.2; E
    29. mov p2,a
    30. clr p0.2
    31. ret
    32.  
    33. led_command:
    34. clr p0.0; RS
    35. clr p0.1; RW
    36. setb p0.2; E
    37. mov p2,a
    38. lcall delay
    39. clr p0.2; E
    40. ret
    41.                                      
    42. mov tmod,#20h            
    43. mov th1,#0fdh            
    44. mov scon,#50h            
    45. setb tr1
    46. mov ie,#90h
    47. sjmp $
    48. delay:
    49. mov r4,#03h ; use 04h for 1 second delay
    50. mov r5,#080h
    51. mov r6,#0ffh
    52. djnz r6,$
    53. djnz r5,$-2
    54. djnz r4,$-4
    55. ret
     
  4. Ian Rogers

    Member

    Dec 12, 2012
    158
    29
    AND!!! Is it now working???
     
  5. PY01A0080

    Thread Starter Member

    Mar 7, 2013
    42
    3
    Yes it's working now.
    so here's the correction to the Transmission file:
    Code ( (Unknown Language)):
    1. transmit:
    2. mov sbuf,a
    3. jnb ti,$
    4. clr ti
    5. lcall delay
    6. ret
    and in the Reception file:
    Code ( (Unknown Language)):
    1. mov a,sbuf
    2. clr ri
    3. lcall led_data
    4. reti
    after that it works fine
    sorry for the late.
     
Loading...