Reply by Bruchor September 18, 20042004-09-18
Hi!
In case the REG command, at first, you must define the port address, and
than define bits.
For example:

P2      EQU     0A0H    ; real port address

ACK	REG	P2.0	;I2C ACKNOWLEDGE
SCL	REG	P2.1	;I2C SERIAL CLOCK
SDA	REG	P2.2	;I2C SERIAL DATA

Best regards!



Reply by Bruchor September 18, 20042004-09-18
Hi! 
In case the REG command, you must previously define the Port2 address, and
than define your bits.
For example:

P2   EQU    0A0H   ; define real port address

SDA  REG    P2.0   ; at now we can define our signals
...
..

Best regards!




Reply by Neil Kurzman September 18, 20042004-09-18
First what assembler are you using.
Second try www.8052.com




Reply by Peter September 17, 20042004-09-17
"colin" <colin@edt.com.tw> wrote in message 
news:64b68ee4.0409170108.1582a7dc@posting.google.com...
>I have a problem in my program. > This program is to write in eeprom(hn58x2432) & read from it to > display > to lcd module.It is transmit by I2C. > Please help me to check my program. > > Thanks. > It have some problem when it compiled.Below is the error message. > > > LINE 11 ACK REG P2.0==============>ILLEGAL MNEMONIC > LINE 12 SCL REG P2.1==============>ILLEGAL MNEMONIC > LINE 13 SDA REG P2.2==============>ILLEGAL MNEMONIC > LINE 14 COUNTD EQU 41H ==============>ILLEGAL MNEMONIC > .... > Just like that >
It means that you have a word that your compiler doesn't understand. First make sure that there are no spaces before ACK, SCL, SDA and COUNTD otherwise the assembler will treat these as instructions (mnemonics) rather than a logical name. If that fails you should look up how to declare port bits. I have never touched an 8051 but my next guess would be that it doesn't like REG and maybe you could replace "REG" with "bit". Peter
Reply by colin September 17, 20042004-09-17
I have a problem in my program.
This program is to write in eeprom(hn58x2432) & read from it to
display
to lcd  module.It is transmit by I2C.
Please help me to check my program.

Thanks.
It have some problem when it compiled.Below is the error message.


LINE 11       ACK     REG P2.0==============>ILLEGAL MNEMONIC
LINE 12       SCL     REG P2.1==============>ILLEGAL MNEMONIC
LINE 13       SDA     REG P2.2==============>ILLEGAL MNEMONIC
LINE 14       COUNTD  EQU 41H ==============>ILLEGAL MNEMONIC
....
Just like that
===============================================================
I don't know some else bugs in it,so help me check it,please.
Thanks.
===============================================================





;=======================================================
;                MAIN PROGRAM
;=======================================================
	ORG	0000H
;=====================================================
;I2C	SET I2C MODULE PINS
;=====================================================
;P1&#28858;LCM&#36039;&#26009;&#32218;&#23560;&#29992;&#25509;&#33139;,P3&#28858;LCM&#20043;E,R/S,W/R&#29992;
;=====================================================
	ACK	REG	P2.0	;I2C ACKNOWLEDGE
	SCL	REG	P2.1	;I2C SERIAL CLOCK
	SDA	REG	P2.2	;I2C SERIAL DATA
	COUNTD	EQU	41H	;&#20498;&#25976;&#29992;&#35336;&#25976;&#22120;
	COUNTU	EQU	42H	;&#35336;&#25976;&#29992;
	ADR	EQU	43H	;I2C EEPROM ADDRESS
	DATA	EQU	44H	;I2C&#35201;&#20659;&#36664;&#30340;&#36039;&#26009;
	X	EQU	45H	;&#30028;&#38754;&#24120;&#25976;
;-------------------------------------------------------------------------------
       	MOV	SP,#5FH
      	MOV    	P2,#0EH
       	ACALL	INIT		;INITIAL LCM
	ACALL  	LINE1		;&#28216;&#27161;&#20572;&#22312;&#31532;&#19968;&#34892;&#31532;&#19968;&#20491;&#23383;
	MOV       	DPTR,#TAB1 
	;&#23559;&#36039;&#26009;&#25351;&#27161;&#26283;&#23384;&#22120;&#25351;&#21521;&#31243;&#24335;&#20839;&#36039;&#26009;&#25152;&#22312;
	ACALL   	WR_TO_ROM	;&#23559;&#36039;&#26009;&#23531;&#20837;ROM
	ACALL	RD_FR_ROM	;&#23559;ROM&#36039;&#26009;&#35712;&#20986;&#20006;&#39023;&#31034;&#26044;LCM
