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

  1. *************************** TALKERA8.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. *   Works with Host user interface program PCBUG11.EXE.                  *
  7. * N.B. TALKERA8.ASC is designed to be downloaded through 68HC11A8 type   *
  8. *      bootloader, and communicate with host through SCI.                *
  9. *      This bootloader loads 256 bytes of user code before terminating.  *
  10. *
  11. * CONSTANTS
  12. TALKBASE  equ $0000
  13. BOOTVECT  equ $00C4       Start of bootstrap vector jump table.
  14. STACK     equ $00EB
  15. REGBASE   equ $1000
  16. *
  17. JSCI      equ $00C4
  18. JXIRQ     equ $00F1
  19. JSWI      equ $00F4
  20. JILLOP    equ $00F7
  21. JCOP      equ $00FA
  22. uS500     equ 5000/35     500uS delay with DEY/BNE loop
  23. JMPEXT    equ $7E         Mnemonic for jump extended instruction
  24. BRKCODE   equ $4A         Break point signal code to host.
  25. BRKACK    equ $B5         Break point acknowledge code from host.
  26. *
  27. * REGISTERS
  28. BAUD      equ $2B
  29. SCCR1     equ $2C
  30. SCCR2     equ $2D
  31. SCSR      equ $2E
  32. SCDR      equ $2F
  33. *
  34. RDRF      equ $20
  35. TDRE      equ $80
  36. *
  37. * PROGRAM
  38.           org TALKBASE
  39. TLKRSTART EQU *
  40.           LDS #STACK
  41.           LDX #REGBASE
  42.           CLR SCCR1,X
  43.           LDD #$300C    Note: if baud rate changed, then TAP below may fail.
  44.           STAA BAUD,X   Initialise SCI to 9600 baud, no parity
  45.           STAB SCCR2,X  and enable SCI tx & rx.
  46.           LDAA #$10     Enable STOP, and XIRQ interrupts, disable I bit intr.
  47.           TAP
  48. *
  49. IDLE      JMP IDLE      Now hang around for SCI interrupt from host.
  50. * A RESET from host changes above jump destination to start of user code.
  51. *
  52. SCISRV    EQU *             On detecting interrupt,
  53.           LDAA SCSR+REGBASE assume receiver caused it.
  54.           ANDA #RDRF
  55.           BEQ SCISRV        otherwise program will hang up
  56. *
  57. RXSRV     EQU *             Talker code processes received data.
  58.           LDAA SCDR+REGBASE Read command byte, & echo it as acknowledge
  59.           BSR OUTSCI        to host.
  60.           BMI INH1      If command bit 7 set, then process inherent command
  61.           BSR INSCI     else read byte count from host into ACCB.(0=256)
  62.           XGDX          Save command and byte count.
  63.           BSR INSCI     Read high address byte
  64.           TBA           into ACCA
  65.           BSR INSCI     then low address byte into ACCB
  66.           XGDX          Restore command in ACCA,count in ACCB,address in X
  67.           CMPA #$01
  68.           BNE RXSRV1    If command is memory read, then
  69. *
  70. TREADMEM  EQU *         REPEAT
  71.           LDAA ,X       read required address
  72.           BSR OUTSCI    send it to host
  73.           TBA           (save byte count)
  74.           BSR INSCI     and wait for acknowledge
  75.           TAB           (restore byte count)
  76.           INX           Increment address
  77.           DECB          Decrement byte count
  78.           BNE TREADMEM  UNTIL all done
  79.           RTI           and return to idle loop or user code.
  80. *
  81. RXSRV1    EQU *
  82.           CMPA #$41
  83.           BNE RXSRVEX    If command is memory write then
  84. *
  85.           TBA           move byte count to ACCA
  86. TWRITMEM  EQU *         REPEAT
  87.           BSR INSCI     Read next byte from host into ACCB,
  88.           STAB ,X       and store at required address.
  89.           LDY #$0001    Set up wait loop to allow for 28C64 prog time, where
  90. WAITPOLL  DEY           Y operand must be manually set to $0359 (3mS)
  91.           BNE WAITPOLL
  92.           LDAB ,X       Read stored byte and
  93.           STAB SCDR+REGBASE   echo it back to host,
  94.           INX
  95.           DECA          Decrement byte count
  96.           BNE TWRITMEM  UNTIL all done
  97. RXSRVEX   EQU *         and return
  98. NULLSRV   RTI
  99. *
  100. INSCI     EQU *
  101.           LDAB SCSR+REGBASE   Wait for RDRF=1
  102.           BITB #$0A           If break detected then
  103.           BNE TLKRSTART       restart talker
  104.           ANDB #RDRF
  105.           BEQ INSCI
  106.           LDAB SCDR+REGBASE   then read data received from host
  107.           RTS                 and return with data in ACCB
  108. *
  109. OUTSCI    EQU *               Only register Y modified.
  110.           XGDY                Enter with data to send in ACCA.
  111. OUTSCI1   LDAA SCSR+REGBASE
  112.           BPL OUTSCI1         MS bit is TDRE flag
  113.           XGDY
  114.           STAA SCDR+REGBASE   Important - Updates CCR!
  115.           RTS
  116. *
  117. INH1      EQU *
  118.           CMPA #$81     If command is read MCU registers then
  119.           BNE INH2
  120. *
  121. INH1A     TSX           Move stack pointer to X
  122.           XGDX          then to ACCD
  123.           BSR OUTSCI    send stack pointer to host (high byte first)
  124.           TBA
  125.           BSR OUTSCI    then low byte
  126.           TSX           Restore X (=stack pointer)
  127.           LDAB #9       then return 9 bytes on stack
  128.           BRA TREADMEM  i.e. CCR,ACCB,ACCA,IXH,IXL,IYH,IYL,PCH,PCL
  129. *
  130. INH2      EQU *
  131.           CMPA #$C1     If command is write MCU registers then
  132.           BNE SWISRV1
  133. *
  134.           BSR INSCI     get stack pointer from host (High byte first)
  135.           TBA
  136.           BSR INSCI
  137.           XGDX          Move to X reg
  138.           TXS           and copy to stack pointer
  139.           LDAA #9       Then put next 9 bytes from host on to stack
  140.           BRA TWRITMEM
  141. *
  142. SWISRV    EQU *         Breakpoints generated by host-placed SWI instruction.
  143.           LDAA #BRKCODE Force host to process breakpoints
  144.           BSR OUTSCI    by sending it the break signal
  145. SWIIDLE   BRA SWIIDLE   Wait for response from host. (Ibit=1,Xbit=0)
  146. *
  147. SWISRV1   EQU *
  148.           CMPA #BRKACK  If host has acknowledged breakpoint state then
  149.           BNE RXSRVEX
  150.           TSX           move stack pointer to SWI stack frame and
  151.           LDAB #9
  152.           ABX
  153.           TXS
  154.           LDD 7,X       Send user code breakpoint return address to host
  155.           BSR OUTSCI    (high byte first)
  156.           TBA
  157.           BSR OUTSCI    (low byte next)
  158.           LDD #IDLE     force idle loop on return from breakpoint processing
  159.           STD 7,X
  160.           BRA INH1A     but first return all MCU registers to host
  161. *
  162.           ORG BOOTVECT  Boot vector jump table set up only during bootstrap.
  163.           FCB JMPEXT    SCI
  164.           FDB SCISRV
  165.           FCB JMPEXT    SPI  (Unused vectors point to RTI)
  166.           FDB NULLSRV
  167.           FCB JMPEXT    Pulse acc. Input Edge
  168.           FDB NULLSRV
  169.           FCB JMPEXT    Pulse acc. Overflow
  170.           FDB NULLSRV
  171.           FCB JMPEXT    Timer Overflow
  172.           FDB NULLSRV
  173.           FCB JMPEXT    OC5
  174.           FDB NULLSRV
  175.           FCB JMPEXT    OC4
  176.           FDB NULLSRV
  177.           FCB JMPEXT    OC3
  178.           FDB NULLSRV
  179.           FCB JMPEXT    OC2
  180.           FDB NULLSRV
  181.           FCB JMPEXT    OC1
  182.           FDB NULLSRV
  183.           FCB JMPEXT    IC3
  184.           FDB NULLSRV
  185.           FCB JMPEXT    IC2
  186.           FDB NULLSRV
  187.           FCB JMPEXT    IC1
  188.           FDB NULLSRV
  189.           FCB JMPEXT    Real Time Intr
  190.           FDB NULLSRV
  191.           FCB JMPEXT    IRQ
  192.           FDB NULLSRV
  193.           FCB JMPEXT    XIRQ   SCI RX line must be connected to XIRQ input.
  194.           FDB SCISRV
  195.           FCB JMPEXT    SWI    N.B. Changed by monitor Break point and Trace !
  196.           FDB NULLSRV
  197.           FCB JMPEXT    ILLOP
  198.           FDB TLKRSTART
  199.           FCB JMPEXT    COP Fail
  200.           FDB NULLSRV
  201.           FCB JMPEXT    Clock Monitor N.B. Changed by monitor Reset operation !
  202.           FDB NULLSRV
  203. *
  204.           END
  205.