hallo alle
bin neu hier im forum auch (bei avr)
ich habe eine problem und bitte um hilfe
ich möchte den (16bit TIMER1) gern actvieren weiss leider nicht wie das geht.
ich habe es versucht mit dem example code der bei codevision dabei ist geht aber nicht könnet es vielleicht an meinem stk200 liegen (mein hardware sind stk200 und atmega32) muss ich vielleicht was machen um es zuaktvieren und wenn nicht kann jemanden mir etwas über timer1(16bit-timer)geben
hier ist mein code
Code:// I/O register definitions for AT90S8515 #include <mega32.h> // quartz crystal frquency [Hz] #define xtal 3686400 // moving LED frequency [Hz] #define fmove 2 // the LED on PORTC output 0 will be on unsigned char led_status=0xfe; // TIMER1 overflow interrupt service routine // occurs every 0.5 seconds interrupt [TIM1_OVF] void timer1_overflow(void) { // preset again TIMER1 TCNT1=0x10000-(xtal/1024/fmove); // move the LED led_status<<=1; led_status|=1; if (led_status==0xff) led_status=0xfe; // turn on the LED PORTB=led_status; } void main(void) { // set the I/O ports // all PORTB pins are outputs DDRB=0xff; // turn on the first LED PORTB=led_status; // init TIMER1 // TIMER1 is disconnected from pin OC1 // no PWM TCCR1A=0; // TIMER1 clock is xtal/1024 TCCR1B=5; // preset TIMER1 TCNT1=0x10000-(xtal/1024/fmove); // clear TIMER1 interrupts flags TIFR=0; // enable TIMER1 overflow interrupt TIMSK=0x80; // all other interrupt sources are disabled GIMSK=0; // global enable interrupts #asm sei #endasm // the rest is done by TIMER1 overflow interrupts while (1); }
danke im vorraus







Zitieren


Lesezeichen