Applications Information
10-22
MC68307 USER’S MANUAL
MOTOROLA
OR.W
#$0003,PBCNT
; Enable M-bus Lines
BSR
INIT_MBS
; Initialize M-bus as slave
FINISH
BRA
FINISH
; Loop forever
*––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
*
M-Bus Setup/Initialization
*––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
INIT_MBS
MOVE.W
#$2700,SR
; Disable interrupts – set to level 7
MOVE.B
#0,MBSR
; Clear interrupt pend, arbitr. lost
MOVE.B
#$10,MFDR
; Set frequency
MOVE.B
#S307_AD,MADR
; Set M-bus slave address
MOVE.B
#$00,MBCR
; Disable and reset M-bus
OR.B
#$C0,MBCR
; Enable M-bus, Ints, TXAK
MOVE.W
#$2300,SR
; Enable INTS by setting to level 3
RTS
*––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
*
Poll the M-bus BUSY
*––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
MBBUSY
BTST
#5,MBSR
; Test MBB bit,
BNE
MBBUSY
; and wait until it is clear
RTS
*––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
*
Post Byte Transmission/Reception Software Response
*––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
ORG
MBUSHAN
; Start of Interrupt Handler
ISR
BCLR
#1,MBSR
; Clear the MIF Flag
MOVE.L
D0,-(A7)
; Push D0 Register to Stack
MOVE.L
D1,-(A7)
; Push D1 Register to Stack
MOVE.L
#0,D0
; Clear general data reg
MOVE.L
#0,D1
; Clear general data reg
* Interrupt Counter
ADDQ.L
#1,D3
; (Not used, simply monitor)
BTST
#5,MBCR
; Check the MSTA Flag
BEQ
SLAVE
; Branch if Slave mode
MASTER
BRA
MASTER
; Master not implemented, so error
*––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
SLAVE
MOVE.B
MBSR,D6
; Read MBSR
BTST.B
#6,D6
; Is it slave address byte?
BEQ
SLAVE_DATA
; If not, then data
*––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
*
Addressed as Slave
*––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
SLAVE_ADD
BTST
#2,D6
; Read SRW to verify slave Tx or Rx
BEQ
INIT_SRX
; If Rx, initialize Slave receive count
INIT_STX
OR.B
#$10,MBCR
; Set transmit mode
MOVE.L
#DATABUF,A0
; Pointer to data storage buffer
MOVE.B
(A0)+,MBDR
; First data byte transmit