原创 ATMEGA16 T/C0的CTC模式

2024-6-7 12:59 193 3 3 分类: MCU/ 嵌入式 文集: AVR
代码:

/*******************************************************
This program was created by the
CodeWizardAVR V3.12 Advanced
Automatic Program Generator
?Copyright 1998-2014 Pavel Haiduc, HP InfoTech s.r.l.
http://www.hpinfotech.com

Project : 
Version : 
Date    : 2024/6/7
Author  : 
Company : 
Comments: 


Chip type               : ATmega16
Program type            : Application
AVR Core Clock frequency: 8.000000 MHz
Memory model            : Small
External RAM size       : 0
Data Stack size         : 256
*******************************************************/

#include <mega16.h>

// Declare your global variables here
interrupt [TIM0_COMP] void timer0_comp_isr(void)
{
    
    PORTA.0=~PORTA.0;
}
void main(void)
{
// Declare your local variables here
PORTA=1;
DDRA=1;
PORTB=1;
DDRB=0;
TCCR0=0X0f;
TCNT0=0X00;
OCR0=0x7c;
TIMSK=0X02;
#asm("sei");
while (1)
      {
      // Place your code here

      }
}
仿真效果图:

文章评论0条评论)

登录后参与讨论
我要评论
0
3
关闭 站长推荐上一条 /2 下一条