سلام.ببخشید چجوری تو وقفه خارجی تایمرو روشن کنم بعد دفعه بعدی که وقفه بخوره تایمر خاموش شه و عدد تو تایمرو استفاده کنم
با کدویژن کار میکنم نه بسکام ممنون :cry2:
با کدویژن کار میکنم نه بسکام ممنون :cry2:
#include <mega32.h> char x; char flag; // External Interrupt 0 service routine interrupt [EXT_INT0] void ext_int0_isr(void) { flag=TCCR0&0b00000111; if(!flag) { TCCR0|=1; } else { x=TCNT0; TCCR0&=~1; } } // Timer 0 overflow interrupt service routine interrupt [TIM0_OVF] void timer0_ovf_isr(void) { PORTC^=0xff; } void main(void) { DDRC=0xff; // Timer/Counter 0 initialization // Clock source: System Clock // Clock value: Timer 0 Stopped // Mode: Normal top=0xFF // OC0 output: Disconnected TCCR0=0x00; TCNT0=0x00; OCR0=0x00; // External Interrupt(s) initialization // INT0: On // INT0 Mode: Falling Edge // INT1: Off // INT2: Off GICR|=0x40; MCUCR=0x02; MCUCSR=0x00; GIFR=0x40; // Timer(s)/Counter(s) Interrupt(s) initialization TIMSK=0x01; // Global enable interrupts #asm("sei") while (1) { // Place your code here } }
دیدگاه