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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
09/10/13 21:58
Read: times


 
#190023 - LCD I2C Using PCF8574
Responding to: ???'s previous message
Thanks for you help.

The 1st site are in french
The 2nd site use C for Arduino board.

I'm loocking for code in ASM to 89s52.

I'm study every night from 21hs to 24hs and read all datasheets

I'm try de code below


SDAPin BIT P0.0 ;I2C serial data line.
SCLPin BIT P0.1 ;I2C serial clock line.
LED BIT ACC.4

I2CIO EQU 04Eh ;Slave address for PCF8574 I/O expandor.
LCD_EN EQU 000
LCD_RW EQU 000
LCD_RS EQU 000



; Data storage locations

BitCnt DATA 008h ;Bit counter for I2C routines.
ByteCnt DATA 009h ;Byte counter for I2C routines.
SlvAdr DATA 0A0h ;Slave address for I2C routines.

XmtDat DATA 010h ;I2C transmit buffer, 8 bytes max.
RcvDat DATA 018h ;I2C receive buffer, 8 bytes max.
AltRcv DATA 020h ;Alternate I2C receive buffer, 8 bytes max.

Flags DATA 028h ;Location for bit flags
Temp DATA 029H
NoAck BIT Flags.0 ;I2C no acknowledge flag.
BusFault BIT Flags.1 ;I2C bus fault flag.
I2CBusy BIT Flags.2 ;I2C busy flag.


ORG 0000H
JMP START

ORG 0030H

START:
MOV IE,#0
MOV SP,#50H
SETB LED
CALL busylcd
CALL busylcd
CALL busylcd
CALL busylcd
CALL busylcd
CALL busylcd
CALL busylcd
CALL busylcd

MOV DPTR,#RESET_LCD
CALL LCD_CMD
MOV DPTR,#SETUP_LCD
CALL LCD_CMD
MOV A,#087H
CALL SEND_CMD


MOV A,#'A'
CALL SEND_DATA


JMP $




SEND_DATA:

CALL BUSYLCD ;LCD BUSY?
PUSH ACC
CALL SEND_DATA1
POP ACC

SWAP A
SEND_DATA1:
SETB LED
ANL A, #0F8h ;XXXX X000 [E=0 RW=0 RS=0].
ORL A, #01h ;XXXX XXX1 [RS = 1].
CALL I2C_DADO ;WRITE ACC TO PCF8574 LCD.
ORL A, #05h ;XXXX X1XX [E = 1].
CALL I2C_DADO ;WRITE ACC TO PCF8574 LCD..
ANL A, #0F9h ;XXXX X0X1 [E = 0 RS=1].
CALL I2C_DADO ;WRITE ACC TO PCF8574 LCD.
CALL busylcd
RET




SEND_CMD:
PUSH ACC
CALL BUSYLCD ;LCD BUSY?

CALL SEND_CMD1 ;HI NIBLE
POP ACC
SWAP A ;LO NIBLE.
SEND_CMD1:
ANL A, #0FCh ; E=0 RW=0 RS=0 SEND INSTRUCTION
CALL I2C_DADO ;WRITE ACC TO PCF8574 LCD.
ORL A, #08h ;E = 1.
CALL I2C_DADO ;WRITE ACC TO PCF8574 LCD..
ANL A, #0FCh ;E = 0.
CALL I2C_DADO ;WRITE ACC TO PCF8574 LCD.
CALL busylcd
RET


I2C_DADO:
PUSH ACC
MOV XMTDAT,A
MOV SlvAdr,#I2CIO ;Write data to PCF8574 I/O expandor.
MOV R0,#XmtDat ;Start of data.
MOV ByteCnt,#1 ;Send one data byte.
CALL SendData
POP ACC
RET



LCD_CMD:
PUSH ACC
LOOP_LCD_CMD:
CLR A
MOVC A,@A+DPTR
JZ END_LCD_CMD
CALL SEND_CMD
INC DPTR
JMP LOOP_LCD_CMD
END_LCD_CMD:
POP ACC
RET

;
busylcd:
; MOV R1,#255
XT:
MOV R0,#255
DJNZ R0,$

;ACC
RET

RESET_LCD:
DB 30h, 30h, 30h, 20h, 00h
SETUP_LCD:
DB 28h,01h,0Ch,06h,00h

$INCLUDE(I2C.ASM)
RET



;***************************************************************************
; ROTINA ascii
; Entrada:
; Saida:
; Alteracao:
; Subrotinas:
; OBS.:
;***************************************************************************
WR_ASCII:
PUSH ACC
SWAP A
CALL TX_ASCII
POP ACC
CALL TX_ASCII
RET

TX_ASCII:
ANL A,#00FH
CJGT A,#9,ADD37
ADD A,#30H
CALL SEND_DATA
RET
ADD37:
ADD A,#37H
CALL SEND_DATA
RET
END

List of 9 messages in thread
TopicAuthorDate
LCD I2C Using PCF8574            01/01/70 00:00      
   it will cost you            01/01/70 00:00      
      LCD I2C Using PCF8574            01/01/70 00:00      
         Only mercenary help for money!            01/01/70 00:00      
         What have you done so far            01/01/70 00:00      
   irrelevant            01/01/70 00:00      
   did you really?            01/01/70 00:00      
      LCD I2C Using PCF8574            01/01/70 00:00      
         What works, and what does not ?            01/01/70 00:00      

Back to Subject List