Gast
#841576
Hallo!
Ich bin Anfänger im GCC programmieren. Ich möchte das beim betätigen
eines Tasters an Port D das Programm in eine ISR springt und mir den
Wert x mit 10 multipliziert. Hab schon was versucht es scheinen aber
noch einige Fehler drin zu sein.
Hoffe ihr könnt mir weiterhelfen. Wäre gut wenn ich auch eine kurze
Erklärung dabei habe.
// Test 1
#include <avr/io.h>
#include <stdint.h>
#include <util/delay.h>
#include <avr/interrupt.h>
volatile float x =0.01;
ISR(INT0_vect)
{
x=x*10;
}
int main (void)
{
DDRD=0x00; //D Eingang
DDRC=0xff; //C Ausgang
PORTC = 0xff;
MCUCR |=(1<<ISC01) | (1<<ISC00);
GICR |=(1<<INT0);
sei();
while(1)
{
PORTC |= (1<<1);
PORTC &=~(1<<3);
PORTC &=~(1<<5);
PORTC |= (1<<7);
_delay_ms(x);
PORTC |= (1<<1);
PORTC &=~(1<<3);
PORTC |= (1<<5);
PORTC &=~(1<<7);
_delay_ms(x);
PORTC &=~(1<<1);
PORTC |= (1<<3);
PORTC |= (1<<5);
PORTC &=~(1<<7);
_delay_ms(x);
PORTC &=~(1<<1);
PORTC |= (1<<3);
PORTC &=~(1<<5);
PORTC |= (1<<7);
_delay_ms(x);
}
}
Vielen Dank schonmal!
Schöne Grüße