AVR Timer Program

Publisher:mancozcLatest update time:2016-10-22 Source: eefocusKeywords:AVR  Timer Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
#include //header file

interrupt [TIM0_OVF] void timer0(void) //Timer interrupt service function
{
    TCNT0=0xff; // Reset the initial value of TCNT0
    PORTD.4 = ~PORTD.4; // PD4 reverse output
}
void main(void)
{
    DDRD=0XF0; //PD port direction register, high is output, low is input
    PORTD=0XFF; //PD port data register writes all 1
    
    TIMSK=0X01; //Open timer, counter 0
    TCCR0=0X07; //Timer clock control register
    TCNT0=0XFF; //Timing count register
    OCR0=0X00; //Output compare register
    #asm("sei"); //Open all interrupts
    while(1);
}

Keywords:AVR  Timer Reference address:AVR Timer Program

Previous article:Basic application of USART serial communication of AVR microcontroller
Next article:How to set the operating frequency of the AVR Mega16 on-chip RC oscillator

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号