;===============================
OK	AJMP	OK
;===============================	
;	SUB ROUTINE
;===============================
INIT	ACALL	DLY40		;INITIAL LCM
	MOV	A,#38H		;&#35373;&#23450;LCM&#28858;8&#20301;&#20803;&#21450;2&#34892;&#39023;&#31034;,5x7
dots
	ACALL	WRINS		;&#35373;&#23450;E ENABLE
&#25226;&#25351;&#20196;&#30908;&#35373;&#23450;&#36914;&#21435;
 	MOV	A,#38H
	ACALL	WRINS
	MOV	A,#38H
	ACALL	WRINS
	MOV	A,#38H
	ACALL	WRINS

	MOV	A,#08H		;#00001000B &#28082;&#26230;&#39023;&#31034;OFF
	ACALL	WRINS
;=============================
	MOV	A,#01H		;#00000001B
&#28165;&#38500;&#28082;&#26230;&#39023;&#31034;
	ACALL	WRINS
;=============================
	MOV	A,#06H		;#00000110B
&#23531;&#20837;1BYTE,&#28216;&#27161;&#21491;&#31227;&#19988;ACC&#21152;&#19968;
	ACALL	WRINS
;=============================
	MOV	A,#0CH		;#00001100B
&#28082;&#26230;&#39023;&#31034;ON,&#19981;&#39023;&#31034;&#28216;&#27161;
	ACALL	WRINS
	RET
;\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
LINE1	MOV	A,#10000000B	;&#39023;&#31034;&#36215;&#22987;&#20301;&#22336;&#28858;&#31532;&#19968;&#34892;&#31532;&#19968;&#20491;&#23383;
	ACALL	WRINS
	RET
;=============================
LINE2	MOV	A,#11000000B	;&#39023;&#31034;&#36215;&#22987;&#20301;&#22336;&#28858;&#31532;&#20108;&#34892;&#31532;&#19968;&#20491;&#23383;
	ACALL	WRINS
	RET
;------------------------------------------------------------
;LCD  	&#25226;&#25351;&#20196;&#30908;&#35373;&#23450;&#36914;&#21435;&#30452;&#25509;&#25511;&#21046;LCD&#30340;&#34722;&#24149;&#39023;&#31034;
;------------------------------------------------------------
WRINS	MOV	P3,#00011111B	;P3&#28858;R/S, E , R/W
	NOP
	SETB	P3.5		;&#35373;&#23450;E&#28858; ENABLE
	MOV	P1,A		;&#23559;A&#20839;&#23481;&#35373;&#23450;&#36914;&#21435;
	NOP
	CLR	P3.5
	ACALL	DLY8
	RET
;------------------------------------------------------------
;LCD    	&#25226;DATA&#30908;&#35373;&#23450;&#36914;&#21435;
&#20358;&#39023;&#31034;&#20839;&#23450;&#30340;&#25991;&#23383;
;------------------------------------------------------------
WRDATA	MOV	P3,#10011111B
	NOP
	SETB	P3.5
	MOV	P1,A
	NOP
	CLR	P3.5
	ACALL	DLY16
	RET
;------------------------------------------------------------

;\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
;I2C	&#25226;&#31243;&#24335;&#20013;&#20043;&#23383;&#20803;&#30908;&#23531;&#20837;ROM&#20013;
;\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
WR_TO_ROM:
	CALL	I2C_WRITE_ADR	;&#20659;&#36664;&#30446;&#30340;ROM&#30340;&#20301;&#22336;,&#29376;&#24907;&#28858;&#23531;&#20837;
	MOV	R7,#00H		;&#25226;&#20301;&#22336;DPTR&#36215;&#30340;&#23383;&#20803;&#30908;&#36880;&#19968;&#36865;&#33267;EEPROM&#27169;&#32068;
