Hallo! Wieso schaltet sich das LED sofort ein, auch wenn nicht einmal der serielle Stecker noch dran ist? Das LED sollte für eine Sekunde aufleuchten, sofern ein 'r' empfangen wird. Was ist daran falsch?? Vielen Dank im Vorraus, Niki PS: Es handelt sich um einen AT90S2333 #include <io.h> #define CPU_CLOCK 4000000 /* @ 4Mhz */ void delay(void) { /* * Mit AVR DelayLoop erstellt - eine Sekunde */ asm volatile( "ldi R17, 0x24" "\n\t" "WGLOOP0: ldi R18, 0xBC" "\n\t" "WGLOOP1: ldi R19, 0xC4" "\n\t" "WGLOOP2: dec R19" "\n\t" "brne WGLOOP2" "\n\t" "dec R18" "\n\t" "brne WGLOOP1" "\n\t" "dec R17" "\n\t" "brne WGLOOP0" "\n\t" "ldi R17, 0x01" "\n\t" "WGLOOP3: dec R17" "\n\t" "brne WGLOOP3" "\n\t" "nop" "\n\t" ); } void init_serial(void) { outb(((1<<RXEN)|(1<<RXCIE)), UCSRB); outb((CPU_CLOCK/(9600*16L)-1), UBRR); } void init_io(void) { outb(0xFF, DDRB); } unsigned char recv(void) { while(!(UCSRA & (1<<RXC))); return UDR; } int main(void) { init_serial(); init_io(); while(1) { switch(recv()) { case 'r': outb(0x80, PORTB); delay(); outb(0x00, PORTB); break; default: break; } } }
hi! also bei mir geht die led nicht sofort ein... hab leider noch keinen max232, kann es also nicht komplett testen. haste die led richtig geschaltet?
Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.