need help of programming of AT89C2051 to communicate with pc

Discussion in 'Embedded Systems and Microcontrollers' started by navid444, May 10, 2008.

  1. navid444

    Thread Starter New Member

    May 10, 2008
    2
    0
    hi i m trying to get data from light sensor and then ADC804 & MAX232 to communicate with pc but my circiut is not working. I thinks its erroe in the program.
    Can any body help me plzzzzzzzzzzzzzzzzzzzzzzz.here is programe & circiut diagrame [​IMG]
    PROGRAME


    org 0H
    AJMP START



    ORG 03H
    RETI

    ORG 0BH

    RETI

    ORG 13H

    RETI

    ORG 1BH

    RETI

    ORG 23H

    RETI

    ORG 25H


    INITIALIZE :

    MOV TH1, #0FDH

    MOV SCON, #01010000B

    MOV TMOD, #00100001B

    MOV TCON, #01000000B

    RET

    SEND:
    CLR T1
    MOV SBUF, A
    WAIT:
    JNB T1, WAIT
    RET

    START:
    MOV SP, #030H

    ACALL INITIALIZE

    ORL P1, #0FFH

    SETB P3^5

    LOOP:
    CLR P3^4

    SETB P3^3

    SETB P3^4
    WAITFORDONE:

    JB P3^5, WAITFORDONE
    CLR P3^3
    MOV A,P1
    ACALL SEND
    SETB P3^3
    AJMP LOOP
    END
     
  2. hgmjr

    Moderator

    Jan 28, 2005
    9,030
    214
    Code ( (Unknown Language)):
    1.  
    2. PROGRAME
    3.  
    4.  
    5. org 0H
    6. AJMP START
    7.  
    8. ORG 03H
    9. RETI
    10.  
    11. ORG 0BH
    12. RETI
    13.  
    14. ORG 13H
    15. RETI
    16.  
    17. ORG 1BH
    18. RETI
    19.  
    20. ORG 23H
    21. RETI
    22.  
    23. ORG 25H
    24.  
    25. INITIALIZE :
    26.  
    27.      MOV TH1, #0FDH
    28.      MOV SCON, #01010000B
    29.      MOV TMOD, #00100001B
    30.      MOV TCON, #01000000B
    31.  
    32. RET
    33.  
    34. SEND:
    35.      CLR T1
    36.      MOV SBUF, A
    37. WAIT:
    38.      JNB T1, WAIT
    39. RET
    40.  
    41. START:
    42.      MOV SP, #030H
    43.      ACALL INITIALIZE
    44.      ORL P1, #0FFH
    45.      SETB P3^5
    46.  
    47. LOOP:
    48.      CLR P3^4
    49.      SETB P3^3
    50.      SETB P3^4
    51.  
    52. WAITFORDONE:
    53.      JB P3^5, WAITFORDONE
    54.      CLR P3^3
    55.      MOV A,P1
    56.      ACALL SEND
    57.      SETB P3^3
    58. AJMP LOOP
    59. END
    60.  
    Formatted using CODE tags

    hgmjr
     
  3. hgmjr

    Moderator

    Jan 28, 2005
    9,030
    214
    How far have you been able to get with your testing?

    hgmjr
     
  4. hgmjr

    Moderator

    Jan 28, 2005
    9,030
    214
    Are you using hyper-terminal on you PC to display the results of the serial data received from the 89C2051?

    hgmjr
     
  5. hgmjr

    Moderator

    Jan 28, 2005
    9,030
    214
    Code ( (Unknown Language)):
    1.  
    2. loop:
    3.     [B].[/B]
    4.     [B].[/B]
    5.     [B].[/B]
    6.  
    7. Waitfordone:
    8.    Jb P3^5, Waitfordone
    9.    Clr P3^3
    10.    nop     ;  Add NOP to delay
    11.    nop     ;  Add NOP to delay
    12.    nop     ;  Add NOP to delay
    13.    nop     ;  Add NOP to delay
    14.    Mov A,p1
    15.    Acall Send
    16.    Setb P3^3
    17.    Ajmp Loop
    18.  
    I did a bit of investigating and the one thing that looked a bit suspicious is the absense of any delay from the time the READ line goes low to the time the output of the ADC is read into the 2051's "A" register.

    I recommend you stuff four NOP instructions in between the high-to-low transition of the ADC's READ control and the actual reading of the ADC's 8-bit output value. This should give the ADC's digital output value time to settle before you read the value into the 2051's "A" register.

    Let me know if this clears things up for you.

    hgmjr
     
Loading...