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

  1. *************************** TALKEREE.ASC 9/2/89 **************************
  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. *   Works with Host user interface program PCBUG11.EXE.                  *
  11. * N.B. TALKEREE.ASC is designed to work with the 68HC11A1 or other       *
  12. *      compatible MCU types. This version of the TALKER is designed to   *
  13. *      execute from internal EEPROM located at $B600-$B7FF.              *
  14. *      TALKEREE must have been previously downloaded in some manner, for *
  15. *      instance using PCBUG11 BOOTA8 option, and EEPROM & LOADS commands.*
  16. *      To initiate communication with TALKEREE, an SCI break condition   *
  17. *      must be detected by the 68HC11 running in bootstrap mode.         *
  18. *      When PCBUG11 is executed with option TALKEREE, a 10mS break is    *
  19. *      output to the 68HC11's SCI, prior to establishing communication.  *
  20. *
  21. * CONSTANTS
  22. TALKBASE  equ $B600
  23. BOOTVECT  equ $00C4       Start of bootstrap vector jump table.
  24. STACK     equ $00EB
  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. *
  43. RDRF      equ $20
  44. TDRE      equ $80
  45. OR        equ $08
  46. FE        equ $02
  47. *
  48. * PROGRAM
  49.           org TALKBASE
  50. TLKRSTART EQU *         First dynamically set up Boot vector jump table.
  51.           LDAA #JMPEXT
  52.           LDY #NULLSRV
  53.           LDX #BOOTVECT
  54. SETVECT   EQU *
  55.           STAA ,X
  56.           INX
  57.           STY ,X
  58.           INX
  59.           INX
  60.           CPX #$100
  61.           BNE SETVECT
  62.           LDX #SCISRV
  63.           STX JXIRQ+1   Changed from JSCI+1
  64.           LDX #TLKRSTART
  65.           STX JILLOP+1
  66. *
  67. USERSTART EQU *
  68.           LDS #STACK
  69.           LDX #REGBASE
  70.           CLR SCCR1,X
  71.           LDD #$300C    was #$302C
  72.           STAA BAUD,X   Initialise SCI to 9600 baud, no parity, no interrupt
  73.           STAB SCCR2,X  and enable SCI tx & rx.
  74.           LDAA #$10     Enable STOP, and XIRQ, disable I bit interrupts.
  75.           TAP
  76. *
  77. IDLE      JMP IDLE      Now hang around for SCI interrupt from host.
  78. * A RESET from host changes above jump destination to start of user code.
  79. *
  80. SCISRV    EQU *             On detecting interrupt,
  81.           LDAA SCSR+REGBASE assume receiver caused it.
  82.           ANDA #RDRF
  83.           BEQ SCISRV        otherwise program will hang up
  84. *
  85. RXSRV     EQU *             Talker code processes received data.
  86.           LDAA SCDR+REGBASE Read command byte, & echo it as acknowledge
  87.           BSR OUTSCI        to host.
  88.           BMI INH1      If command bit 7 set, then process inherent command
  89.           BSR INSCI     else read byte count from host into ACCB.(0=256)
  90.           XGDX          Save command and byte count.
  91.           BSR INSCI     Read high address byte
  92.           TBA           into ACCA
  93.           BSR INSCI     then low address byte into ACCB
  94.           XGDX          Restore command in ACCA,count in ACCB,address in X
  95.           CMPA #$01
  96.           BNE RXSRV1    If command is memory read, then
  97. *
  98. TREADMEM  EQU *         REPEAT
  99.           LDAA ,X       read required address
  100.           BSR OUTSCI    send it to host
  101.           TBA           (save byte count)
  102.           BSR INSCI     and wait for acknowledge
  103.           TAB           (restore byte count)
  104.           INX           Increment address
  105.           DECB          Decrement byte count
  106.           BNE TREADMEM  UNTIL all done
  107.           RTI           and return to idle loop or user code.
  108. *
  109. RXSRV1    EQU *
  110.           CMPA #$41
  111.           BNE RXSRVEX    If command is memory write then
  112. *
  113.           TBA           move byte count to ACCA
  114. TWRITMEM  EQU *         REPEAT
  115.           BSR INSCI     Read next byte from host into ACCB,
  116.           STAB ,X       and store at required address.
  117.           LDY #$0001    Set up wait loop to allow for 28C64 prog time, where
  118. WAITPOLL  DEY           Y operand must be manually set to $0359 (3mS)
  119.           BNE WAITPOLL
  120.           LDAB ,X       Read stored byte and
  121.           STAB SCDR+REGBASE   echo it back to host,
  122.           INX
  123.           DECA          Decrement byte count
  124.           BNE TWRITMEM  UNTIL all done
  125. RXSRVEX   EQU *         and return
  126. NULLSRV   RTI
  127. *
  128. INSCI     EQU *
  129.           LDAB SCSR+REGBASE   Wait for RDRF=1
  130.           BITB #(FE+OR)       If break detected then
  131.           BNE TLKRSTART       restart talker.
  132.           ANDB #RDRF
  133.           BEQ INSCI
  134.           LDAB SCDR+REGBASE   then read data received from host
  135.           RTS                 and return with data in ACCB
  136. *
  137. OUTSCI    EQU *               Only register Y modified.
  138.           XGDY                Enter with data to send in ACCA.
  139. OUTSCI1   LDAA SCSR+REGBASE
  140.           BPL OUTSCI1         MS bit is TDRE flag
  141.           XGDY
  142.           STAA SCDR+REGBASE   Important - Updates CCR!
  143.           RTS
  144. *
  145. INH1      EQU *
  146.           CMPA #$81     If command is read MCU registers then
  147.           BNE INH2
  148. *
  149. INH1A     TSX           Move stack pointer to X
  150.           XGDX          then to ACCD
  151.           BSR OUTSCI    send stack pointer to host (high byte first)
  152.           TBA
  153.           BSR OUTSCI    then low byte
  154.           TSX           Restore X (=stack pointer)
  155.           LDAB #9       then return 9 bytes on stack
  156.           BRA TREADMEM  i.e. CCR,ACCB,ACCA,IXH,IXL,IYH,IYL,PCH,PCL
  157. *
  158. INH2      EQU *
  159.           CMPA #$C1     If command is write MCU registers then
  160.           BNE SWISRV1
  161. *
  162.           BSR INSCI     get stack pointer from host (High byte first)
  163.           TBA
  164.           BSR INSCI
  165.           XGDX          Move to X reg
  166.           TXS           and copy to stack pointer
  167.           LDAA #9       Then put next 9 bytes from host on to stack
  168.           BRA TWRITMEM
  169. *
  170. SWISRV    EQU *         Breakpoints generated by host-placed SWI instruction.
  171.           LDAA #BRKCODE Force host to process breakpoints
  172.           BSR OUTSCI    by sending it the break signal
  173. SWIIDLE   BRA SWIIDLE   then wait for response from host. (Ibit=1,Xbit=0)
  174. *
  175. SWISRV1   EQU *
  176.           CMPA #BRKACK  If host has acknowledged breakpoint state then
  177.           BNE RXSRVEX
  178.           TSX           move stack pointer to SWI stack frame and
  179.           LDAB #9
  180.           ABX
  181.           TXS
  182.           LDD 7,X       Send user code breakpoint return address to host
  183.           BSR OUTSCI    (high byte first)
  184.           TBA
  185.           BSR OUTSCI    (low byte next)
  186.           LDD #IDLE     force idle loop on return from breakpoint processing
  187.           STD 7,X
  188.           BRA INH1A     but first return all MCU registers to host
  189. *
  190.           END
  191.