need help of programming of AT89C2051 to communicate with pc

Thread Starter

navid444

Joined May 10, 2008
2
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

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
 

hgmjr

Joined Jan 28, 2005
9,029
Rich (BB code):
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
Formatted using CODE tags

hgmjr
 

hgmjr

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

hgmjr
 

hgmjr

Joined Jan 28, 2005
9,029
Rich (BB code):
loop:
    .
    .
    .
 
Waitfordone:
   Jb P3^5, Waitfordone
   Clr P3^3
   nop     ;  Add NOP to delay
   nop     ;  Add NOP to delay
   nop     ;  Add NOP to delay
   nop     ;  Add NOP to delay
   Mov A,p1
   Acall Send
   Setb P3^3
   Ajmp Loop
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
 
Top