Juhhu, es Funktioniert 
Ich habe die ganze Flankentriggerung weggelassen und die Interrupts nun heiss auf "any logical change" gemacht...
Vielen Dank nochmals für dienen Hilfe!
Hier der funktionierende Code:
Code:
#include <inttypes.h>
#include <avr/interrupt.h>
#define F_CPU 8000000 /* 8Mhz */
#include <util/delay.h> /* definiert _delay_ms() ab avr-libc Version 1.2.0 */
#include "twimaster.c"
#include "LCD.h"
volatile long t2_y,t2_x;
volatile long t1_y,t1_x;
volatile int x1,x0; // Temp Variablen für ISR's
int count_y, count_x;
char ziel[5];
ISR(SIG_INTERRUPT1){
GIFR = 0;
if(x1==1){
x1=0;
t1_y = count_y;
}
else{
x1=1;
t2_y = count_y;
count_y = 0;
}
}
ISR(SIG_INTERRUPT0){
GIFR = 0;
if(x0==1){
x0=0;
t1_x = count_x;
}
else{
x0=1;
t2_x = count_x;
count_x = 0;
}
}
ISR (SIG_OUTPUT_COMPARE1A){
count_y++;
count_x++;
}
void Timer_Inits(void){
TCCR1A = 0;
TCCR1B = (1 << WGM12) | (1 << CS10);
OCR1A = (uint16_t) ((uint32_t) F_CPU / 50000); //100000
TIMSK |= (1 << OCIE1A); // Interrupt wenn Timer Vergleichswert erreicht
//Jede logische änderung von INT0 oder INT1 löst Interrupt aus
MCUCR = (0<<ISC11 | 1<<ISC10 | 0<<ISC01 | 1<<ISC00);
GIMSK = (1<<INT0 | 1<<INT1); //Int0 u. 1 aktiv
}
int main (void){
DDRC = 0x00; //alles als Eingan def.
PORTC =0x00; //PullUp's aus
DDRD =0x00; //alles Eingang
PORTD =0x00; //PullUp's aus
Timer_Inits();
i2c_init();
_delay_ms(10000);
lcd_init();
_delay_ms(10000);
sei();
for(;;){
_delay_ms(90000000);
clear();
//A(g) = ((T1/T2) / 0.5)/12.5%
int resultx,resulty;
uint8_t sreg = SREG;
cli();
long t1x = t1_x;
long t2x = t2_x;
long t1y = t1_y;
long t2y = t2_y;
SREG = sreg;
if(t2x!=0) resultx = (((((float)t1x/(float)t2x)*1000)-481)*1000)/125;
else resultx=0;
if(t2y!=0) resulty = (((((float)t1y/(float)t2y)*1000)-481)*1000)/125;
else resulty=0;
sei();
sprintf(ziel,"%d",resultx);
stringout ("ay=");
stringout (ziel);
sprintf(ziel,"%d",resulty);
stringout (" ax=");
stringout (ziel);
}
}
Lesezeichen