PIC timer1 timer

Publisher:beup001Latest update time:2018-07-30 Source: eefocusKeywords:pic  timer1  timer Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

Function: Use Timer1 to delay the LED light to flash in a cycle

Requirements: MPLAB 8.2 or above, a MEO engineering board, PIC16-MCD2 simulation download,

Chip configuration word, watchdog off, power-on delay on, power-off detection off, low voltage programming off, 4MXT mode oscillation 

*/

#include


int main()

{

    TRISC = 0x00; //c port is defined as output

    PORTC = 0x00; // all off

    TMR1CS = 1; //T1CON<1> Set timer1 to configure timer

    T1CON = 0xb0; //1011 0000 Configuration bits read and write the Timer1 register 16 bits at a time with 1:8 prescale

    TMR1 = 0; //TMR1 is assigned the initial value and the timer value is cleared 

    TMR1ON = 1; // Enable timer

    while (1)

    {

          for (int i=0; i<8; i++)

          {

              PORTC = 0x01; //The first light is on 

              PORTC = PORTC>>1; //Shift right one bit

              if (TMR1IF == 1) //Generate interrupt, overflow

              {

                   TMR1IF = 0; // Clear overflow

                   TMR1 = 0; //TMR1 is assigned the initial value and the timer value is cleared 

                   PORTD = 0x00; //All off 

              } 

          }

    } 

}


Keywords:pic  timer1  timer Reference address:PIC timer1 timer

Previous article:PIC Timer Interrupt
Next article:Pic18F25K80 Timer 0 configuration in 16-bit mode

Recommended ReadingLatest update time:2024-11-25 11:08

Using PIC to write efficient bit shift operations
Writing Efficient Shift Operations with PIC        Shift operations are required in many analog serial communications. Taking the read byte of 1-W bus as an example, the original code is: unsigned char read_byte(void) {  unsigned char i;  unsigned char value = 0;  for (i = 0; i 8; i++)  {   if(read_bit())
[Microcontroller]
What are the application designs of PIC8-bit microcontrollers? What are the techniques?
The PIC series 8-bit single-chip microcomputer (RISC microcontroller) developed by Microchip Technology Inc. of the United States, especially the microcontroller with built-in second-generation Flash memory (40-year storage life), is unique in terms of rapid application. Due to its ease of use and high reliability, th
[Microcontroller]
What are the application designs of PIC8-bit microcontrollers? What are the techniques?
Summary of the eight advantages of PIC microcontrollers
As one of the work contents of many people, PIC microcontroller plays an important role. But most people don't know why to use PIC microcontroller. To solve this problem, we must talk about several major advantages of PIC microcontroller. Through this article about the advantages of PIC microcontroller, I hope that re
[Microcontroller]
Summary of the eight advantages of PIC microcontrollers
PIC16F676 microcontroller internal EEPROM program
BSF STATUS,RP0          CLRF EEADR ;Address 0     MOVLW .9     MOVWF EEDAT ;The data to be written is 9     BSF EECON1,WREN ;Enable writing     MOVLW 0X55     MOVWF EECON2     MOVLW 0XAA     MOVWF EECON2     BSF EECON1,WR ;Start writing     NOP     NOP ;Several NOPs are added for fear of affecting the following operat
[Microcontroller]
Design of electric hot shear control circuit based on PIC microcontroller
  The system structure of the electric heating shear circuit is shown in Figure 1. It consists of six parts: sensor-ball switch, microcontroller timing detection and processing, working status indication, PWM signal generation and adjustment, electric heating module drive, and power supply.   As shown in Figure 1, th
[Power Management]
Design of electric hot shear control circuit based on PIC microcontroller
Realization of reactive power compensation algorithm for three-phase mismatch of load based on PIC16C72
1 Introduction At present, most of the power factor compensators used by many industrial and mining enterprises adopt the method of three-phase simultaneous compensation, which has a better compensation effect when the three-phase load is symmetrical or basically symmetrical. However, many electricity users
[Power Management]
Realization of reactive power compensation algorithm for three-phase mismatch of load based on PIC16C72
PIC microcontroller uses CCP1 module to generate 10-bit PWM waveform program
//This program is used to make the CCP1 module generate a PWM waveform with a resolution of 10 bits and a duty cycle of 50% #include p18f452.h void CCP1NIT(void) {  CCPR1L=0x7f;  CCP1CON=0x3c; //Set the CCP1 module to PWM mode, and      the lower 2 bits of its working //cycle are 11, and the upper 8 bits are 011
[Microcontroller]
Application design of PIC16F887 and MPLAB
Preface In recent years, due to the rapid development of semiconductor technology, the manufacturing cost of electronic products has been greatly reduced, and the use of electronic products has gradually become an indispensable part of people's daily lives. Due to the different needs of users
[Microcontroller]
Application design of PIC16F887 and MPLAB
Latest Microcontroller Articles
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号