一个关于mega128外部中断的问题
本人刚刚开始使用mega128作项目,在调试外部中断5时遇到如下问题,希望高手出来解决以下。将外部中断5配置为下降沿触发方式,可是初始化完成后PE5脚为高电平时就进入中断了,这是不应该的吧,后来配置为地点平触发也是一样。程序如下:
//ICC-AVR application builder : 2007-3-10 15:03:36
// Target : M128
// Crystal: 16.000Mhz
#include <iom128v.h>
#include <macros.h>
unsigned char sss;
void port_init(void)
{
PORTA = 0x00;
DDRA= 0x00;
PORTB = 0x00;
DDRB= 0x00;
PORTC = 0x00; //m103 output only
DDRC= 0x00;
PORTD = 0x00;
DDRD= 0x00;
PORTE = 0x00;
DDRE= 0x00;
PORTF = 0x00;
DDRF= 0x00;
PORTG = 0x00;
DDRG= 0x00;
}
#pragma interrupt_handler int5_isr:7
void int5_isr(void)
{
//external interupt on INT5
CLI();
sss=10;
SEI();
}
//call this routine to initialize all peripherals
void init_devices(void)
{
//stop errant interrupts until set up
CLI(); //disable all interrupts
XDIV= 0x00; //xtal divider
XMCRA = 0x00; //external memory
port_init();
MCUCR = 0x00;
EICRA = 0x00; //extended ext ints
EICRB = 0x08; //extended ext ints
EIMSK = 0x20;
TIMSK = 0x00; //timer interrupt sources
ETIMSK = 0x00; //extended timer interrupt sources
SEI(); //re-enable interrupts
//all peripherals are now initialized
}
void main(main)
{
port_init();
init_devices();
} 没人帮忙回答阿。现在发现这个程序在另一个测试板子上运行正常。是芯片坏了吗? 有经验的同志帮忙看看阿,分析不出原因阿。 检查电路。
页:
[1]