Applications Information
10-18
MC68307 USER’S MANUAL
MOTOROLA
ORG
$10000
; Random location for assembly
AND.L
#$FFFFFEFF,SCR
; Clear SCR bit 8, M-bus CLock Active
MOVE.B
#$40,PIVR
; Vector = #$40, Vector @ address $100
OR.W
#$000D,PICR
; M-bus Interrupt level = 5
MOVE.L
#MBUSHAN,MBUSVEC ; Set up M-bus Interrupt Handler
OR.W
#$0003,PBCNT
; Enable M-bus Lines
BSR
INIT_MBM
; Initialize M-bus as master
* WRITE TO SLAVE 68307 M-bus
* Write Chip Address, and Two bytes of data
START
BSR
MBBUSY
; Poll the M-bus, wait till bus free
MOVE.B
#0,V_DRXCNT
; Data RECEIVE COUNT
MOVE.B
#ATXCNT,V_ATXCNT ; Address TRANSMIT COUNT
MOVE.B
#DTXCNT,V_DTXCNT ; Data TRANSMIT COUNT
MOVE.B
#1,V_WRITE
; Set Write to slave var = TRUE
MOVE.B
#S307_AD,V_CHIPAD; Slave 68307 M-bus receiver Addr.
MOVE.L
#S307_DATA,A0
; Pointer to stored data for transfer
BSRWRITE1
; Send out the Chip Address
* READ FROM SLAVE 68307 M-bus
* Write Chip Address, and READ Two bytes of data
BSR
MBBUSY
; Poll the M-bus, wait till bus free
MOVE.B
#DRXCNT,V_DRXCNT ; Data RECEIVE COUNT
MOVE.B
#ATXCNT,V_ATXCNT ; Address TRANSMIT COUNT
MOVE.B
#0,V_DTXCNT
; Data TRANSMIT COUNT
MOVE.B
#0,V_WRITE
; Set Write to slave var = FALSE
MOVE.B
#S307_AD,D6
; Alter chip address lsb for
OR.B
#$01,D6
; slave transmit and
MOVE.B
D6,V_CHIPAD
; write to chip address variable
MOVE.L
#S307_DATA,A0
; Pointer to data for memory 1
BSR
WRITE1
; Send out the Chip Address
*Test Complete
BSR
MBBUSY
; Poll the M-bus, wait till bus free
FOREVER
BRA
FOREVER
; Test complete & passed, loop forever
*––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
*
M-Bus Setup/Initialization
*––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
INIT_MB
MMOVE.W #$2700,SR
; Disable interrupts – set to level 7
MOVE.B
#0,MBSR
; Clear interrupt pend, arbitr. lost
MOVE.B
#$0C,MFDR
; Set frequency
MOVE.B
#$00,MBCR
; Disable and reset M-bus
MOVE.B
#$80,MBCR
; Enable M-bus
RTS
* NOTE - By not writing MADR, the 68307 M-bus slave address = 0
*––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
*
Poll the M-bus BUSY
*––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––