home *** CD-ROM | disk | FTP | other *** search
/ World of A1200 / World_Of_A1200.iso / programs / develop / hc11dev / scixirq / talkeex2.asc < prev    next >
Text File  |  1995-02-27  |  8KB  |  197 lines

  1. *************************** TALKEEX2.ASC 4/2/89 **************************
  2. *   Written by R.Soja, Motorola, East Kilbride                           *
  3. *   Motorola Copyright 1989                                              *
  4. *   MCU resident, Interrupt driven Communication routines for 68HC11     *
  5. *   monitor. Provides low level memory and stack read/write operations.  *
  6. *   Works with Host user interface program PCBUG11.EXE.                  *
  7. *                                                                        *
  8. *   This talker uses XIRQ (connected to SCI RX)                          *
  9. *   --------------------------------------------                         *
  10. *                                                                        *
  11. * N.B. TALKEEX2.ASC is designed to work with the 68HC811A2/E2 MCU,       *
  12. *      executing from internal EEPROM addresses $FF00-$FFFF, and         *
  13. *      communicating with PCBUG11 at a rate of 38.4K baud.               *
  14. *      TALKEEX2 must have been previously downloaded in some manner, for *
  15. *      instance using PCBUG11 BOOTA2 option, and EEPROM & LOADS commands.*
  16. *      TALKEEX2 is designed to run with the 68HC811A2 in normal single   *
  17. *      chip or expanded mode.                                            *
  18. *      On startup PCBUG11 reads the file TALKEEX2.MAP.                   *
  19. *
  20. * CONSTANTS
  21. TALKBASE  equ $FF00
  22. TALKVECT  equ $FFD6       Start of normal vector jump table.
  23. STACK     equ $00FF
  24. REGBASE   equ $1000
  25. *
  26. JSCI      equ $00C4
  27. JXIRQ     equ $00F1
  28. JSWI      equ $00F4
  29. JILLOP    equ $00F7
  30. JCOP      equ $00FA
  31. JMPEXT    equ $7E         Mnemonic for jump extended instruction
  32. BRKCODE   equ $4A         Break point signal code to host.
  33. BRKACK    equ $B5         Break point acknowledge code from host.
  34. *
  35. * REGISTERS
  36. BAUD      equ $2B
  37. SCCR1     equ $2C
  38. SCCR2     equ $2D
  39. SCSR      equ $2E
  40. SCDR      equ $2F
  41. BPROT     equ $35
  42. *
  43. RDRF      equ $20
  44. TDRE      equ $80
  45. OR        equ $08
  46. FE        equ $02
  47. *
  48. * PROGRAM
  49.           org TALKBASE
  50. TALKSTART EQU *
  51.           LDS #STACK
  52.           LDX #REGBASE
  53.           CLR BPROT,X   Enable EEPROM programming
  54.           CLR SCCR1,X
  55.           LDD #$020C
  56.           STAA BAUD,X   Initialise SCI to 38.4K baud, no parity
  57.           STAB SCCR2,X  and enable SCI tx & rx.
  58.           LDAA #$10     Enable STOP, and XIRQ, disable I bit interrupts.
  59.           TAP
  60. *
  61. IDLE      JMP IDLE      Now hang around for SCI interrupt from host.
  62. * A RESET from host changes above jump destination to start of user code.
  63. *
  64. SCISRV    EQU *             On detecting interrupt,
  65.           LDAA SCSR+REGBASE assume receiver caused it.
  66.           ANDA #RDRF
  67.           BEQ SCISRV        otherwise program will hang up
  68. *
  69. RXSRV     EQU *             Talker code processes received data.
  70.           LDAA SCDR+REGBASE Read command byte, & echo it as acknowledge
  71.           BSR OUTSCI        to host.
  72.           BMI INH1      If command bit 7 set, then process inherent command
  73.           BSR INSCI     else read byte count from host into ACCB.(0=256)
  74.           XGDX          Save command and byte count.
  75.           BSR INSCI     Read high address byte
  76.           TBA           into ACCA
  77.           BSR INSCI     then low address byte into ACCB
  78.           XGDX          Restore command in ACCA,count in ACCB,address in X
  79.           CMPA #$01
  80.           BNE RXSRV1    If command is memory read, then
  81. *
  82. TREADMEM  EQU *         REPEAT
  83.           LDAA ,X       read required address
  84.           BSR OUTSCI    send it to host
  85.           TBA           (save byte count)
  86.           BSR INSCI     and wait for acknowledge
  87.           TAB           (restore byte count)
  88.           INX           Increment address
  89.           DECB          Decrement byte count
  90.           BNE TREADMEM  UNTIL all done
  91.           RTI           and return to idle loop or user code.
  92. *
  93. RXSRV1    EQU *
  94.           CMPA #$41
  95.           BNE RXSRVEX    If command is memory write then
  96. *
  97.           TBA           move byte count to ACCA
  98. TWRITMEM  EQU *         REPEAT
  99.           BSR INSCI     Read next byte from host into ACCB,
  100.           STAB ,X       and store at required address.
  101.           LDY #$0001    Set up wait loop to allow for 28C64 prog time, where
  102. WAITPOLL  DEY           Y operand must be manually set to $0359 (3mS)
  103.           BNE WAITPOLL
  104.           LDAB ,X       Read stored byte and
  105.           STAB SCDR+REGBASE   echo it back to host,
  106.           INX
  107.           DECA          Decrement byte count
  108.           BNE TWRITMEM  UNTIL all done
  109. RXSRVEX   EQU *         and return
  110. NULLSRV   RTI
  111. *
  112. INSCI     EQU *
  113.           LDAB SCSR+REGBASE   Wait for RDRF=1
  114.           BITB #OR+FE
  115.           BNE TALKSTART
  116.           ANDB #RDRF
  117.           BEQ INSCI
  118.           LDAB SCDR+REGBASE   then read data received from host
  119.           RTS                 and return with data in ACCB
  120. *
  121. OUTSCI    EQU *               Only register Y modified.
  122.           XGDY                Enter with data to send in ACCA.
  123. OUTSCI1   LDAA SCSR+REGBASE
  124.           BPL OUTSCI1         MS bit is TDRE flag
  125.           XGDY
  126.           STAA SCDR+REGBASE   Important - Updates CCR!
  127.           RTS
  128. *
  129. INH1      EQU *
  130.           CMPA #$81     If command is read MCU registers then
  131.           BNE INH2
  132. *
  133. INH1A     TSX           Move stack pointer to X
  134.           XGDX          then to ACCD
  135.           BSR OUTSCI    send stack pointer to host (high byte first)
  136.           TBA
  137.           BSR OUTSCI    then low byte
  138.           TSX           Restore X (=stack pointer)
  139.           LDAB #9       then return 9 bytes on stack
  140.           BRA TREADMEM  i.e. CCR,ACCB,ACCA,IXH,IXL,IYH,IYL,PCH,PCL
  141. *
  142. INH2      EQU *
  143.           CMPA #$C1     If command is write MCU registers then
  144.           BNE SWISRV1
  145. *
  146.           BSR INSCI     get stack pointer from host (High byte first)
  147.           TBA
  148.           BSR INSCI
  149.           XGDX          Move to X reg
  150.           TXS           and copy to stack pointer
  151.           LDAA #9       Then put next 9 bytes from host on to stack
  152.           BRA TWRITMEM
  153. *
  154. SWISRV    EQU *         Breakpoints generated by host-placed SWI instruction.
  155.           LDAA #BRKCODE Force host to process breakpoints
  156.           BSR OUTSCI    by sending it the break signal
  157. SWIIDLE   BRA SWIIDLE   then wait for response from host. (Ibit=1,Xbit=0)
  158. *
  159. SWISRV1   EQU *
  160.           CMPA #BRKACK  If host has acknowledged breakpoint state then
  161.           BNE RXSRVEX
  162.           TSX           move stack pointer to SWI stack frame and
  163.           LDAB #9
  164.           ABX
  165.           TXS
  166.           LDD 7,X       Send user code breakpoint return address to host
  167.           BSR OUTSCI    (high byte first)
  168.           TBA
  169.           BSR OUTSCI    (low byte next)
  170.           LDD #IDLE     force idle loop on return from breakpoint processing
  171.           STD 7,X
  172.           BRA INH1A     but first return all MCU registers to host
  173. *
  174.           org TALKVECT
  175.           FDB SCISRV    SCI RX interrupt
  176.           FDB NULLSRV   SPI
  177.           FDB NULLSRV   Pulse Acc Input Edge
  178.           FDB NULLSRV   Pulse Acc Overflow
  179.           FDB NULLSRV   Timer Overflow
  180.           FDB NULLSRV   TOC5
  181.           FDB NULLSRV   TOC4
  182.           FDB NULLSRV   TOC3
  183.           FDB NULLSRV   TOC2
  184.           FDB NULLSRV   TOC1
  185.           FDB NULLSRV   TIC3
  186.           FDB NULLSRV   TIC2
  187.           FDB NULLSRV   TIC1
  188.           FDB NULLSRV   Real Time Interrupt
  189.           FDB NULLSRV   IRQ
  190.           FDB SCISRV    XIRQ (SCI RX connected to XIRQ pin)
  191.           FDB NULLSRV   SWI  (Changed by Break and Trace monitor cmds)
  192.           FDB TALKSTART Illegal opcode trap (Restart talker)
  193.           FDB NULLSRV   COP Software fail (Unused)
  194.           FDB NULLSRV   COP Clock Monitor fail (Reassigned by PCBUG11 RESET)
  195.           FDB TALKSTART Reset
  196.           END
  197.