int2.c

来自「MEGA16单片机程序包2」· C语言 代码 · 共 47 行

C
47
字号
//ICC-AVR application builder : 2007-5-6 12:36:39
// Target : M16
// Crystal: 8.0000Mhz

#include <iom16v.h>
#include <macros.h>

void port_init(void)
{
 PORTA = 0x00;
 DDRA  = 0xff;
 PORTB = 0x00;
 DDRB  = 0x00;
 PORTC = 0x00; //m103 output only
 DDRC  = 0x00;
 PORTD = 0x0c;
 DDRD  = 0x00;
}

#pragma interrupt_handler int0_isr:2
void int0_isr(void)
{
 PORTA = 0XF0;
}

//call this routine to initialize all peripherals
void init_devices(void)
{
 //stop errant interrupts until set up
 CLI(); //disable all interrupts
 port_init();

 MCUCR = 0x00;
 GICR  = 0x40;
 TIMSK = 0x00; //timer interrupt sources
 SEI(); //re-enable interrupts
 //all peripherals are now initialized
}

//
void main(void)
{
 init_devices();
 //insert your functional code here...
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?