📄 ca745.asm
字号:
CLR l_byte
CLR yu
BC STATUS,C
MM:
RLC div_l
RLC yu
MOV A,b_div
SUB A,yu
JBC STATUS,C
MOV yu,A
RLC l_byte
DJZ temp
JMP MM
ret
;***************************************************
;INITIALIZE THE MCU
;WRITE BY MARK.PENG
;2003-12-14
;***************************************************
LCD_Display: RET
BC P5,SCE
BC P5,SCK
call delay_2us
BS P5,sda
call delay_2us
BS P5,SCK
call delay_4us
MOV A,@0x40
call _SPI_Write
MOV A,@0x04
MOV count,a
MOV A,@A1
MOV INDF,A
lcd_loop:
MOV A,INDF
CALL LCD_DATA
call _SPI_Write
INC FSR
DJZ count
JMP lcd_loop
BS P5,SCE
CALL delay_2us
BS P5,SCK
BS P5,SDA
RET
;***************************************************
;INITIALIZE THE MCU
;WRITE BY MARK.PENG
;2003-12-14
;***************************************************
_SPI_Write:
MOV TEMP,A
MOV A,@0x08
MOV count,a
LOOP1:
BC P5,SCK
call delay_2us
RLC TEMP
JBC STATUS,C
BS P5,sda
JBS STATUS,C
BC P5,sda
call delay_2us
BS P5,SCK
call delay_4us
DJZ count
JMP LOOP1
RET
;**********************************************************************************
;
;
;**********************************************************************************
rf_frequ_data:
CLR AA1
CLR AA0
MOV A,@0x20
MOV TEMP,A
MOV A,@8
MOV count,A
QQ:
RRC TEMP
JBC STATUS,C
CALL ADDMULTIPLY
RRC AA1
RRC AA0
DJZ count
JMP QQ
MOV A,@0X6A
ADD AA0,A
MOV A,@0X6D
JBC STATUS,C
ADD A,@1
ADD AA1,A
MOV A,@0XD2
MOV device_addr,A
MOV A,AA0
MOV word_addr,A
MOV A,AA1
MOV TXBUF,A
CALL _I2C_Write
RET
ADDMULTIPLY:
MOV A,rf_frequ
ADD AA1,A
RET
;*****************************************************************
;
;
;*****************************************************************
_I2C_Write: ret
SDA_O
BS P6,_sda
call delay_10us
BS P6,_scl
call delay_10us
BC P6,_sda
call delay_10us
MOV A,@0x03
MOV count1,a
write_byte_cyc:
BC P6,_scl
SDA_O
BC P6,_sda
MOV A,@0x08
MOV count,a
MOV A,@device_addr
MOV INDF,A
write_bit_cyc:
BC P6,_scl
call delay_4us
RLC INDF
JBC STATUS,C
BS P6,_sda
JBS STATUS,C
BC P6,_sda
call delay_4us
BS P6,_scl
call delay_6us
DJZ count
JMP write_bit_cyc
write_byte_ack:
BC P6,_scl
SDA_I
call delay_6us
BS P6,_scl
call delay_3us
JBC P6,_sda
JMP _I2C_Write ;write_eeprom
call delay_4us
write_byte_end:
INC FSR
DJZ count1
JMP write_byte_cyc
write_eeprom_end:
BC P6,_scl
SDA_O
BC P6,_sda
call delay_6us
BS P6,_scl
call delay_10us ;6us
BS P6,_sda
call delay_10us
ret
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;read and write the eeprom program
;write by ProBoy
;2003-7-28
;*****************************************************************************
_I2C_Read:
SDA_O ;START
BS P6,_sda
call delay_10us
BS P6,_scl
call delay_10us
BC P6,_sda
call delay_10us
MOV A,@0x02
MOV count1,a
write_byte_cyc1:
BC P6,_scl
SDA_O
BC P6,_sda
MOV A,@0x08
MOV count,a
MOV A,@device_addr
MOV INDF,A
write_bit_cyc1:
BC P6,_scl
call delay_4us
RLC INDF
JBC STATUS,C
BS P6,_sda
JBS STATUS,C
BC P6,_sda
call delay_4us
BS P6,_scl
call delay_6us
DJZ count
JMP write_bit_cyc1
write_byte_ack1:
BC P6,_scl
SDA_I
call delay_6us
BS P6,_scl
call delay_3us
JBC P6,_sda
JMP _I2C_Read
call delay_4us
write_byte_end1:
INC FSR
DJZ count1
JMP write_byte_cyc1
BC P6,_scl
call delay_5us
SDA_O ;START
BS P6,_sda
call delay_10us
BS P6,_scl
call delay_10us
BC P6,_sda
call delay_10us
MOV a,@0x01 ;Read SLAVE ADDRESS
OR a,device_addr
MOV temp,a
MOV a,@0x08
MOV count,a
device_bit_cyc1:
BC P6,_scl
call delay_4us
RLC temp
JBC STATUS,C
BS P6,_sda
JBS STATUS,C
BC P6,_sda
call delay_4us
BS P6,_scl
call delay_6us
DJZ count
JMP device_bit_cyc1
BC P6,_scl
SDA_I
call delay_6us
BS P6,_scl
call delay_5us
JBC P6,_sda
JMP _I2C_Read
call delay_5us
CLR temp
MOV a,@0x08
MOV count,a
bit_cyc:
BC P6,_scl
call delay_10us
BS P6,_scl
call delay_5us
JBC P6,_sda
BS STATUS,C
JBS P6,_sda
BC STATUS,C
RLC temp
call delay_2us
DJZ count
JMP bit_cyc
MOV a,temp
MOV RXBUF,a
read_eeprom_end: ;STOP
BC P6,_scl
SDA_O
BC P6,_sda
call delay_6us
BS P6,_scl
call delay_10us
BS P6,_sda
call delay_10us
ret
;*****************************************************************
;used: the LCD Display Table
;reg:
;wrt: ProBoy
;date: 2001.07.03
;*****************************************************************
LCD_DATA:
ADD PC,A
RETL 0x7b ;0
RETL 0x7b ;1
RETL 0x1c ;2
RETL 0x7b ;3
RETL 0x7b ;4
RETL 0x1c ;5
RETL 0x7b ;6
RETL 0x7b ;7
RETL 0x1c ;8
RETL 0x1c ;9
;*****************************************************************
;used: the delay for key
;reg:
;wrt: ProBoy
;date: 2001.07.03
;*****************************************************************
delay_20ms:
MOV A,@0XFF
MOV COUNT,A
LOOP:
CALL delay_6us
DJZ COUNT
JMP LOOP
RET
delay_10us:
JMP $+1
JMP $+1
JMP $+1
JMP $+1
delay_6us:
JMP $+1
JMP $+1
delay_5us:
JMP $+1
JMP $+1
delay_4us:
JMP $+1
JMP $+1
delay_3us:
JMP $+1
JMP $+1
delay_2us:
JMP $+1
ret
;----------------------------------------
END
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -