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