PIC16F877A timing TMR0

Publisher:yunhuiLatest update time:2012-10-24 Source: 21ic Keywords:PIC16F877A Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
The following experimental program is written to make the 8 LEDs on the RC port light up one by one, and then turn off one by one after all are lit, and repeat this cycle. The timer query method is used to control the delay, and the timer interrupt is not used. The interrupt program will be written above later.

            tmr0     equ    01h
             pcl      equ    02h
             status   equ    03h
             option_reg  equ  81h
             intcon    equ    0bh
             portc equiv 07h
             trisc     equ    87h
             tmr0data  equ     15h
             count     equ    20h
             rp0       equ    5h
             org      0000h
             nop
             goto     main
             org      0005h
       main  
             nop
             bsf      status,rp0
             movlw 00h
             movwf    trisc
             movlw 07h
             movwf    option_reg
             bcf      status,rp0
             clrf     count
      walk1
             movf     count,0
             call     read
             movwf portc
             incf     count,1
             movlw 0fh
             andwf    count,1
             call     delay
             call     delay
             call     delay
             call     delay
             call     delay
             call     delay
             call     delay
             goto      loop1
       delay
             bcf      intcon,2
             movlw tmr0data
             movwf    tmr0
       delay1
             btfss    intcon,2
             goto      delay1
             return
       
      read   
             addwf     pcl,1
            retlw      b'10000000'
            retlw      b'11000000'  
            retlw      b'11100000'
            retlw      b'11110000'
            retlw      b'11111000'
            retlw      b'11111100'
            retlw      b'11111110'
            retlw      b'11111111'
            retlw      b'11111110'
            retlw      b'11111100'
            retlw      b'11111000'
            retlw      b'11110000'
            retlw      b'11100000'
            retlw      b'11000000'
            retlw      b'10000000'
            retlw      b'00000000'
            end

This program uses TMR0 of 16F877A. For specific settings, please look up the function descriptions of INTCON, OPTION_REG, TMR0 and other related special working registers in 16F877C. I recommend the PIC microcontroller practical tutorial written by Mr. Li Xuehai.

Keywords:PIC16F877A Reference address:PIC16F877A timing TMR0

Previous article:Design of pressure control system in closed container based on single chip microcomputer
Next article:Application of PIC microcontroller in aircraft refueling system

Recommended ReadingLatest update time:2024-11-16 15:19

Basic I/O port operations
//Use of MCU I/O port //★★★★★★★★★Use of MCU I/O port★★★★★★★★★★★\\ //MCU model: PIC16F877A //Function description: Make the RC0 port light flash #include pic.h //Includes the internal resources of the MCU predefined __CONFIG(0XF73A); //Chip configuration word  void delay(); //delay function declaration //=====
[Microcontroller]
Design of Chaotic Signal Generator Based on PIC16F877A Single Chip Microcomputer
Chaos science has been widely studied thanks to Lorenz's "butterfly effect" in the 1960s. Chaotic signals have the characteristics of initial value sensitivity, internal randomness, ergodicity and boundedness. In recent years, they have been deeply studied and explored, and have begun to be widely used in signal proce
[Microcontroller]
Design of Chaotic Signal Generator Based on PIC16F877A Single Chip Microcomputer
Design of digital controlled current source based on single chip microcomputer
Abstract: This paper presents a design of digital current source based on single-chip microcomputer control. This design uses PIC16F877A single-chip microcomputer as the core component, and uses PID algorithm to achieve the functions of selectable range, adjustable output, precise stepping, and extremely small ripple
[Microcontroller]
Design of digital controlled current source based on single chip microcomputer
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号