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

  1. *************************** TALKER79.ASC 22/9/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 DOES NOT use XIRQ                                        *
  8. *   -----------------------------                                        *
  9. *   N.B. XIRQ pin on 68HC711E9 must be connected to 12 Volts to program  *
  10. *        internal EPROM.                                                 *
  11. *   -------------------------------------------------------------------  *
  12. *                                                                        *
  13. *   Works with Host user interface program PCBUG11.EXE.                  *
  14. * N.B. TALKER79.ASC is designed to be downloaded through standard type   *
  15. *      of bootloader, and communicate with host through SCI.             *
  16. *      This bootloader relies on a 4 char idle line on SCI to terminate. *
  17. *      The talker baud rate is 38400 baud when used with a 4.9152MHz     *
  18. *      crystal. This ensures fast EPROM programming times.               *
  19. *      This means that the monitor must be invoked with the command:     *
  20. *                    PCBUG11 BOOT79 4800                                 *
  21. *      Then PCBUG11's baud rate must be changed to 38400 baud with the   *
  22. *      command:      BAUD 38400                                          *
  23. *
  24. * CONSTANTS
  25. TALKBASE  equ $0000
  26. BOOTVECT  equ $00C4       Start of bootstrap vector jump table.
  27. STACK     equ $01FF
  28. REGBASE   equ $1000
  29. *
  30. JSCI      equ $00C4
  31. JXIRQ     equ $00F1
  32. JSWI      equ $00F4
  33. JILLOP    equ $00F7
  34. JCOP      equ $00FA
  35. uS500     equ 5000/35     500uS delay with DEY/BNE loop
  36. JMPEXT    equ $7E         Mnemonic for jump extended instruction
  37. BRKCODE   equ $4A         Break point signal code to host.
  38. BRKACK    equ $B5         Break point acknowledge code from host.
  39. *
  40. * REGISTERS
  41. BAUD      equ $2B
  42. SCCR1     equ $2C
  43. SCCR2     equ $2D
  44. SCSR      equ $2E
  45. SCDR      equ $2F
  46. *
  47. RDRF      equ $20
  48. TDRE      equ $80
  49. *
  50. * PROGRAM
  51.           org TALKBASE
  52. TLKRSTART EQU *
  53.           LDS #STACK
  54.           LDX #REGBASE
  55.           CLR SCCR1,X
  56.           LDD #$012C    Initialise SCI to 38400 baud with 4.9152MHz XTAL
  57.           STAA BAUD,X   
  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 #$0A           If break detected
  116.           BNE TLKRSTART       then restart talker
  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 BOOTVECT  Boot vector jump table set up only during bootstrap.
  177.           FCB JMPEXT    SCI
  178.           FDB SCISRV
  179.           FCB JMPEXT    SPI  (Unused vectors point to RTI)
  180.           FDB NULLSRV
  181.           FCB JMPEXT    Pulse acc. Input Edge
  182.           FDB NULLSRV
  183.           FCB JMPEXT    Pulse acc. Overflow
  184.           FDB NULLSRV
  185.           FCB JMPEXT    Timer Overflow
  186.           FDB NULLSRV
  187.           FCB JMPEXT    OC5
  188.           FDB NULLSRV
  189.           FCB JMPEXT    OC4
  190.           FDB NULLSRV
  191.           FCB JMPEXT    OC3
  192.           FDB NULLSRV
  193.           FCB JMPEXT    OC2
  194.           FDB NULLSRV
  195.           FCB JMPEXT    OC1
  196.           FDB NULLSRV
  197.           FCB JMPEXT    IC3
  198.           FDB NULLSRV
  199.           FCB JMPEXT    IC2
  200.           FDB NULLSRV
  201.           FCB JMPEXT    IC1
  202.           FDB NULLSRV
  203.           FCB JMPEXT    Real Time Intr
  204.           FDB NULLSRV
  205.           FCB JMPEXT    IRQ
  206.           FDB NULLSRV
  207.           FCB JMPEXT    XIRQ
  208.           FDB NULLSRV
  209.           FCB JMPEXT    SWI    N.B. Changed by monitor Break point and Trace !
  210.           FDB NULLSRV
  211.           FCB JMPEXT    ILLOP
  212.           FDB TLKRSTART
  213.           FCB JMPEXT    COP Fail
  214.           FDB NULLSRV
  215.           FCB JMPEXT    Clock Monitor N.B. Changed by monitor Reset operation !
  216.           FDB NULLSRV
  217. *
  218.           END
  219.