NEXT	MOV	A,R7	  	;&#30452;&#33267;&#36935;&#21040;&#32080;&#26463;&#30908;10H&#25165;&#36820;&#22238;&#20027;&#31243;&#24335;
	MOVC	A,@A+DPTR	;DPTR&#25351;&#21040;&#31243;&#24335;&#20839;&#30340;&#36039;&#26009;&#36215;&#22987;&#20301;&#22336;
	CLR	SDA		;&#38283;&#22987;&#20659;&#36664;&#31243;&#24335;&#20839;&#30340;&#36039;&#26009;&#21040;ROM
	MOV	COUNTD,#8
	MOV	DATA,A		;&#23559;A&#30340;&#20839;&#23481;&#20659;&#33267;DATA,&#30001;DATA&#20316;&#26283;&#23384;&#22120;&#23531;&#20837;
IWA	RLC	DATA
	MOV	SDA,C
	SETB	SCL
	CLR	SCL
	DJNZ	COUNTD,IWA
	CLR	ACK
	SET	ACK	
;=======&#27298;&#26597;&#24460;&#38754;&#23383;&#20803;&#26159;&#21542;10H================================================
	CJNE	A,#10H,RD_NX	;&#35712;&#21040;10H,&#21363;&#20572;&#27490;&#35712;&#21462;&#21450;&#23531;&#20837;&#21205;&#20316;
	RET
RD_NX: 	
	INC	R7		;&#19981;&#26159;&#35712;&#21040;10H,&#21363;&#32380;&#32396;&#35712;&#21462;&#19979;&#19968;&#20491;&#23383;&#20803;R7&#20316;&#28858;&#35336;&#25976;&#22120;
	AJMP	NEXT		;R7&#20316;&#28858;&#35336;&#25976;&#22120;&#30475;&#20659;&#20837;&#22810;&#23569;&#23383;&#20803;
=========================================================================
;\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
;I2C	&#38283;&#22987;&#35712;&#20986;ROM&#20839;&#30340;&#36039;&#26009;&#20006;&#39023;&#31034;&#26044;&#34722;&#24149;
;\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
RD_FR_ROM:
	MOV	DATA,#0
	CALL	I2C_READ_ADR	;&#20659;&#36664;&#30446;&#30340;ROM&#30340;&#20301;&#22336;,&#29376;&#24907;&#28858;&#35712;&#20986;
	MOV	A,R7		;&#25226;&#20659;&#33267;ROM&#30340;&#23383;&#20803;&#30908;,&#20498;&#25976;&#36865;&#20986;&#33267;LCM&#27169;&#32068;&#20358;&#39023;&#31034;
	MOV	COUNTU,A  	;&#30001;R7&#21487;&#30475;&#20986;&#20659;&#20837;&#22810;&#23569;&#23383;&#20803;&#21040;ROM&#35041;&#38754;,&#27492;&#20540;&#20659;&#20837;COUNTU
RD_NX	CLR	SDA		;&#38283;&#22987;&#20659;&#36664;ROM&#20839;&#30340;&#36039;&#26009;&#21040;LCM
	MOV	COUNTD,#8
RFR	MOV	X,#0
	MOV	A,#0
	MOV	C,SDA		;&#24478;SDA&#38283;&#22987;&#25509;&#25910;&#36039;&#26009;
	ADDC	A,X		;&#25509;&#25910;SDA&#21152;&#21040;A&#32047;&#31309;&#22120;&#20013;
	ADD	DATA,A		;A&#20839;&#23481;&#20659;&#32102;DATA
	RL	DATA
	SETB	SCL
	CLR	SCL	
	DJNZ	COUNTD,RFR	;&#20659;&#23436;8&#20491;&#23383;&#20803;&#24460;
	CLR	ACK		;&#32102;&#19968;&#20491;&#25033;&#31572;
	SET	ACK
	MOV	A,DATA		;&#23559;&#20659;&#20837;&#30340;&#23383;&#20803;&#20659;&#33267;A&#32047;&#31309;&#22120;
	CALL	WRDATA		;&#36865;&#20986;&#23383;&#20803;&#35731;LCM&#39023;&#31034;
	DJNZ	COUNTU,RD_NX	;&#25345;&#32396;&#35712;&#20986;&#19979;&#19968;&#20491;&#23383;&#20803;,&#30452;&#21040;&#25152;&#26377;&#23383;&#20803;&#35712;&#20986;
 	RET

