我用MEGA168 (PC0引脚对地接开关) 做中断试验,PB1接个发光管,为何进不了中断,灭不了发光管?请指教
#define F_CPU 8000000 /* 单片机主频为7.3728MHz,用于延时子程序 */
#include <util/delay.h>
#include <avr/io.h>
#include <avr/interrupt.h> //中断信号头
#define uchar unsigned char
#define uint unsigned int
#define ulong unsigned long
#define delay_us(x) _delay_us(x) //AVR GCC延时函数 x(us)
#define delay_ms(x) _delay_ms(x) //AVR GCC延时函数 x(ms)
#define LED0 PORTB &= ~(1 << PORTB1) //LED关
#define LED1 PORTB |= (1 << PORTB1) //LED开
#pragma interrupt_handler pcint0_ier:8
void pcint0_ier(void)
{
LED0;
}
void port_init(void)
{
DDRC=0xFC; //LED (PC4)
PORTC=0xFD;
PCICR=0B00000010;
PCMSK1=0B00111111;
sei();
}
void main()
{
port_init(); //引脚初始化
LED1;
while(1);
{
}
}
|