Philips Semiconductors
Product data
P83C654X2/P87C654X2
80C51 8-bit microcontroller family
16 kB OTP/ROM,
256B RAM, low voltage (2.7 to 5.5 V), low power, high speed
(30/33 MHz)
2004 Apr 20
53
!********************************************************************************************************
! INITIALIZATION ROUTINE
! Example to initialize IIC Interface as slave receiver or slave transmitter and
! start a MASTER TRANSMIT or a MASTER RECEIVE function. 4 bytes will be transmitted or received.
!********************************************************************************************************
.sect
strt
.base
0x00
ajmp INIT
0000
4100
! RESET
.sect
.base
INIT:
initial
0x200
0200
75DB31
mov
S1ADR,#OWNSLA
! Load own SLA + enable
! general call recognition
! P1.6 High level.
! P1.7 High level.
0203
0205
0207
020A
020D
020F
D296
D297
755001
43A8A0
C2BD
75D8C5
setb
setb
mov
orl
clr
mov
P1(6)
P1(7)
HADD,#PAG1
IEN0,#ENSI01
SI01HP
S1CON, #ENS1_NOTSTA_NOTSTO_NOTSI_AA_CR0
! Enable SI01 interrupt
! SI01 interrupt low priority
! Initialize SLV funct.
!********************************************************************************************************
!– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –
! START MASTER TRANSMIT FUNCTION
!– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –
0212
0215
0218
755204
7551C0
D2DD
mov
mov
setb
NUMBYTMST,#0x4
SLA,#SLAW
STA
! Transmit 4 bytes.
! SLA+W, Transmit funct.
! set STA in S1CON
!– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –
! START MASTER RECEIVE FUNCTION
!– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –
mov
NUMBYTMST,#0x4
mov
SLA,#SLAR
setb
STA
021A
021D
0220
755204
7551C1
D2DD
! Receive 4 bytes.
! SLA+R, Receive funct.
! set STA in S1CON
!********************************************************************************************************
! SI01 INTERRUPT ROUTINE
!********************************************************************************************************
.sect
intvec
.base
0x00
! SI01 interrupt vector
! S1STA and HADD are pushed onto the stack.
! They serve as return address for the RET instruction.
! The RET instruction sets the Program Counter to address HADD,
! S1STA and jumps to the right subroutine.
002B
002D
002F
0031
C0D0
C0D9
C050
22
push psw
push S1STA
push HADD
ret
! save psw
! JMP to address HADD,S1STA.
!– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –
! STATE
: 00, Bus error.
! ACTION
: Enter not addressed SLV mode and release bus. STO reset.
!– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –
.sect
st0
.base
0x100
0100
75D8D5
mov
S1CON,#ENS1_NOTSTA_STO_NOTSI_AA_CR0 ! clr SI
! set STO,AA
0103
0105
D0D0
32
pop
reti
psw