;===========================================================	

;\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
;I2C	&#35373;&#23450;&#25351;&#23450;
ROM&#30340;&#20301;&#22336;&#20006;&#35373;&#23450;&#28858;&#23531;&#20837;&#29376;&#24907;
;\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
;===========================================================
I2C_WRITE_ADR:
	CLR	SDA
	SET	ACK
	MOV	COUNTD,#8
	MOV	ADR,#11100010B	;&#35373;&#23450;&#23531;&#20837;&#20043;ROM&#21450;&#20854;&#20301;&#22336;,&#29376;&#24907;&#28858;&#23531;&#20837;
	CALL	I2C_START
IWA	RLC	ADR
	MOV	SDA,C
	SETB	SCL		;&#36039;&#26009;&#20659;&#36664;&#23436;SCL&#38920;&#28858;&#39640;&#28310;&#20301;
	CLR	SCL		;&#36039;&#26009;&#20659;&#36664;&#26178;SCL&#38920;&#28858;&#20302;&#28310;&#20301;
	DJNZ	COUNTD,IWA
	CLR	ACK	
	SET	ACK
	RET	
;===========================================================
;\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
;I2C	&#35373;&#23450;&#25351;&#23450;
ROM&#30340;&#20301;&#22336;&#20006;&#35373;&#23450;&#28858;&#35712;&#20986;&#29376;&#24907;
;\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
;===========================================================
I2C_READ_ADR:
	CLR	SDA
	SET	ACK
	MOV	COUNTD,#8
	MOV	ADR,#11100011B	;&#35373;&#23450;&#23531;&#20837;&#20043;ROM&#21450;&#20854;&#20301;&#22336;,&#29376;&#24907;&#28858;&#23531;&#20837;
	CALL	I2C_START
IRA	RLC	ADR
	MOV	SDA,C
	SETB	SCL		;&#36039;&#26009;&#20659;&#36664;&#23436;SCL&#38920;&#28858;&#39640;&#28310;&#20301;
	CLR	SCL		;&#36039;&#26009;&#20659;&#36664;&#26178;SCL&#38920;&#28858;&#20302;&#28310;&#20301;
	DJNZ	COUNTD,IRA
	CLR	ACK
	SET	ACK	
	RET	
;===========================================================
;===============================
; I2C	I2C START CONDITION
;===============================
I2C_START:
	SETB	SCL
	SETB	SDL
	CLR	SDL	
	CLR	SCL	;&#36039;&#26009;&#20659;&#36664;&#26178;SCL&#38920;&#28858;&#20302;&#28310;&#20301;
	RET
;===============================
;I2C	 I2C STOP CONDITION	
;===============================
I2C_STOP:
	SETB	SCL	
	CLR	SDL	
	SETB	SDL
	CLR	SCL
	RET
;==============================
;I2C	I2C INPUT DATA STATE
;==============================
;==============================
; 
;==============================	
;++++++++++++++++++++++++++++++++
;DELAY 40ms
;++++++++++++++++++++++++++++++++
DLY40	MOV	R6,#100
DL0	MOV	R7,#200
	DJNZ	R7,$
	DJNZ	R6,DL
	RET
;++++++++++++++++++++++++++++++++
;DELAY 8ms
;++++++++++++++++++++++++++++++++
DLY8	MOV	R6,#20
DL1	MOV	R7,#200
	DJNZ	R7,$
	DJNZ	R6,DL1
	RET
;++++++++++++++++++++++++++++++++
;DELAY 160us
;++++++++++++++++++++++++++++++++
DLY16	MOV	R6,#80
	DJNZ	R6,$
	RET
;++++++++++++++++++++++++++++++++

;==============================
;====       STORE DATA       =========
;==============================
TAB1	DB	"4444"
	DB	"4444"
	DB	10H
TAB2	DB	"abcdABCD"
	DB	10H
	END
;======================================================================