// Crystal: 7.3728MHz ,功能:学习外部中断0的程序
#include <iom16v.h>
#include <macros.h>
#define LED_COM PORTA ^= (1 << PA6) //
void port_init(void)
{
PORTA = 0x40;
DDRA = 0x40;
PORTB = 0x00;
DDRB = 0x00;
PORTC = 0x00; //m103 output only
DDRC = 0x00;
PORTD = 0x04;
DDRD = 0x00;
}
#pragma interrupt_handler int0_isr:2
void int0_isr(void)
{
LED_COM;
}
//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()
{
init_devices();
while(1)
{
;
}
}
本文关键字:单片机 AVR单片机,单片机-工控设备 - AVR单片机
上一篇:AVR单片机C语言入门知识