Guest User

Untitled

a guest
May 18th, 2018
235
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MPASM 31.47 KB | None | 0 0
  1.  
  2. ;*****************************************************************************************
  3. ;*****************************************************************************************
  4. ;**                                         **
  5. ;**             Header Information                  **
  6. ;**                                         **
  7. ;*****************************************************************************************
  8. ;**                                         **
  9. ;** Processor Type: PIC 16F887                              **
  10. ;** Default Assembler Radix: Decimal                            **
  11. ;** Assembler Error Level: Suppress error 302                       **
  12. ;** Assembler Header File: P16F887.INC                          **
  13. ;**                                             **
  14. ;** Configuration Word 1                                **
  15. ;**                                         **
  16. ;** Debug Mode Off (Default)                                **
  17. ;** Low Voltage Programming Off                             **
  18. ;** Fail Safe Clock Monitor Off                             **
  19. ;** Internal External Switchover Off                            **
  20. ;** Brown Out Reset Off                                 **
  21. ;** Data Code Protect Off (Default)                         **
  22. ;** Code Protect Off (Default)                              **
  23. ;** RE3 Has MCLR Function (Default)                         **
  24. ;** Power Up Timer On                                   **
  25. ;** Watchdog Timer Off                                  **
  26. ;** Internal Oscillator - RA6 & RA7 are digital I/O                 **
  27. ;**                                         **
  28. ;** Configuration Word 2                                **
  29. ;**                                         **
  30. ;** Program Memory Write Protect Off (Default)                      **
  31. ;** Brown Out Reset Voltage 4.0V (Default - BOR Disabled by Configuation Word 1)    **
  32. ;**                                         **
  33. ;** Fosc = 4MHz                                     **
  34. ;**                                         **
  35. ;*****************************************************************************************
  36. ;*****************************************************************************************
  37.  
  38.         list        p=16F887, r=dec, w=-302
  39.         include     <P16F887.INC>
  40.         __config    _CONFIG1, _LVP_OFF & _FCMEN_OFF & _IESO_OFF & _BOR_OFF & _PWRTE_ON & _WDT_OFF & _INTOSCIO
  41.  
  42. ;*****************************************************************************************
  43. ;**                                         **
  44. ;**             Variable Declarations                   **
  45. ;**                                         **
  46. ;*****************************************************************************************
  47.  
  48.         cblock      0x20
  49.                 FUNCTIONDATA
  50.                 MIDIDATA
  51.                 MIDICHANNELH
  52.                 MIDICHANNELL
  53.                 AMPCHANNEL
  54.                 MIDIFLAGS
  55.         endc
  56.  
  57.         cblock      0x70
  58.                 W_TEMP          ;W context save for interrupts
  59.                 STATUS_TEMP     ;STATUS context save for interrupts
  60.                 PCLATH_TEMP     ;PCLATH context save for interrupts
  61.                 DATAL           ;first data byte buffer
  62.                 DATAH           ;second data byte buffer
  63.                 COMMAND         ;GLCD instruction buffer
  64.                 DELAYCOUNT      ;delay counter
  65.                 COUNT1          ;general purpose counter 1
  66.                 COUNT2          ;general purpose counter 2
  67.                 COUNT3          ;general purpose counter 3
  68.                 DATA_EE_ADDR        ;data EEPROM address buffer
  69.                 DATA_EE_DATA        ;data EEPROM data buffer
  70.         endc
  71.  
  72. ;*****************************************************************************************
  73. ;**                                         **
  74. ;**             I/O Line Names                      **
  75. ;**                                         **
  76. ;*****************************************************************************************
  77.  
  78. #define     RD_EN       0x01        ;read enable macro
  79. #define     WRT_EN      0x02        ;write enable macro
  80. #define     RW_DIS      0x07        ;read/write disable macro
  81.  
  82. #define     CD      PORTA,RA0   ;GLCD Command/Data (high = Command/low = Data)
  83. #define     RST     PORTA,RA1   ;GLCD Reset (active low)
  84. #define     FONT        PORTA,RA2   ;GLCD Font Select (high = 6x8 font/low = 8x8 font)
  85.  
  86. #define     WRITE       PORTC,RC0   ;GLCD Read (active low)
  87. #define     READ        PORTC,RC1   ;GLCD Write (active low)
  88. #define     CE      PORTC,RC2   ;GLCD Chip Enable (active low)
  89.  
  90. #define     STA0        PORTB,RB0   ;GLCD data port bit 0
  91. #define     STA1        PORTB,RB1   ;GLCD data port bit 1
  92. #define     DARRDY      PORTB,RB2   ;GLCD data port bit 2
  93. #define     DAWRDY      PORTB,RB3   ;GLCD data port bit 3
  94. #define     D4      PORTB,RB4   ;GLCD data port bit 4
  95. #define     D5      PORTB,RB5   ;GLCD data port bit 5
  96. #define     D6      PORTB,RB6   ;GLCD data port bit 6
  97. #define     D7      PORTB,RB7   ;GLCD data port bit 7
  98.  
  99. ;*****************************************************************************************
  100. ;**                                         **
  101. ;**             Single Byte Instructions                **
  102. ;**                                         **
  103. ;*****************************************************************************************
  104.  
  105. ;mode set instructions
  106.  
  107. #define     OR_CGROM    0x80        ;text OR'ed with graphics, CG-ROM on
  108. #define     XOR_CGROM   0x81        ;text XOR'ed with graphics, CG-ROM on
  109. #define     AND_CGROM   0x83        ;text AND'ed with graphics, CG-ROM on
  110. #define     TATTR_CGROM 0x84        ;text attribute mode, CG-ROM on
  111. #define     OR_CGRAM    0x88        ;text OR'ed with graphics, CG-RAM on
  112. #define     XOR_CGRAM   0x89        ;text XOR'ed with graphics, CG-RAM on
  113. #define     AND_CGRAM   0x8B        ;text AND'ed with graphics, CG-RAM on
  114. #define     TATTR_CGRAM 0x8C        ;text attribute mode, CG-RAM on
  115.  
  116. ;cursor pattern select instructions
  117.  
  118. #define     CSR1        0xA0        ;1 line cursor
  119. #define     CSR2        0xA1        ;2 line cursor
  120. #define     CSR3        0xA2        ;3 line cursor
  121. #define     CSR4        0xA3        ;4 line cursor
  122. #define     CSR5        0xA4        ;5 line cursor
  123. #define     CSR6        0xA5        ;6 line cursor
  124. #define     CSR7        0xA6        ;7 line cursor
  125. #define     CSR8        0xA7        ;8 line cursor (block cursor)
  126.  
  127. ;display mode set instructions
  128.  
  129. #define     DIS_MODE1   0x94        ;text RAM on, cursor off
  130. #define     DIS_MODE2   0x96        ;text RAM on, cursor on, blink off
  131. #define     DIS_MODE3   0x97        ;text RAM on, cursor on, blink on
  132. #define     DIS_MODE4   0x98        ;graphics RAM on, cursor off
  133. #define     DIS_MODE5   0x9A        ;graphics RAM on, cursor on, blink off
  134. #define     DIS_MODE6   0x9B        ;graphics RAM on, cursor on, blink on
  135. #define     DIS_MODE7   0x9C        ;text/graphics RAM on, cursor off
  136. #define     DIS_MODE8   0x9E        ;text/graphics RAM on, cursor on, blink off
  137. #define     DIS_MODE9   0x9F        ;text/graphics RAM on, cursor on, blink on
  138.  
  139. ;*****************************************************************************************
  140. ;**                                         **
  141. ;**             Start Here                      **
  142. ;**                                         **
  143. ;*****************************************************************************************
  144.  
  145.         org     0x000       ;reset vector
  146.         goto        START
  147.  
  148.         org     0x004       ;interrupt vector
  149.         goto        ISR
  150.  
  151.         org     0x005       ;data table vector
  152.  
  153. ;*****************************************************************************************
  154. ;**                                         **
  155. ;**             Character Map                       **
  156. ;**                                         **
  157. ;*****************************************************************************************
  158.  
  159. ALPHA       addwf       PCL,F
  160.         retlw       0x00        ;blank space
  161.         retlw       0x21        ;A
  162.         retlw       0x22        ;B
  163.         retlw       0x23        ;C
  164.         retlw       0x24        ;D
  165.         retlw       0x25        ;E
  166.         retlw       0x26        ;F
  167.         retlw       0x27        ;G
  168.         retlw       0x28        ;H
  169.         retlw       0x29        ;I
  170.         retlw       0x2A        ;J
  171.         retlw       0x2B        ;K
  172.         retlw       0x2C        ;L
  173.         retlw       0x2D        ;M
  174.         retlw       0x2E        ;N
  175.         retlw       0x2F        ;O
  176.         retlw       0x30        ;P
  177.         retlw       0x31        ;Q
  178.         retlw       0x32        ;R
  179.         retlw       0x33        ;S
  180.         retlw       0x34        ;T
  181.         retlw       0x35        ;U
  182.         retlw       0x36        ;V
  183.         retlw       0x37        ;W
  184.         retlw       0x38        ;X
  185.         retlw       0x39        ;Y
  186.         retlw       0x3A        ;Z
  187.  
  188. DIGIT       addwf       PCL,F
  189.         retlw       0x10        ;0
  190.         retlw       0x11        ;1
  191.         retlw       0x12        ;2
  192.         retlw       0x13        ;3
  193.         retlw       0x14        ;4
  194.         retlw       0x15        ;5
  195.         retlw       0x16        ;6
  196.         retlw       0x17        ;7
  197.         retlw       0x18        ;8
  198.         retlw       0x19        ;9
  199.         retlw       0x21        ;A
  200.         retlw       0x22        ;B
  201.         retlw       0x23        ;C
  202.         retlw       0x24        ;D
  203.         retlw       0x25        ;E
  204.         retlw       0x26        ;F
  205.  
  206. PUNCTUATION addwf       PCL,F
  207.         retlw       0x01        ; !
  208.         retlw       0x02        ; "
  209.         retlw       0x03        ; #
  210.         retlw       0x04        ; $
  211.         retlw       0x05        ; %
  212.         retlw       0x06        ; &
  213.         retlw       0x07        ; '
  214.         retlw       0x08        ; (
  215.         retlw       0x09        ; )
  216.         retlw       0x0A        ; *
  217.         retlw       0x0B        ; +
  218.         retlw       0x0C        ; ,
  219.         retlw       0x0D        ; -
  220.         retlw       0x0E        ; .
  221.         retlw       0x0F        ; /
  222.         retlw       0x1A        ; :
  223.         retlw       0x1B        ; ;
  224.         retlw       0x1C        ; <
  225.         retlw       0x1D        ; =
  226.         retlw       0x1E        ; >
  227.         retlw       0x1F        ; ?
  228.         retlw       0x20        ; @
  229.         retlw       0x3B        ; [
  230.         retlw       0x3C        ; \
  231.         retlw       0x3D        ; ]
  232.         retlw       0x3E        ; ^
  233.         retlw       0x3F        ; _
  234.         retlw       0x5B        ; {
  235.         retlw       0x5D        ; }
  236.         retlw       0x5E        ; ~
  237.  
  238. FUNCTION    addwf       PCL,F
  239.         goto        Chan1
  240.         goto        Chan2
  241.         goto        Chan3
  242.         goto        Chan4
  243.         goto        MuteOn
  244.         goto        MuteOff
  245.         goto        MR2On
  246.         goto        MR2Off
  247.         goto        MCutOn
  248.         goto        MCutOff
  249.         goto        FXOn
  250.         goto        FXOff
  251.  
  252.         org     0x100
  253. ;*****************************************************************************************
  254. ;**                                         **
  255. ;**             Interrupt Handler                   **
  256. ;**                                         **
  257. ;*****************************************************************************************
  258.  
  259. ISR     movwf       W_TEMP      ;W save
  260.         swapf       STATUS,W    ;STATUS save
  261.         banksel     0       ;bank 0
  262.         movwf       STATUS_TEMP
  263.         movfw       PCLATH      ;PCLATH save
  264.         movwf       PCLATH_TEMP
  265.  
  266. ;*****************************************************************************************
  267.  
  268. ;query interrupt bits
  269.  
  270.         btfsc       PIR1,RCIF
  271.         call        MIDIRx
  272.         btfsc       INTCON,T0IF
  273.         call        TIMER0
  274.         goto        ISRExit
  275.  
  276. ;*****************************************************************************************
  277.  
  278. ;MIDI receive interrupt
  279.  
  280. MIDIRx      movfw       RCREG
  281.         btfsc       MIDIFLAGS,0
  282.         goto        MIDIData
  283.         movwf       MIDICHANNELL
  284.  
  285.         movfw       MIDICHANNELL
  286.         andlw       0xF0
  287.         xorlw       0xC0
  288.         btfss       STATUS,Z
  289.         goto        MIDIRxExit
  290.  
  291.         movlw       0x0F
  292.         andwf       MIDICHANNELL,F
  293.         incf        MIDICHANNELL,F
  294.         incf        MIDIFLAGS,F
  295.         goto        MIDIRxExit
  296.  
  297. MIDIData    movwf       MIDIDATA
  298.         incf        MIDIFLAGS,F
  299.  
  300. MIDIRxExit  btfss       RCSTA,OERR
  301.         btfsc       RCSTA,FERR
  302.         call        ClrSerErr
  303.         return
  304.  
  305. ;*****************************************************************************************
  306.  
  307. ;timer 0 interrupt
  308.  
  309. TIMER0      btfss       MIDIFLAGS,1
  310.         goto        T0Exit
  311.  
  312. ;process channel byte
  313.  
  314.         clrf        MIDICHANNELH
  315.         movlw       10
  316.         subwf       MIDICHANNELL,F
  317.         btfss       STATUS,C
  318.         goto        $+3
  319.  
  320.         goto        TEN
  321.  
  322.         movlw       10
  323.         addwf       MIDICHANNELL,F
  324.         movlw       0x4E
  325.         movwf       DATAL
  326.         movlw       0x18
  327.         movwf       DATAH
  328.         call        ADDR_PTR
  329.         call        DAWSet
  330.         goto        ONE
  331.  
  332. TEN     incf        MIDICHANNELH,F
  333.         movlw       0x4E
  334.         movwf       DATAL
  335.         movlw       0x18
  336.         movwf       DATAH
  337.         call        ADDR_PTR
  338.         call        DAWSet
  339.         movfw       MIDICHANNELH
  340.         call        DAWDLoad
  341. ONE     movfw       MIDICHANNELL
  342.         call        DAWDLoad
  343.         movlw       0
  344.         call        DAWALoad
  345.         call        DAReset
  346.  
  347. ;process data byte
  348.  
  349.         movlw       200
  350.         subwf       MIDIDATA,F
  351.         movlw       12
  352.         subwf       MIDIDATA,W
  353.         btfsc       STATUS,C
  354.         goto        $+3
  355.         movfw       MIDIDATA
  356.         call        FUNCTION
  357.         clrf        MIDIFLAGS
  358.  
  359. T0Exit      clrf        TMR0
  360.         bcf     INTCON,T0IF
  361.         return
  362.  
  363. ;*****************************************************************************************
  364.  
  365. ISRExit     movfw       PCLATH_TEMP ;PCLATH restore
  366.         movwf       PCLATH
  367.         swapf       STATUS_TEMP,W   ;STATUS restore
  368.         movwf       STATUS
  369.         swapf       W_TEMP,F    ;W restore
  370.         swapf       W_TEMP,W
  371.         retfie              ;return to main code
  372.  
  373. ;*****************************************************************************************
  374. ;**                                         **
  375. ;**             Serial Error Clear                  **
  376. ;**                                         **
  377. ;*****************************************************************************************
  378.  
  379. ClrSerErr   bcf     RCSTA,CREN
  380.         movfw       RCREG
  381.         movfw       RCREG
  382.         bsf     RCSTA,CREN
  383.  
  384. ;*****************************************************************************************
  385. ;**                                         **
  386. ;**             Delay Routines                      **
  387. ;**                                         **
  388. ;*****************************************************************************************
  389.  
  390. Delay50mS   clrf        TMR2        ;init timer 2
  391.         bcf     PIR1,TMR2IF ;clear timer 2 interrupt flag
  392.         btfss       PIR1,TMR2IF ;timer 2 PR2 match?
  393.         goto        $-1     ;no, check again
  394.         return              ;yes, done
  395.  
  396. Delay       movwf       DELAYCOUNT  ;init delay counter
  397.         call        Delay50mS
  398.         decfsz      DELAYCOUNT,F    ;decrement counter
  399.         goto        $-2
  400.         return
  401.  
  402. ;*****************************************************************************************
  403. ;**                                         **
  404. ;**             GLCD Two Data Byte Instructions             **
  405. ;**                                         **
  406. ;*****************************************************************************************
  407.  
  408. CSR_PTR     movlw       0x21        ;set cursor pointer
  409.         goto        InstLoad
  410. OFST_PTR    movlw       0x22        ;set offset address
  411.         goto        InstLoad
  412. ADDR_PTR    movlw       0x24        ;set address pointer
  413.         goto        InstLoad
  414. TXT_HOME    movlw       0x40        ;set text home address
  415.         goto        InstLoad
  416. TXT_AREA    movlw       0x41        ;set text area
  417.         goto        InstLoad
  418. GRPH_HOME   movlw       0x42        ;set graphics home address
  419.         goto        InstLoad
  420. GRPH_AREA   movlw       0x43        ;set graphics area
  421.         goto        InstLoad
  422.  
  423. InstLoad    movwf       COMMAND     ;load instruction into instruction buffer
  424.         call        TwoData
  425.         return
  426.  
  427. ;*****************************************************************************************
  428. ;**                                         **
  429. ;**             GLCD Data Auto Instructions             **
  430. ;**                                         **
  431. ;*****************************************************************************************
  432.  
  433. ;data auto reset
  434.  
  435. DAReset     call        DAWStat
  436.         movlw       0xB2
  437.         call        Command
  438.         return
  439.  
  440. ;*****************************************************************************************
  441.  
  442. ;data auto write set
  443.  
  444. DAWSet      movlw       0xB0
  445.         movwf       COMMAND
  446.         call        NoData
  447.         call        LCDStat
  448.         return
  449.  
  450. ;*****************************************************************************************
  451.  
  452. ;data auto write
  453.  
  454. DAWWrite    call        DAWStat     ;check DAWRDY bit
  455.         movfw       DATAL       ;load byte
  456.         call        DWrite      ;send byte
  457.         return
  458.  
  459. ;*****************************************************************************************
  460. ;**                                         **
  461. ;**             GLCD Status Check                   **
  462. ;**                                         **
  463. ;*****************************************************************************************
  464.  
  465. ;status read mode enable
  466.  
  467. StatReadEn  bsf     CD      ;command mode
  468.         movlw       RD_EN       ;enable read
  469.         movwf       PORTC
  470.         return
  471.  
  472. ;*****************************************************************************************
  473.  
  474. ;status read mode disable
  475.  
  476. StatReadDis movlw       RW_DIS      ;disable read
  477.         movwf       PORTC
  478.         return
  479.  
  480. ;*****************************************************************************************
  481.  
  482. ;general GLCD status check
  483.  
  484. LCDStat     call        StatReadEn  ;enable read
  485.         btfsc       STA0        ;STA0 = 1?
  486.         btfss       STA1        ;STA1 = 1?
  487.         goto        $-2     ;no, check again
  488.         call        StatReadDis ;disable read
  489.         return              ;done
  490.  
  491. ;*****************************************************************************************
  492.  
  493. ;data auto write status check
  494.  
  495. DAWStat     call        StatReadEn  ;enable read
  496.         btfss       DAWRDY      ;DAWRDY = 1?
  497.         goto        $-1     ;no, check again
  498.         call        StatReadDis ;disable read
  499.         return              ;done
  500.  
  501. ;*****************************************************************************************
  502.  
  503. ;data auto write status check
  504.  
  505. DARStat     call        StatReadEn  ;enable read
  506.         btfss       DARRDY      ;DARRDY = 1?
  507.         goto        $-1     ;no, check again
  508.         call        StatReadDis ;disable read
  509.         return              ;done
  510.  
  511. ;*****************************************************************************************
  512. ;**                                         **
  513. ;**             GLCD Instruction Send                   **
  514. ;**                                         **
  515. ;*****************************************************************************************
  516.  
  517. TwoData     call        LCDStat     ;check status
  518.         movfw       DATAL       ;load first data byte
  519.         call        DWrite      ;send first data byte
  520. OneData     call        LCDStat     ;check status
  521.         movfw       DATAH       ;load second data byte
  522.         call        DWrite      ;send second data byte
  523. NoData      call        LCDStat     ;check status
  524.         movfw       COMMAND     ;load instruction
  525.         call        Command     ;send instruction
  526.         return              ;done
  527.  
  528. ;*****************************************************************************************
  529. ;**                                         **
  530. ;**             GLCD Command/Data Write                 **
  531. ;**                                         **
  532. ;*****************************************************************************************
  533.  
  534. Command     bsf     CD      ;command mode
  535.         goto        $+2
  536. DWrite      bcf     CD      ;data mode
  537.         movwf       PORTB       ;transfer data to bidirectional data port latch
  538.         movlw       WRT_EN      ;enable write
  539.         movwf       PORTC
  540.         banksel     TRISD       ;bank 1
  541.         clrf        TRISD       ;port d output
  542.         banksel     0       ;bank 0
  543.         movlw       RW_DIS      ;disable read/write
  544.         movwf       PORTC
  545.         banksel     TRISD       ;bank 1
  546.         comf        TRISD,F     ;port d input
  547.         banksel     0       ;bank 0
  548.         return
  549.  
  550. ;*****************************************************************************************
  551. ;**                                         **
  552. ;**             GLCD VRAM Clear                     **
  553. ;**                                         **
  554. ;*****************************************************************************************
  555.  
  556. VRAMClear   call        DAWSet
  557.         movlw       0
  558.         movwf       DATAL
  559.         movlw       40
  560.         movwf       COUNT1
  561.         call        DAWWrite
  562.         decfsz      COUNT1,F
  563.         goto        $-2
  564.         decfsz      COUNT2,F
  565.         goto        $-6
  566.         goto        WordExit
  567.  
  568. ;*****************************************************************************************
  569. ;**                                         **
  570. ;**             GLCD Letter Auto Write                  **
  571. ;**                                         **
  572. ;*****************************************************************************************
  573.  
  574. DAWDLoad    call        DIGIT
  575.         goto        $+4
  576. DAWALoad    call        ALPHA
  577.         goto        $+2
  578. DAWPLoad    call        PUNCTUATION
  579.         movwf       DATAL
  580.         call        DAWWrite
  581.         return
  582.  
  583. ;*****************************************************************************************
  584. ;**                                         **
  585. ;**             Function Messages                   **
  586. ;**                                         **
  587. ;*****************************************************************************************
  588.  
  589. Chan1       movlw       1
  590.         goto        $+6
  591. Chan2       movlw       2
  592.         goto        $+4
  593. Chan3       movlw       3
  594.         goto        $+2
  595. Chan4       movlw       4
  596.         movwf       AMPCHANNEL
  597.         call        Line2
  598.         call        AmpChannel
  599.         call        Select
  600.         call        Line3
  601.         call        AmpChannel
  602.         call        DAWSet
  603.         movfw       AMPCHANNEL
  604.         call        DAWDLoad
  605.         call        DAReset
  606.         movlw       5
  607.         goto        LineExit
  608.  
  609. ;*****************************************************************************************
  610.  
  611. MuteOn      call        Line3
  612.         call        Mute
  613.         call        Active
  614.         goto        $+4
  615. MuteOff     call        Line3
  616.         call        Mute
  617.         call        Bypass
  618.         movlw       6
  619.         call        LineClear
  620.         call        Line2
  621.         call        Mute
  622.         call        Select
  623.         movlw       9
  624.         goto        LineExit
  625.  
  626. ;*****************************************************************************************
  627.  
  628. MR2On       call        Line3
  629.         call        Master2
  630.         call        Active
  631.         goto        $+4
  632. MR2Off      call        Line3
  633.         call        Master2
  634.         call        Bypass
  635.         movlw       5
  636.         call        LineClear
  637.         call        Line2
  638.         call        Master2
  639.         call        Select
  640.         movlw       5
  641.         goto        LineExit
  642.  
  643. ;*****************************************************************************************
  644.  
  645. MCutOn      call        Line3
  646.         call        MidCut
  647.         call        Active
  648.         goto        $+4
  649. MCutOff     call        Line3
  650.         call        MidCut
  651.         call        Bypass
  652.         movlw       5
  653.         call        LineClear
  654.         call        Line2
  655.         call        MidCut
  656.         call        Select
  657.         movlw       5
  658.         goto        LineExit
  659.  
  660. ;*****************************************************************************************
  661.  
  662. FXOn        call        Line3
  663.         call        FXLoop
  664.         call        Active
  665.         goto        $+4
  666. FXOff       call        Line3
  667.         call        FXLoop
  668.         call        Bypass
  669.         movlw       5
  670.         call        LineClear
  671.         call        Line2
  672.         call        FXLoop
  673.         call        Select
  674.         movlw       5
  675.         goto        LineExit
  676.  
  677. ;*****************************************************************************************
  678.  
  679. Line2       movlw       154
  680.         goto        $+2
  681. Line3       movlw       230
  682.         movwf       DATAL
  683.         movlw       0x18
  684.         movwf       DATAH
  685.         call        ADDR_PTR
  686.         return
  687.  
  688. ;*****************************************************************************************
  689.  
  690. LineClear   movwf       COUNT1
  691.         call        DAWSet
  692.         movlw       0
  693.         call        DAWALoad
  694.         decfsz      COUNT1,F
  695.         goto        $-3
  696.         goto        WordExit
  697.  
  698. ;*****************************************************************************************
  699. ;**                                         **
  700. ;**             Data Messages                       **
  701. ;**                                         **
  702. ;*****************************************************************************************
  703.  
  704. ;Active
  705.  
  706. Active      call        DAWSet      ;enable data auto write mode
  707.         movlw       1       ;A
  708.         call        DAWALoad
  709.         movlw       3       ;C
  710.         call        DAWALoad
  711.         movlw       20      ;T
  712.         call        DAWALoad
  713.         movlw       9       ;I
  714.         call        DAWALoad
  715.         movlw       22      ;V
  716.         call        DAWALoad
  717.         movlw       5       ;E
  718.         call        DAWALoad
  719.         goto        WordExit
  720.  
  721. ;*****************************************************************************************
  722.  
  723. ;Bypass
  724.  
  725. Bypass      call        DAWSet      ;enable data auto write mode
  726.         movlw       2       ;B
  727.         call        DAWALoad
  728.         movlw       25      ;Y
  729.         call        DAWALoad
  730.         movlw       16      ;P
  731.         call        DAWALoad
  732.         movlw       1       ;A
  733.         call        DAWALoad
  734.         movlw       19      ;S
  735.         call        DAWALoad
  736.         movlw       19      ;S
  737.         call        DAWALoad
  738.         goto        WordExit
  739.  
  740. ;*****************************************************************************************
  741.  
  742. ;Channel
  743.  
  744. AmpChannel  call        DAWSet      ;enable data auto write mode
  745.         movlw       1       ;A
  746.         call        DAWALoad
  747.         movlw       13      ;M
  748.         call        DAWALoad
  749.         movlw       16      ;P
  750.         call        DAWALoad
  751.         movlw       0       ;
  752.         call        DAWALoad
  753.         movlw       3       ;C
  754.         call        DAWALoad
  755.         movlw       8       ;H
  756.         call        DAWALoad
  757.         movlw       1       ;A
  758.         call        DAWALoad
  759.         movlw       14      ;N
  760.         call        DAWALoad
  761.         movlw       14      ;N
  762.         call        DAWALoad
  763.         movlw       5       ;E
  764.         call        DAWALoad
  765.         movlw       12      ;L
  766.         call        DAWALoad
  767.         movlw       0       ;
  768.         call        DAWALoad
  769.         goto        WordExit
  770.  
  771. ;*****************************************************************************************
  772.  
  773. ;FX Loop
  774.  
  775. FXLoop      call        DAWSet      ;enable data auto write mode
  776.         movlw       6       ;F
  777.         call        DAWALoad
  778.         movlw       24      ;X
  779.         call        DAWALoad
  780.         movlw       0       ;
  781.         call        DAWALoad
  782.         movlw       12      ;L
  783.         call        DAWALoad
  784.         movlw       15      ;O
  785.         call        DAWALoad
  786.         movlw       15      ;O
  787.         call        DAWALoad
  788.         movlw       16      ;P
  789.         call        DAWALoad
  790.         movlw       0       ;
  791.         call        DAWALoad
  792.         goto        WordExit
  793.  
  794. ;*****************************************************************************************
  795.  
  796. ;Master 2
  797.  
  798. Master2     call        DAWSet      ;enable data auto write mode
  799.         movlw       13      ;M
  800.         call        DAWALoad
  801.         movlw       1       ;A
  802.         call        DAWALoad
  803.         movlw       19      ;S
  804.         call        DAWALoad
  805.         movlw       20      ;T
  806.         call        DAWALoad
  807.         movlw       5       ;E
  808.         call        DAWALoad
  809.         movlw       18      ;R
  810.         call        DAWALoad
  811.         movlw       0       ;
  812.         call        DAWALoad
  813.         movlw       2       ;2
  814.         call        DAWDLoad
  815.         movlw       0       ;
  816.         call        DAWALoad
  817.         goto        WordExit
  818.  
  819. ;*****************************************************************************************
  820.  
  821. ;Mid Cut
  822.  
  823. MidCut      call        DAWSet      ;enable data auto write mode
  824.         movlw       13      ;M
  825.         call        DAWALoad
  826.         movlw       9       ;I
  827.         call        DAWALoad
  828.         movlw       4       ;D
  829.         call        DAWALoad
  830.         movlw       0       ;
  831.         call        DAWALoad
  832.         movlw       3       ;C
  833.         call        DAWALoad
  834.         movlw       21      ;U
  835.         call        DAWALoad
  836.         movlw       20      ;T
  837.         call        DAWALoad
  838.         movlw       0       ;
  839.         call        DAWALoad
  840.         goto        WordExit
  841.  
  842. ;*****************************************************************************************
  843.  
  844. ;Mute
  845.  
  846. Mute        call        DAWSet      ;enable data auto write mode
  847.         movlw       13      ;M
  848.         call        DAWALoad
  849.         movlw       21      ;U
  850.         call        DAWALoad
  851.         movlw       20      ;T
  852.         call        DAWALoad
  853.         movlw       5       ;E
  854.         call        DAWALoad
  855.         movlw       0       ;
  856.         call        DAWALoad
  857.         goto        WordExit
  858.  
  859. ;*****************************************************************************************
  860.  
  861. ;Select
  862.  
  863. Select      call        DAWSet      ;enable auto data write mode
  864.         movlw       19      ;S
  865.         call        DAWALoad
  866.         movlw       5       ;E
  867.         call        DAWALoad
  868.         movlw       12      ;L
  869.         call        DAWALoad
  870.         movlw       5       ;E
  871.         call        DAWALoad
  872.         movlw       3       ;C
  873.         call        DAWALoad
  874.         movlw       20      ;T
  875.         call        DAWALoad
  876.         goto        WordExit
  877.  
  878. LineExit    call        LineClear
  879.         goto        $+2
  880. WordExit    call        DAReset     ;disable data auto write mode
  881.         return
  882.  
  883.         org     0x400
  884.  
  885. ;*****************************************************************************************
  886. ;**                                         **
  887. ;**             Initialization Routine                  **
  888. ;**                                         **
  889. ;*****************************************************************************************
  890.  
  891. START       movlw       0x05        ;Command mode, 6x8 font, reset
  892.         movwf       PORTA       ;init port output latches
  893.         clrf        PORTB
  894.         movlw       RW_DIS      ;read,write and ce disabled
  895.         movwf       PORTC
  896.         clrf        PORTD
  897.         clrf        PORTE
  898.         banksel     ANSEL       ;bank 3
  899.         clrf        ANSEL
  900.         clrf        ANSELH
  901.         banksel     TRISA       ;bank 1
  902.         clrf        TRISA       ;PORTA - PORTC, PORTE output
  903.         clrf        TRISB
  904.         movlw       b'10000000' ;RC7 = UART RX, RC0-RC6 output
  905.         movwf       TRISC
  906.         clrf        TRISD
  907.         clrf        TRISE
  908.  
  909. ;timer 0 init
  910.  
  911.         movlw       0xD7
  912.         movwf       OPTION_REG
  913.         movlw       195     ;set PR2 for 50mS overflow
  914.         movwf       PR2
  915.  
  916. ;UART init
  917.  
  918.         movlw       0x01        ;baud = 31.25K for MIDI
  919.         movwf       SPBRG
  920.         clrf        TXSTA       ;asynchronous serial, disable tx
  921.         banksel     0       ;bank 0
  922.         bsf     RCSTA,CREN  ;enable continuous rx
  923.  
  924. ;timer 2 init
  925.  
  926.         movlw       b'01111110' ;timer 2 1:16 prescaler
  927.         movwf       T2CON       ;and 1:16 postscaler
  928.  
  929. ;*****************************************************************************************
  930. ;**                                         **
  931. ;**             GLCD Initialization                 **
  932. ;**                                         **
  933. ;*****************************************************************************************
  934.  
  935. GLCDInit    call        Delay50mS   ;wait 50mS
  936.         bsf     RST     ;release GLCD reset
  937.        
  938. ;GLCD mode select - XOR mode w/CG-ROM
  939.  
  940.         movlw       XOR_CGROM
  941.         movwf       COMMAND
  942.         call        NoData
  943.  
  944. ;graphics home address set
  945.  
  946.         movlw       0x00
  947.         movwf       DATAL
  948.         movlw       0x00
  949.         movwf       DATAH
  950.         call        GRPH_HOME
  951.        
  952. ;graphics area set - 40 columns @ 6 pixels per column
  953.  
  954.         movlw       0x28
  955.         movwf       DATAL
  956.         movlw       0x00
  957.         movwf       DATAH
  958.         call        GRPH_AREA
  959.  
  960. ;text home address set - address 0x1700
  961.  
  962.         movlw       0x00
  963.         movwf       DATAL
  964.         movlw       0x17
  965.         movwf       DATAH
  966.         call        TXT_HOME
  967.  
  968. ;text area set - 40 columns @ 1 character per column
  969.  
  970.         movlw       0x28
  971.         movwf       DATAL
  972.         movlw       0x00
  973.         movwf       DATAH
  974.         call        TXT_AREA
  975.  
  976. ;set offset register - 0x03
  977.  
  978.         movlw       0x03
  979.         movwf       DATAL
  980.         movlw       0x00
  981.         movwf       DATAH
  982.         call        OFST_PTR
  983.  
  984. ;set address pointer to graphics home address
  985.  
  986.         movlw       0x00
  987.         movwf       DATAL
  988.         movlw       0x00
  989.         movwf       DATAH
  990.         call        ADDR_PTR
  991.  
  992. ;clear graphics RAM
  993.  
  994.         movlw       128
  995.         movwf       COUNT2
  996.         call        VRAMClear
  997.  
  998. ;set address pointer to text home address
  999.  
  1000.         movlw       0x00
  1001.         movwf       DATAL
  1002.         movlw       0x17
  1003.         movwf       DATAH
  1004.         call        ADDR_PTR
  1005.  
  1006. ;clear text RAM
  1007.  
  1008.         movlw       32
  1009.         movwf       COUNT2
  1010.         call        VRAMClear
  1011.  
  1012. ;set cursor pointer - position row 0 column 0
  1013.  
  1014.         movlw       5
  1015.         movwf       DATAL
  1016.         movlw       0
  1017.         movwf       DATAH
  1018.         call        CSR_PTR
  1019.  
  1020. ;set cursor pattern - single line cursor
  1021.  
  1022.         movlw       CSR1
  1023.         movwf       COMMAND
  1024.         call        NoData
  1025.  
  1026. ;set display mode - text & graphics RAM on, cursor off
  1027.  
  1028.         movlw       DIS_MODE7
  1029.         movwf       COMMAND
  1030.         call        NoData
  1031.  
  1032. ;*****************************************************************************************
  1033. ;**                                         **
  1034. ;**             Begin Main Program                  **
  1035. ;**                                         **
  1036. ;*****************************************************************************************
  1037.  
  1038.         movlw       40
  1039.         call        Delay
  1040.  
  1041. ;set address pointer to text home address
  1042.  
  1043.         movlw       0x33
  1044.         movwf       DATAL
  1045.         movlw       0x17
  1046.         movwf       DATAH
  1047.         call        ADDR_PTR
  1048.  
  1049. ;*****************************************************************************************
  1050. ;**                                         **
  1051. ;**             Splash Screen                       **
  1052. ;**                                         **
  1053. ;*****************************************************************************************
  1054.  
  1055.         call        DAWSet      ;enable data auto write mode
  1056.         movlw       19      ;S
  1057.         call        DAWALoad
  1058.         movlw       9       ;I
  1059.         call        DAWALoad
  1060.         movlw       14      ;N
  1061.         call        DAWALoad
  1062.         movlw       9       ;I
  1063.         call        DAWALoad
  1064.         movlw       19      ;S
  1065.         call        DAWALoad
  1066.         movlw       20      ;T
  1067.         call        DAWALoad
  1068.         movlw       5       ;E
  1069.         call        DAWALoad
  1070.         movlw       18      ;R
  1071.         call        DAWALoad
  1072.         movlw       0       ;
  1073.         call        DAWALoad
  1074.         movlw       4       ;D
  1075.         call        DAWALoad
  1076.         movlw       5       ;E
  1077.         call        DAWALoad
  1078.         movlw       19      ;S
  1079.         call        DAWALoad
  1080.         movlw       9       ;I
  1081.         call        DAWALoad
  1082.         movlw       7       ;G
  1083.         call        DAWALoad
  1084.         movlw       14      ;N
  1085.         call        DAWALoad
  1086.         movlw       19      ;S
  1087.         call        DAWALoad
  1088.         call        DAReset     ;disable data auto write mode
  1089.  
  1090.         movlw       40      ;wait 2 seconds
  1091.         call        Delay
  1092.  
  1093.         movlw       0x82
  1094.         movwf       DATAL
  1095.         movlw       0x17
  1096.         movwf       DATAH
  1097.         call        ADDR_PTR
  1098.  
  1099.         call        DAWSet      ;enable data auto write mode
  1100.         movlw       4       ;D
  1101.         call        DAWALoad
  1102.         movlw       9       ;I
  1103.         call        DAWALoad
  1104.         movlw       5       ;E
  1105.         call        DAWALoad
  1106.         movlw       26      ;Z
  1107.         call        DAWALoad
  1108.         movlw       5       ;E
  1109.         call        DAWALoad
  1110.         movlw       12      ;L
  1111.         call        DAWALoad
  1112.         movlw       0       ;
  1113.         call        DAWALoad
  1114.         movlw       8       ;H
  1115.         call        DAWALoad
  1116.         movlw       5       ;E
  1117.         call        DAWALoad
  1118.         movlw       18      ;R
  1119.         call        DAWALoad
  1120.         movlw       2       ;B
  1121.         call        DAWALoad
  1122.         movlw       5       ;E
  1123.         call        DAWALoad
  1124.         movlw       18      ;R
  1125.         call        DAWALoad
  1126.         movlw       20      ;T
  1127.         call        DAWALoad
  1128.         movlw       14      ;/
  1129.         call        DAWPLoad
  1130.         movlw       22      ;V
  1131.         call        DAWALoad
  1132.         movlw       8       ;H
  1133.         call        DAWALoad
  1134.         movlw       4       ;4
  1135.         call        DAWDLoad
  1136.         call        DAReset     ;disable data auto write mode
  1137.  
  1138.         movlw       40      ;wait 2 seconds
  1139.         call        Delay
  1140.  
  1141.         movlw       0xD0
  1142.         movwf       DATAL
  1143.         movlw       0x17
  1144.         movwf       DATAH
  1145.         call        ADDR_PTR
  1146.  
  1147.         call        DAWSet      ;enable data auto write mode
  1148.         movlw       6       ;F
  1149.         call        DAWALoad
  1150.         movlw       15      ;O
  1151.         call        DAWALoad
  1152.         movlw       15      ;O
  1153.         call        DAWALoad
  1154.         movlw       20      ;T
  1155.         call        DAWALoad
  1156.         movlw       19      ;S
  1157.         call        DAWALoad
  1158.         movlw       23      ;W
  1159.         call        DAWALoad
  1160.         movlw       9       ;I
  1161.         call        DAWALoad
  1162.         movlw       20      ;T
  1163.         call        DAWALoad
  1164.         movlw       3       ;C
  1165.         call        DAWALoad
  1166.         movlw       8       ;H
  1167.         call        DAWALoad
  1168.         movlw       0       ;
  1169.         call        DAWALoad
  1170.         movlw       4       ;D
  1171.         call        DAWALoad
  1172.         movlw       5       ;E
  1173.         call        DAWALoad
  1174.         movlw       3       ;C
  1175.         call        DAWALoad
  1176.         movlw       15      ;O
  1177.         call        DAWALoad
  1178.         movlw       4       ;D
  1179.         call        DAWALoad
  1180.         movlw       5       ;E
  1181.         call        DAWALoad
  1182.         movlw       18      ;R
  1183.         call        DAWALoad
  1184.         movlw       0       ;
  1185.         call        DAWALoad
  1186.         movlw       20      ;T
  1187.         call        DAWALoad
  1188.         movlw       15      ;O
  1189.         call        DAWALoad
  1190.         movlw       15      ;O
  1191.         call        DAWALoad
  1192.         movlw       12      ;L
  1193.         call        DAWALoad
  1194.         call        DAReset     ;disable data auto write mode
  1195.  
  1196.         movlw       40      ;wait 2 seconds
  1197.         call        Delay
  1198.  
  1199.         bcf     T2CON,1     ;change timer 2 to allow 1mS delay
  1200.         banksel     PR2
  1201.         movlw       64
  1202.         movwf       PR2
  1203.         banksel     0
  1204.  
  1205.         movlw       0x00        ;address pointer to graphics home address
  1206.         movwf       DATAL
  1207.         movlw       0x00
  1208.         movwf       DATAH
  1209.         call        ADDR_PTR
  1210.  
  1211.         movlw       63
  1212.         movwf       DATAL
  1213.         movlw       64
  1214.         movwf       COUNT2
  1215.         movlw       2
  1216.         movwf       COUNT3
  1217.  
  1218. SCROLL      call        DAWSet
  1219.         movlw       40
  1220.         movwf       COUNT1
  1221.         call        DAWWrite
  1222.         call        Delay50mS
  1223.         decfsz      COUNT1,F
  1224.         goto        $-3
  1225.         decfsz      COUNT2,F
  1226.         goto        $-7
  1227.         call        DAReset
  1228.  
  1229.         movlw       0x00
  1230.         movwf       DATAL
  1231.         movlw       0x00
  1232.         movwf       DATAH
  1233.         call        ADDR_PTR
  1234.  
  1235.         movlw       0
  1236.         movwf       DATAL
  1237.         movlw       64
  1238.         movwf       COUNT2
  1239.         decfsz      COUNT3,F
  1240.         goto        SCROLL
  1241.  
  1242.         bsf     T2CON,1     ;change timer 2 to allow for 50mS delay
  1243.         banksel     PR2
  1244.         movlw       195
  1245.         movwf       PR2
  1246.         banksel     0
  1247.  
  1248. ;*****************************************************************************************
  1249. ;**                                         **
  1250. ;**             Main Screen                     **
  1251. ;**                                         **
  1252. ;*****************************************************************************************
  1253.  
  1254.         movlw       0x40
  1255.         movwf       DATAL
  1256.         movlw       0x18
  1257.         movwf       DATAH
  1258.         call        ADDR_PTR
  1259.  
  1260.         call        DAWSet      ;enable data auto write mode
  1261.         movlw       13      ;M
  1262.         call        DAWALoad
  1263.         movlw       9       ;I
  1264.         call        DAWALoad
  1265.         movlw       4       ;D
  1266.         call        DAWALoad
  1267.         movlw       9       ;I
  1268.         call        DAWALoad
  1269.         movlw       0       ;
  1270.         call        DAWALoad
  1271.         movlw       3       ;C
  1272.         call        DAWALoad
  1273.         movlw       8       ;H
  1274.         call        DAWALoad
  1275.         movlw       1       ;A
  1276.         call        DAWALoad
  1277.         movlw       14      ;N
  1278.         call        DAWALoad
  1279.         movlw       14      ;N
  1280.         call        DAWALoad
  1281.         movlw       5       ;E
  1282.         call        DAWALoad
  1283.         movlw       12      ;L
  1284.         call        DAWALoad
  1285.         movlw       15      ;:
  1286.         call        DAWPLoad
  1287.         call        DAReset     ;disable data auto write mode
  1288.  
  1289.         movlw       144
  1290.         movwf       DATAL
  1291.         movlw       0x18
  1292.         movwf       DATAH
  1293.         call        ADDR_PTR
  1294.  
  1295.         call        DAWSet      ;enable data auto write mode
  1296.         movlw       6       ;F
  1297.         call        DAWALoad
  1298.         movlw       21      ;U
  1299.         call        DAWALoad
  1300.         movlw       14      ;N
  1301.         call        DAWALoad
  1302.         movlw       3       ;C
  1303.         call        DAWALoad
  1304.         movlw       20      ;T
  1305.         call        DAWALoad
  1306.         movlw       9       ;I
  1307.         call        DAWALoad
  1308.         movlw       15      ;O
  1309.         call        DAWALoad
  1310.         movlw       14      ;N
  1311.         call        DAWALoad
  1312.         movlw       15      ;:
  1313.         call        DAWPLoad
  1314.         call        DAReset     ;disable data auto write mode
  1315.  
  1316.         movlw       224
  1317.         movwf       DATAL
  1318.         movlw       0x18
  1319.         movwf       DATAH
  1320.         call        ADDR_PTR
  1321.  
  1322.         call        DAWSet      ;enable data auto write mode
  1323.         movlw       4       ;D
  1324.         call        DAWALoad
  1325.         movlw       1       ;A
  1326.         call        DAWALoad
  1327.         movlw       20      ;T
  1328.         call        DAWALoad
  1329.         movlw       1       ;A
  1330.         call        DAWALoad
  1331.         movlw       15      ;:
  1332.         call        DAWPLoad
  1333.         movlw       0       ;
  1334.         call        DAWALoad
  1335.         call        DAReset     ;disable data auto write mode
  1336.  
  1337.         movlw       40      ;wait 2 seconds
  1338.         call        Delay
  1339.  
  1340.         movlw       6
  1341.         movwf       COUNT1
  1342.         movlw       2
  1343.         movwf       COUNT2
  1344.  
  1345.         movlw       40
  1346.         movwf       DATAL
  1347.         movlw       0x17
  1348.         movwf       DATAH
  1349. TXTScroll   call        TXT_HOME
  1350.  
  1351.         movlw       2
  1352.         call        Delay
  1353.  
  1354.         movlw       40
  1355.         addwf       DATAL,F
  1356.         decfsz      COUNT1,F
  1357.         goto        TXTScroll
  1358.  
  1359.         incf        DATAH,F
  1360.         movlw       2
  1361.         movwf       COUNT1
  1362.         decfsz      COUNT2,F
  1363.         goto        TXTScroll
  1364.  
  1365. ;Initialization is complete at this point. Unit will begin to recieve/process/display
  1366. ;MIDI data from the Diezel Herbert/VH4 controller from here on out.
  1367.  
  1368. ;*****************************************************************************************
  1369. ;**                                         **
  1370. ;**             MIDI Receive/Process                    **
  1371. ;**                                         **
  1372. ;*****************************************************************************************
  1373.  
  1374. MAIN        clrf        MIDIFLAGS   ;clear MIDI flags
  1375.         bsf     RCSTA,SPEN  ;enable serial port
  1376.         banksel     PIE1        ;bank 1
  1377.         bsf     PIE1,RCIE   ;enable serial rx interrupt
  1378.         banksel     0       ;bank 0
  1379.         clrf        TMR0        ;clear timer 0
  1380.         movlw       b'11100000' ;enable timer 0 and serial rx interrupts
  1381.         movwf       INTCON
  1382.        
  1383.         goto        $       ;wait for interrupts
  1384.  
  1385.         end             ;end of file
Add Comment
Please, Sign In to add comment