|
楼主 |
发表于 2014-5-24 00:01:44
|
显示全部楼层
本帖最后由 biying 于 2014-5-24 01:16 编辑
根据马老师的指点,我重新新建了工程,修改了程序后,INT0终于有反应了。我发现个现像,当设置为任意电平触发时,快速按下再放开按键,等再次开中断时,依然会再执行中断程序一次,似乎像是有记忆能力一样,也就是说第二次开中断时,会先对比上一次中断时的电平状态。
但是ATTINY85依然不能用INT0
- /*****************************************************
- This program was produced by the
- CodeWizardAVR V2.05.1b Evaluation
- Automatic Program Generator
- ?Copyright 1998-2011 Pavel Haiduc, HP InfoTech s.r.l.
- http://www.hpinfotech.com
- Project :
- Version :
- Date : 2014-5-23
- Author : Freeware, for evaluation and non-commercial use only
- Company :
- Comments: PB3和PB4接LED灯,PB1为INT0接按键
- Chip type : ATtiny13A
- AVR Core Clock frequency: 9.600000 MHz
- Memory model : Tiny
- External RAM size : 0
- Data Stack size : 16
- *****************************************************/
- #include <tiny13a.h>
- #include<delay.h>
- // External Interrupt 0 service routine
- interrupt [EXT_INT0] void ext_int0_isr(void)
- {
- // Place your code here
- GIMSK=0x00; //禁用INT0中断,等合适的时候再打开
- GIFR=0x40;
- PORTB ^= 1<<4;
- }
- // Declare your global variables here
- void main(void)
- {
- // Declare your local variables here
- // Crystal Oscillator division factor: 1
- #pragma optsize-
- CLKPR=0x80;
- CLKPR=0x00;
- #ifdef _OPTIMIZE_SIZE_
- #pragma optsize+
- #endif
- // Input/Output Ports initialization
- // Port B initialization
- // Func5=In Func4=Out Func3=Out Func2=Out Func1=In Func0=Out
- // State5=P State4=1 State3=1 State2=1 State1=P State0=1
- PORTB=0x3F;
- DDRB=0x1D;
- // Timer/Counter 0 initialization
- // Clock source: System Clock
- // Clock value: Timer 0 Stopped
- // Mode: Normal top=0xFF
- // OC0A output: Disconnected
- // OC0B output: Disconnected
- TCCR0A=0x00;
- TCCR0B=0x00;
- TCNT0=0x00;
- OCR0A=0x00;
- OCR0B=0x00;
- // External Interrupt(s) initialization
- // INT0: On
- // INT0 Mode: Low level
- // Interrupt on any change on pins PCINT0-5: Off
- GIMSK=0x40;
- MCUCR=0x01;
- GIFR=0x40;
- // Timer/Counter 0 Interrupt(s) initialization
- TIMSK0=0x00;
- // Analog Comparator initialization
- // Analog Comparator: Off
- ACSR=0x80;
- ADCSRB=0x00;
- DIDR0=0x00;
- // ADC initialization
- // ADC disabled
- ADCSRA=0x00;
- // Global enable interrupts
- #asm("sei")
- while (1)
- {
- // Place your code here
- delay_ms(4000);
- PORTB ^= 1<<3;
- GIMSK=0x40;
- }
- }
复制代码 |
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?注册
x
|