Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
05/16/00 19:49
Read: times


 
#2700 - RE: help with code?
Lance,

I liked your coding but you have done some mistakes. Instead of MOV SBUF,#CHX you have to write MOV SBUF,CHX and so on for CHY and CHZ. Make sure Cy=0 before operations SUBB A,TCHi.

Seems the following code will work correct.

Regards,

George

CHKSUM DATA 033h ; check sum stored in address 33 hex
TCHX DATA 034H ; temporary storage of offset values plus
TCHY DATA 035H
TCHZ DATA 036H
ORG 00000H ; Execution Starts Here
MOV 0EFH,#0C0H ; set adccon1 register to enable A/D conversion
SETB F0 ; flag for first time through loop set
MOV TMOD,#20h ; 8bit timer auto-reload mode
MOV PCON,#00h ;make sure that PCON.7 is not set for double baud rate
MOV TH1,#250 ; 4800 baud rate
MOV SCON,#042h ; 8 bit UART mode
SETB TR1 ; start timer for serial communication
MOV CHKSUM,#000H
LOOP1: MOV R0,#010H
MOV R1,#TCHX
MOV R2,#003H
LOOP2: MOV 0D8H,R0
JB 0D8H.4,$ ; wait for A/D conversion
MOV A,0D9H ; store result of conversion
JNB F0,NOFIRST
MOV @R1,A
JMP TORS
NOFIRST: CLR C
SUBB A,@R1
ADD A,#080H
TORS: JNB TI,TORS
CLR TI
MOV SBUF,A
ADD A,CHKSUM
MOV CHKSUM,A
INC R0
INC R1
DJNZ R2,LOOP2
CLR F0
JMP LOOP1
END


List of 5 messages in thread
TopicAuthorDate
help with code?            01/01/70 00:00      
RE: help with code?            01/01/70 00:00      
RE: help with code?            01/01/70 00:00      
RE: help with code?            01/01/70 00:00      
RE: help with code?            01/01/70 00:00      

Back to Subject List