Guest User

Untitled

a guest
Apr 20th, 2018
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MPASM 17.15 KB | None | 0 0
  1. ;*************************************************************************************************
  2. ;*************************************************************************************************
  3. ;**                                             **
  4. ;**             16F887 Graphic LCD Driver                   **
  5. ;**              For Toshiba T6963C 240 x 64 GLCD                   **
  6. ;**                    By Jon Wilder                        **
  7. ;**                       Date: 12/01/2011                      **
  8. ;**                                             **
  9. ;*************************************************************************************************
  10. ;*************************************************************************************************
  11. ;**                                             **
  12. ;**             Header Information/Config Options               **
  13. ;**                                             **
  14. ;**                                             **
  15. ;**                                             **
  16. ;** Processor Type: PIC 16F887                                  **
  17. ;** Default Radix: Decimal                                  **
  18. ;** Error Level: -302/Suppress all assembler bank select warnings               **
  19. ;** Reference header file P16F887.INC for SFR and Config option labels              **
  20. ;**                                             **
  21. ;** Configuration Word 1                                    **
  22. ;**                                             **
  23. ;** In Circuit Debug Off (Default)                              **
  24. ;** Low Voltage Programming Off                                 **
  25. ;** Fail Safe Clock Monitor Off                                 **
  26. ;** Internal External Switchover Off                                **
  27. ;** Brown Out Reset Off                                     **
  28. ;** Data Code Protection Off (Default)                              **
  29. ;** Code Protection Off (Default)                               **
  30. ;** RA5 has MCLR Function (Default)                             **
  31. ;** Power Up Timer On                                       **
  32. ;** Watchdog Timer Off                                      **
  33. ;** High Speed XT Oscillator                                    **
  34. ;**                                             **
  35. ;** Configuration Word 2                                    **
  36. ;**                                             **
  37. ;** Program ROM Write Protection Off (Default)                          **
  38. ;** Brown Out Reset 4.0V (Default)                              **
  39. ;**                                             **
  40. ;** Fosc = 16MHz                                        **
  41. ;**                                             **
  42. ;*************************************************************************************************
  43. ;*************************************************************************************************
  44.  
  45.         list        p=16F887, r=dec, w=-302
  46.         include     <P16F887.INC>
  47.         include     "T6963CGLCD.INC"
  48.         __config    _CONFIG1, _LVP_OFF & _FCMEN_OFF & _IESO_OFF & _BOR_OFF & _PWRTE_ON & _WDT_OFF & _FOSC_HS
  49.  
  50. ;*************************************************************************************************
  51. ;**                                             **
  52. ;**             RAM Location Constants                      **
  53. ;**                                             **
  54. ;*************************************************************************************************
  55.  
  56.         cblock      0x20
  57.                 TEMP            ;temp buffer
  58.                 DATAL           ;instruction data low byte
  59.                 DATAH           ;instruction data high byte
  60.                 COMMAND         ;instruction
  61.                 TABLECOUNT      ;table counter
  62.         endc
  63.  
  64.         cblock      0x70
  65.                 W_TEMP          ;interrupt context save for W
  66.                 STATUS_TEMP     ;interrupt context save for STATUS
  67.                 PCLATH_TEMP     ;interrupt context save for PCLATH
  68.                 COUNT1          ;delay counter 1
  69.                 COUNT2          ;delay counter 2
  70.                 COUNT3          ;delay counter 3
  71.                 DATA_EE_ADDR        ;data EEPROM address buffer
  72.                 DATA_EE_DATA        ;data EEPROM data buffer
  73.                 CASEFLAGS       ;used to indicate upper/lower case
  74.         endc
  75.  
  76. ;*************************************************************************************************
  77. ;**                                             **
  78. ;**             Control/Data Line Labels                    **
  79. ;**                                             **
  80. ;*************************************************************************************************
  81.  
  82. ;nemonics used for read/write enable/disable
  83.  
  84. WR_EN       EQU     2           ;write mode enable
  85. WR_DIS      EQU     7           ;write mode disable
  86. RD_EN       EQU     1           ;read mode enable
  87. RD_DIS      EQU     7           ;read mode disable
  88.  
  89. ;control lines
  90.  
  91. #define     CD      PORTA,RA0       ;GLCD command/data
  92. #define     RST     PORTA,RA1       ;GLCD reset
  93. #define     FONT        PORTA,RA2       ;GLCD font select (6x8 or 8x8)
  94. #define     WRITE       PORTC,RC0       ;GLCD write enable/disable (active low)
  95. #define     READ        PORTC,RC1       ;GLCD read enable/disable (active low)
  96. #define     CE      PORTC,RC2       ;GLCD chip enable/disable (active low)
  97.  
  98. ;data port
  99.  
  100. #define     D0      PORTD,RD0       ;GLCD data port bit 0
  101. #define     D1      PORTD,RD1       ;GLCD data port bit 1
  102. #define     D2      PORTD,RD2       ;GLCD data port bit 2
  103. #define     D3      PORTD,RD3       ;GLCD data port bit 3
  104. #define     D4      PORTD,RD4       ;GLCD data port bit 4
  105. #define     D5      PORTD,RD5       ;GLCD data port bit 5
  106. #define     D6      PORTD,RD6       ;GLCD data port bit 6
  107. #define     D7      PORTD,RD7       ;GLCD data port bit 7
  108.  
  109. ;*************************************************************************************************
  110. ;**                                             **
  111. ;**             Start of Main Code                      **
  112. ;**                                             **
  113. ;*************************************************************************************************
  114.  
  115.         org         0x000           ;reset vector
  116.         goto        START           ;jump to start of main code
  117.  
  118.         org         0x004           ;interrupt vector
  119.         goto        ISR         ;jump to start of interrupt handler
  120.  
  121.  
  122. ;digit look up table
  123.  
  124. DIGIT       addwf       PCL,F
  125.         retlw       0x10            ;0
  126.         retlw       0x11            ;1
  127.         retlw       0x12            ;2
  128.         retlw       0x13            ;3
  129.         retlw       0x14            ;4
  130.         retlw       0x15            ;5
  131.         retlw       0x16            ;6
  132.         retlw       0x17            ;7
  133.         retlw       0x18            ;8
  134.         retlw       0x19            ;9
  135.         retlw       0x21            ;A
  136.         retlw       0x22            ;B
  137.         retlw       0x23            ;C
  138.         retlw       0x24            ;D
  139.         retlw       0x25            ;E
  140.         retlw       0x26            ;F
  141.  
  142. ;upper case look up table
  143. ;(add offset of 0x20 to fetched table value to convert to lower case)
  144.  
  145. ALPHA       addwf       PCL,F
  146.         retlw       0           ;space
  147.         retlw       0x21            ;A
  148.         retlw       0x22            ;B
  149.         retlw       0x23            ;C
  150.         retlw       0x24            ;D
  151.         retlw       0x25            ;E
  152.         retlw       0x26            ;F
  153.         retlw       0x27            ;G
  154.         retlw       0x28            ;H
  155.         retlw       0x29            ;I
  156.         retlw       0x2A            ;J
  157.         retlw       0x2B            ;K
  158.         retlw       0x2C            ;L
  159.         retlw       0x2D            ;M
  160.         retlw       0x2E            ;N
  161.         retlw       0x2F            ;O
  162.         retlw       0x30            ;P
  163.         retlw       0x31            ;Q
  164.         retlw       0x32            ;R
  165.         retlw       0x33            ;S
  166.         retlw       0x34            ;T
  167.         retlw       0x35            ;U
  168.         retlw       0x36            ;V
  169.         retlw       0x37            ;W
  170.         retlw       0x38            ;X
  171.         retlw       0x39            ;Y
  172.         retlw       0x3A            ;Z
  173.  
  174. ;*************************************************************************************************
  175. ;**                                             **
  176. ;**             Initialization Routine                      **
  177. ;**                                             **
  178. ;*************************************************************************************************
  179.  
  180. START       clrf        PORTA           ;init ports
  181.         clrf        PORTB
  182.         clrf        PORTC
  183.         clrf        PORTD
  184.         clrf        PORTE
  185.         banksel     ANSEL           ;bank 3
  186.         clrf        ANSEL           ;all ports digital I/O
  187.         clrf        ANSELH
  188.         banksel     TRISA           ;bank 1
  189.         clrf        TRISA           ;PORTA, PORTB, PORTC, and PORTE outputs
  190.         clrf        TRISB           ;PORTD defaults to input
  191.         clrf        TRISC
  192.         clrf        TRISE
  193.         banksel     0           ;bank 0
  194.         clrf        CASEFLAGS
  195.  
  196. GLCD_INIT   bcf     RST         ;reset GLCD
  197.         movlw       5           ;Command mode and 6x8 font
  198.         movwf       PORTA
  199.         movlw       7           ;disable read, write, and chip enable
  200.         movwf       PORTC
  201.         call        Delay50mS       ;wait 50mS
  202.         bsf     RST         ;disable reset
  203.  
  204. ;set operating mode
  205.  
  206. ModeSet     movlw       XOR_CGROM       ;text attribute mode with CG ROM on
  207.         movwf       COMMAND
  208.         call        NoData
  209.  
  210.  
  211. ;graphics RAM start address 0x0000
  212.  
  213. GraphicsHome    movlw       0
  214.         movwf       DATAL
  215.         movlw       0
  216.         movwf       DATAH
  217.         call        GRPHHome
  218.  
  219. ;graphics area 40 rows for 240x64 display
  220.  
  221. GraphicsArea    movlw       0x28
  222.         movwf       DATAL
  223.         movlw       0
  224.         movwf       DATAH
  225.         call        GRPHArea
  226.  
  227. ;text RAM start address 0x1700
  228.  
  229. TextHome    movlw       0
  230.         movwf       DATAL
  231.         movlw       0x17
  232.         movwf       DATAH
  233.         call        TXTHome
  234.  
  235. ;text area 40 rows for 240x64 display
  236.  
  237. TextArea    movlw       0x28
  238.         movwf       DATAL
  239.         movlw       0
  240.         movwf       DATAH
  241.         call        TXTArea
  242.  
  243. ;set offset register
  244.  
  245. CGROMSet    movlw       0x03
  246.         movwf       DATAL
  247.         movlw       0
  248.         movwf       DATAH
  249.         call        CGROM
  250.  
  251. ;clear graphics RAM
  252.  
  253.         movlw       0           ;set start address to 0x00
  254.         movwf       DATAL
  255.         movlw       0
  256.         movwf       DATAH
  257.         movlw       20
  258.         movwf       COUNT2
  259.         call        DisplayClear
  260.  
  261. ;clear text RAM
  262.  
  263.         movlw       0           ;set start address to 0x17
  264.         movwf       DATAL
  265.         movlw       0x17
  266.         movwf       DATAH
  267.         movlw       2
  268.         movwf       COUNT2
  269.         call        DisplayClear
  270.  
  271. ;single line cursor
  272.  
  273. CSRPattern  movlw       0xA0
  274.         movwf       COMMAND
  275.         call        NoData
  276.  
  277. ;set cursor pointer on line 0 column 0
  278.  
  279. CSRPointer  movlw       26
  280.         movwf       DATAL
  281.         movlw       5
  282.         movwf       DATAH
  283.         call        CSR_PTR
  284.  
  285. ;text and graphics RAM on, cursor on with cursor blink
  286.  
  287. DisplayOn   movlw       0x9F
  288.         movwf       COMMAND
  289.         call        NoData
  290.  
  291.  
  292. ;position address pointer on line 0, column 6
  293.  
  294.         movlw       240
  295.         movwf       COUNT1
  296.         movlw       20
  297.         movwf       COUNT2
  298.  
  299.         movlw       0           ;set address pointer
  300.         movwf       DATAL
  301.         movlw       0x0
  302.         movwf       DATAH
  303.         call        ADDR_PTR
  304.  
  305.         call        DAWSet          ;enable data auto write
  306.         movlw       0xFF            ;back shade display
  307.         movwf       DATAL          
  308.         call        DAWrite
  309.         decfsz      COUNT1,F
  310.         goto        $-2
  311.         decfsz      COUNT2,F
  312.         goto        $-4
  313.         call        DAWReset        ;disable auto write
  314.  
  315.         movlw       46          ;set address pointer
  316.         movwf       DATAL
  317.         movlw       0x17
  318.         movwf       DATAH
  319.         call        ADDR_PTR
  320.  
  321.         call        DAWSet          ;enable data auto write
  322.  
  323.         movlw       16          ;P
  324.         call        DAWALoad
  325.  
  326.         movlw       9           ;I
  327.         call        DAWALoad
  328.  
  329.         movlw       3           ;C
  330.         call        DAWALoad
  331.  
  332.         movlw       1           ;1
  333.         call        DAWDLoad
  334.  
  335.         movlw       6           ;6
  336.         call        DAWDLoad
  337.  
  338.         movlw       6           ;F
  339.         call        DAWALoad
  340.  
  341.         movlw       8           ;8
  342.         call        DAWDLoad
  343.  
  344.         movlw       8           ;8
  345.         call        DAWDLoad
  346.  
  347.         movlw       7           ;7
  348.         call        DAWDLoad
  349.  
  350.         movlw       0           ;
  351.         call        DAWALoad
  352.  
  353.         movlw       7           ;G
  354.         call        DAWALoad
  355.  
  356.         movlw       18          ;R
  357.         call        DAWALoad
  358.  
  359.         movlw       1           ;A
  360.         call        DAWALoad
  361.  
  362.         movlw       16          ;P
  363.         call        DAWALoad
  364.  
  365.         movlw       8           ;H
  366.         call        DAWALoad
  367.  
  368.         movlw       9           ;I
  369.         call        DAWALoad
  370.  
  371.         movlw       3           ;C
  372.         call        DAWALoad
  373.  
  374.         movlw       0           ;
  375.         call        DAWALoad
  376.  
  377.         movlw       12          ;L
  378.         call        DAWALoad
  379.  
  380.         movlw       3           ;C
  381.         call        DAWALoad
  382.  
  383.         movlw       4           ;D
  384.         call        DAWALoad
  385.  
  386.         movlw       0           ;
  387.         call        DAWALoad
  388.  
  389.         movlw       4           ;D
  390.         call        DAWALoad
  391.  
  392.         movlw       18          ;R
  393.         call        DAWALoad
  394.  
  395.         movlw       9           ;I
  396.         call        DAWALoad
  397.  
  398.         movlw       22          ;V
  399.         call        DAWALoad
  400.  
  401.         movlw       5           ;E
  402.         call        DAWALoad
  403.  
  404.         movlw       18          ;R
  405.         call        DAWALoad
  406.  
  407.         call        DAWReset        ;disable data auto write
  408.  
  409.         movlw       125         ;set address pointer
  410.         movwf       DATAL
  411.         movlw       0x17
  412.         movwf       DATAH
  413.         call        ADDR_PTR
  414.  
  415.         call        DAWSet          ;enable data auto write
  416.  
  417.         movlw       6           ;F
  418.         call        DAWALoad
  419.  
  420.         movlw       15          ;O
  421.         call        DAWALoad
  422.  
  423.         movlw       18          ;R
  424.         call        DAWALoad
  425.  
  426.         movlw       0           ;
  427.         call        DAWALoad
  428.  
  429.         movlw       20          ;T
  430.         call        DAWALoad
  431.  
  432.         movlw       15          ;O
  433.         call        DAWALoad
  434.  
  435.         movlw       19          ;S
  436.         call        DAWALoad
  437.  
  438.         movlw       8           ;H
  439.         call        DAWALoad
  440.  
  441.         movlw       9           ;I
  442.         call        DAWALoad
  443.  
  444.         movlw       2           ;B
  445.         call        DAWALoad
  446.  
  447.         movlw       1           ;A
  448.         call        DAWALoad
  449.  
  450.         movlw       0           ;
  451.         call        DAWALoad
  452.  
  453.         movlw       20          ;T
  454.         call        DAWALoad
  455.  
  456.         movlw       6           ;6
  457.         call        DAWDLoad
  458.  
  459.         movlw       9           ;9
  460.         call        DAWDLoad
  461.  
  462.         movlw       6           ;6
  463.         call        DAWDLoad
  464.  
  465.         movlw       3           ;3
  466.         call        DAWDLoad
  467.  
  468.         movlw       3           ;C
  469.         call        DAWALoad
  470.  
  471.         movlw       0           ;
  472.         call        DAWALoad
  473.  
  474.         movlw       2           ;2
  475.         call        DAWDLoad
  476.  
  477.         movlw       4           ;4
  478.         call        DAWDLoad
  479.  
  480.         movlw       0           ;0
  481.         call        DAWDLoad
  482.  
  483.         bsf     CASEFLAGS,0
  484.         movlw       24          ;x
  485.         call        DAWALoad
  486.  
  487.         movlw       6           ;6
  488.         call        DAWDLoad
  489.  
  490.         movlw       4           ;4
  491.         call        DAWDLoad
  492.  
  493.         movlw       0           ;
  494.         call        DAWALoad
  495.  
  496.         movlw       7           ;G
  497.         call        DAWALoad
  498.  
  499.         movlw       12          ;L
  500.         call        DAWALoad
  501.  
  502.         movlw       3           ;C
  503.         call        DAWALoad
  504.  
  505.         movlw       4           ;D
  506.         call        DAWALoad
  507.  
  508.         call        DAWReset        ;disable data auto write
  509.  
  510.         movlw       213         ;set address pointer
  511.         movwf       DATAL
  512.         movlw       0x17
  513.         movwf       DATAH
  514.         call        ADDR_PTR
  515.  
  516.         call        DAWSet          ;enable data auto write
  517.  
  518.         movlw       2           ;B
  519.         call        DAWALoad
  520.  
  521.         movlw       25          ;Y
  522.         call        DAWALoad
  523.  
  524.         movlw       0           ;
  525.         call        DAWALoad
  526.  
  527.         movlw       10          ;J
  528.         call        DAWALoad
  529.  
  530.         movlw       15          ;O
  531.         call        DAWALoad
  532.  
  533.         movlw       14          ;N
  534.         call        DAWALoad
  535.  
  536.         movlw       0           ;
  537.         call        DAWALoad
  538.  
  539.         movlw       23          ;W
  540.         call        DAWALoad
  541.  
  542.         movlw       9           ;I
  543.         call        DAWALoad
  544.  
  545.         movlw       12          ;L
  546.         call        DAWALoad
  547.  
  548.         movlw       4           ;D
  549.         call        DAWALoad
  550.  
  551.         movlw       5           ;E
  552.         call        DAWALoad
  553.  
  554.         movlw       18          ;R
  555.         call        DAWALoad
  556.  
  557.         call        DAWReset        ;disable data auto write
  558.  
  559.         goto        $
  560.  
  561. ;*************************************************************************************************
  562. ;**                                             **
  563. ;**             Delay Loops                         **
  564. ;**                                             **
  565. ;*************************************************************************************************
  566.  
  567. ;fixed 50mS delay
  568.  
  569. Delay50mS   movlw       0xFF
  570.         movwf       COUNT1
  571.         movwf       COUNT2
  572.         decfsz      COUNT1,F
  573.         goto        $-1
  574.         decfsz      COUNT2,F
  575.         goto        $-3
  576.         return
  577.  
  578. ;*************************************************************************************************
  579.  
  580. ;variable delay
  581.  
  582. Delay       movwf       COUNT3
  583.         call        Delay50mS
  584.         decfsz      COUNT3,F
  585.         goto        $-2
  586.         return
  587.  
  588. ;*************************************************************************************************
  589. ;**                                             **
  590. ;**             Two Data Byte Instructions                  **
  591. ;**                                             **
  592. ;*************************************************************************************************
  593.  
  594. CGROM       movlw       0x22
  595.         goto        CSend
  596. ADDR_PTR    movlw       0x24
  597.         goto        CSend
  598. CSR_PTR     movlw       0x21
  599.         goto        CSend
  600. GRPHHome    movlw       0x42
  601.         goto        CSend
  602. GRPHArea    movlw       0x43
  603.         goto        CSend
  604. TXTHome     movlw       0x40
  605.         goto        CSend
  606. TXTArea     movlw       0x41
  607.         goto        CSend
  608. CSend       movwf       COMMAND
  609.         call        TwoData
  610.         return
  611.  
  612. ;*************************************************************************************************
  613. ;**                                             **
  614. ;**             Data Auto Read/Write Routines                   **
  615. ;**                                             **
  616. ;*************************************************************************************************
  617.  
  618. DAWSet      movlw       0xB0
  619.         movwf       COMMAND
  620.         call        NoData
  621.         call        LCDStat
  622.         call        DAWStat
  623.         return
  624.  
  625. ;*************************************************************************************************
  626.  
  627. DAWReset    call        DAWStat
  628.         movlw       0xB2
  629.         movwf       COMMAND
  630.         call        NoData
  631.         return
  632.  
  633. ;*************************************************************************************************
  634.  
  635. ;check data auto write ready bit
  636.  
  637. DAWStat     call        StatReadEn      ;enable status read
  638.         btfss       D3          ;auto write ready?
  639.         goto        $-1
  640.         call        StatReadDis     ;disable status read
  641.         return
  642.  
  643. ;*************************************************************************************************
  644.  
  645. DAWrite     call        DAWStat
  646.         movfw       DATAL
  647.         call        DWrite
  648.         return
  649.  
  650. ;*************************************************************************************************
  651.  
  652. DAWALoad    call        ALPHA
  653.         btfsc       CASEFLAGS,0
  654.         addlw       0x20
  655.         goto        $+2
  656. DAWDLoad    call        DIGIT
  657.         movwf       DATAL
  658.         call        DAWrite
  659.         bcf     CASEFLAGS,0
  660.         return
  661.  
  662. ;*************************************************************************************************
  663. ;**                                             **
  664. ;**             Command Send Routines                       **
  665. ;**                                             **
  666. ;*************************************************************************************************
  667.  
  668. TwoData     call        LCDStat
  669.         movfw       DATAL
  670.         call        DWrite
  671. OneData     call        LCDStat
  672.         movfw       DATAH
  673.         call        DWrite
  674. NoData      call        LCDStat
  675.         movfw       COMMAND
  676.         call        Command
  677.         return
  678.  
  679. ;*************************************************************************************************
  680. ;**                                             **
  681. ;**             GLCD Read/Write/Status Check                    **
  682. ;**                                             **
  683. ;*************************************************************************************************
  684.  
  685. ;command/data write
  686.  
  687. Command     bsf     CD          ;command mode
  688.         goto        $+2
  689. DWrite      bcf     CD          ;data mode
  690.         movwf       PORTD           ;place write data on data port latch
  691.         movlw       WR_EN           ;chip enable low
  692.         movwf       PORTC           ;enable write
  693.         banksel     TRISD           ;bank 1
  694.         clrf        TRISD           ;RD0-RD7 output
  695.         banksel     0           ;bank 0
  696.         movlw       WR_DIS          ;disable write
  697.         movwf       PORTC           ;chip enable high
  698.         banksel     TRISD           ;bank 1
  699.         comf        TRISD,F         ;RD0-RD7 input
  700.         banksel     0           ;bank 0
  701.         return
  702.  
  703. ;*************************************************************************************************
  704.  
  705. ;check GLCD status
  706.  
  707. LCDStat     call        StatReadEn      ;enable status read
  708.         btfsc       D0          ;is GLCD ready?
  709.         btfss       D1
  710.         goto        $-2         ;no, check again
  711.         call        StatReadDis     ;disable status read
  712.         return
  713.  
  714. ;*************************************************************************************************
  715.  
  716. ;GLCD status read enable
  717.  
  718. StatReadEn  bsf     CD          ;command mode
  719.         movlw       RD_EN           ;enable read
  720.         movwf       PORTC
  721.         return
  722.  
  723. ;*************************************************************************************************
  724.  
  725. ;GLCD status read disable
  726.  
  727. StatReadDis movlw       RD_DIS          ;disable read
  728.         movwf       PORTC
  729.         return
  730.  
  731. ;*************************************************************************************************
  732. ;**                                             **
  733. ;**                 Clear Display                       **
  734. ;**                                             **
  735. ;*************************************************************************************************
  736.  
  737. DisplayClear    movlw       160         ;init counters
  738.         movwf       COUNT1          ;to clear 320 VRAM locations
  739.         call        ADDR_PTR        ;set address pointer
  740.         call        DAWSet
  741.         call        DAWStat
  742.         movlw       0           ;write 0 to display
  743.         call        DWrite
  744.         decfsz      COUNT1,F        ;decrement COUNT1 and continue writing
  745.         goto        $-4         ;data if COUNT1 > 0
  746.         movlw       160         ;re-init COUNT1
  747.         movwf       COUNT1          ;decrement COUNT2 and continue writing
  748.         decfsz      COUNT2,F        ;data if COUNT2 > 0
  749.         goto        $-8
  750.         call        DAWReset
  751.         return                  ;done
  752.  
  753. ;*************************************************************************************************
  754. ;**                                             **
  755. ;**             Interrupt Handler                       **
  756. ;**                                             **
  757. ;*************************************************************************************************
  758.  
  759. ;interrupt context save
  760.  
  761. ISR     movwf       W_TEMP
  762.         swapf       STATUS,W
  763.         banksel     0           ;bank 0
  764.         movwf       STATUS_TEMP
  765.         movfw       PCLATH
  766.         movwf       PCLATH_TEMP
  767.  
  768. ;interrupt code goes here
  769.  
  770. ;interrupt context restore
  771.  
  772. ISRExit     movfw       PCLATH_TEMP
  773.         movwf       PCLATH
  774.         swapf       STATUS_TEMP,W
  775.         movwf       STATUS
  776.         swapf       W_TEMP,F
  777.         swapf       W_TEMP,W
  778.         retfie
  779.  
  780.         end
Add Comment
Please, Sign In to add comment