Not logged in. · Lost password · Register
Forum: Grundstudium 2. Semester Informatik (GDI II) SPiC RSS
Interrupts
Zerotan #1 -- for a month · 3 posts
Show profile · Link to this post
Subject: Interrupts
Hallo,

ich hab jetzt mal zum Testen von Interrupts ein kleines Programm geschrieben, aber es funktioniert nicht ;-)

#include <led.h>
#include <button.h>
#include <avr/interrupt.h>
#include <avr/io.h>

static volatile int x;

ISR(INT0_vect){
x++;

}

void init(){

DDRD &= ~(1<<PD2);  /* Button 0 als Eingang */
PORTD |= (1<<PD2); /* pull-up*/
GICR |= (1<<INT0); /* INT0 - Interrupt anschalten */
MCUCR |= (1<<ISC01)|(1<<ISC00); /*steigende Flanke*/


}
void main(void){

init();

while(1){
sb_led_on(x);
}
}


Was ist daran falsch, es macht mir die 1. Led an, und dann passiert nix bei Tastendruck.

Gruß
Zerotan
morty (Administrator) #2 -- since Sep 2003 · 730 posts · Location: Erlangen
Show profile · Link to this post
spontan würde ich sagen, das sei() um die Interrupts zu aktivieren.
Zerotan #3 -- for a month · 3 posts
Show profile · Link to this post
Tatsächlich danke.

Ich dachte, dass ich das Bit im GICR-Register setze aktiviert den Interrupt automatisch??

Oder was bringt das GICR-Register dann??


Gruß

Zerotan
morty (Administrator) #4 -- since Sep 2003 · 730 posts · Location: Erlangen
Show profile · Link to this post
GICR erlaubt dir einzelne Interrupts zu sperren. Hierbei treten gegebenenfalls Nebenhäufigkeitsprobleme auf (Register lesen, verändern, schreiben). Außerdem sind sei und cli global und beziehen sich auf alle Interrupts.
Close Smaller – Larger + Reply to this post:
Verification code: VeriCode Please note the verification code from the picture into the text field next to it.
Smileys: :-) ;-) :-D :-p :blush: :cool: :rolleyes: :huh: :-/ <_< :-( :'( :#: :scared: 8-( :nuts: :-O
Special characters:
Go to forum
Unclassified NewsBoard 1.6.4 © 2003-5 by Yves Goergen
Page created in 380.2 ms (173.9 ms) · 62 database queries in 61.9 ms
Current time: 2010-09-10, 04:29:14 (UTC +02:00)