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

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