PIC microcontroller timer interrupt

Publisher:温馨小筑Latest update time:2015-07-15 Source: 51hei Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
   #INCLUDE"P16F877.inc"
   ORG  000H
   GOTO A1
   ORG 004H; timing interrupt entry address 
   GOTO ZD01;
   ORG  0CH
A1 MOVLW 1; bit 1 displays the number
   MOVWF 50H; 
   MOVLW 2; bit 2 displays the number
   MOVWF 51H;
   MOVLW 3; bit 3 displays the number
   MOVWF 52H;
   MOVLW 4; bit 4 displays the number
   MOVWF 53H;
   MOVLW 4; Display digits
   MOVWF 40H;
   MOVLW B'00000001'; bit code
   MOVWF 41H;
   MOVLW 50H;
   MOVWF FSR ; indirect addressing
   BSF STATUS, RP0; select body 1
   BCF  STATUS,RP1;
   MOVLW 00H; 1:2TMRO ratio
   MOVWF OPTION_REG; divide by 1/2
   BCF STATUS,RP0;body0
   BCF  STATUS,RP1;
   MOVLW 0FFH;
   MOVFW TMR0; initial value
   BCF INTCON, T0IF; clear the timing interrupt flag
   BSF INTCON, T0IE; open timer interrupt
   BSF INTCON, GIE; open general interrupt
   GOTO $
   
   
ZD01 BCF INTCON, GIE; turn off total interrupt
   BTFSS INTCON, T0IF; Determine whether a timing interrupt occurs
   GOTO ZD03; No, jump out, continue to execute
   
   BCF  INTCON,T0IF
   BSF STATUS,RP0;body1
   BCF  STATUS,RP1;
   MOVLW 0;
   MOVWF TRISB; RB port is set as output port
   MOVWF TRISD; RD port is set as output port
   BCF STATUS,RP0;body0
   BCF  STATUS,RP1;
   MOVLW 0FFH;
   MOVWF PORTB; RB port outputs high level
   MOVLW 0
   MOVWF PORTD; RD port outputs low level to clear the screen
   
   MOVFW INDF; indirect addressing display data  
   CALL Q1; check the data table
   MOVWF PORTB; Display the broken code output to port RB
   INCF FSR,1; Indirect addressing address plus 1
   MOVFW 41H ; bit code
   MOVWF PORTD; bit code output to RD port
   RLF 41H,0; Process C
   RLF 41H,1; left shift code
   DECFSZ 40H,1; Determine whether the 4 bits are displayed
   GOTO ZD02; otherwise continue to display
   MOVLW 4; Display digits
   MOVWF 40H;
   MOVLW B'00000001'; bit code
   MOVWF 41H;
   MOVLW 50H;
   MOVWF FSR ; indirect addressing
ZD02  MOVLW 0FFH;
   MOVFW TMR0; reload initial value
ZD03 BSF INTCON, GIE; open general interrupt
   RETFIE ;Interrupt return
 
;********************************************
; data sheet
;********************************************      
Q1   ADDWF   PCL,1  
    RETLW     00C0H        ;0
       RETLW     00F9H        ;1
        RETLW     00A4H        ;2
        RETLW     00B0H        ;3
      RETLW     0099H        ;4
      RETLW     0092H        ;5
      RETLW     0082H        ;6
      RETLW     00F8H        ;7
      RETLW     0080H        ;8
      RETLW     0090H        ;9
      RETLW     0088H        ;A
      RETLW     0083H        ;B
      RETLW     00C6H        ;C
      RETLW     00A1H        ;D
      RETLW     0086H        ;E
      RETLW     008EH        ;F
   END 
Reference address:PIC microcontroller timer interrupt

Previous article:PIC microcontroller running light program
Next article:PIC microcontroller interrupt nesting

Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号