Hallo Johannes,
der Code sieht erst mal OK aus.
Ich tippe mal auf falsche Fusebits (CLKSEL = Externer Quarz) oder die RS232 Anschaltung. Dann poste mal den Schaltplan.
Gruß m.a.r.v.i.n
Hallo,
ich versuche seit gestern RS232 zum laufen zu bringen, aber es klappt irgendwie nicht..
Hier erstmal der Code (fast so wie aus dem AVR Datenblatt):
uart.c
main.cCode:#define BAUD 38400 void usart_init() { /* Calculate baud rate */ uint16_t ubrr = (uint16_t) ((uint32_t) F_CPU/(16*BAUD) - 1); /* Set baud rate */ UBRRH = (uint8_t) (ubrr>>8); UBRRL = (uint8_t) ubrr; /* Enable Receiver and Transmitter */ UCSRB = (1<<RXEN) | (1<<TXEN); /* Set frame format: 8data, 2stop bit */ UCSRC = (1<<URSEL) | (1<<USBS) | (1<<UCSZ0); } void usart_transmit(uint8_t data) { /* Wait for empty transmit buffer */ while ( !( UCSRA & (1<<UDRE)) ) ; /* Put data into buffer, sends the data */ UDR = data; } void usart_print(char *s) { do { usart_transmit(*s); } while (*s++); }
Achso, ich benutze einen AVR Mega8Code:#define F_CPU 16000000 #include <avr/io.h> #include <inttypes.h> #include "usart.c" int main(void) { usart_init(); while(1) { usart_print("Test"); } return 0; }
Nur irgendwie empfange ich am Computer gar nix und weiß nicht woran es liegt..
Könnt ihr mir da helfen?
Viele Grüße,
Johannes
Hallo Johannes,
der Code sieht erst mal OK aus.
Ich tippe mal auf falsche Fusebits (CLKSEL = Externer Quarz) oder die RS232 Anschaltung. Dann poste mal den Schaltplan.
Gruß m.a.r.v.i.n
Hallo,
wie stell ich unter Linux die Fusebits ein? Oder wie unter Windows?
Im Moment kann ich es leider nicht weiter testen, weil mein Programmer (mySmartUSB) irgendwie kaputt ist.
Und ich habe keine RS232 schnittstelle, nur USB und benutze um Moment einen USB->RS232 Adapter, vielleicht liegts auch an dem.
Viele Grüße,
Johannes
Hallo Johannes,
ich habe auch den mySmartUSB Flasher. Kommt ab und zu vor, das man die Firmware neu flashen muß (Nach Anstecken leuchtet keine LED mehr). Aktuelle Firmware gibt es auf der myAvr Homepage. Genau den Anweisungen folgen, dann kann nichts schiefgehen.
Der mySmartUSB bringt ja auch eine USB UART Bridge mit. Mit dem myAVR QuickProg Tool (ebenfalls von der myAVR Homepage) kann man per Software in den UART Mode wechseln und die UART testen (Control Center starten)
Die Fuses kann man mit diesem Tool zwar auch auf externen Quarz stellen, aber das würde ich nicht tun (ist nämlich für das myAVR Board gedacht mit 3,68MHz Quarz). Die Fuses setzt man am besten mit Avrdude. Gehört zur WinAVR Toolsuite dazu, gibt es ebenso für Linux.
Mit dem AVR Fuses Calculator kann man sich online die korrekten Fuses berechnen lassen.
Diese Einstellung sollte funktionieren. Ergibt für Low: 0xFF, High: 0xD9
Diese Werte gibt man dann in der Befehlszeile für Avrdude ein:
Oder man startet die avrdude-gui Bediengrafik und klickt sich das ganze zusammen, wie in dem Screenshot zu sehen.Code:"avrdude" -p m8 -c AVR910 -P com3 -U lfuse:w:FF -U hfuse:w:D9 -F
Gruß m.a.r.v.i.n
Hallo,
ich hab die Firmware neu geflasht, aber es geht trotzdem noch nicht...
Wenn ich ein Programm übertragen will leuchtet nur die rote LED und nur eine grüne..
Wenn ich ganz viel Glück habe geht es dann doch, aber meistens kommt das:
Ich ruf bei denen morgen mal anCode:avrdude: verifying ... avrdude: verification error, first mismatch at byte 0x0000 0x12 != 0x00 avrdude: verification error; content mismatch avrdude: safemode: Fuses OK avrdude done. Thank you.
Viele Grüße,
Johannes
Hallo,
so, der mySmartUSB geht wieder, nun habe ich aber folgendes Problem:
Wenn ich "avrdude -p m8 -c AVR910 -P /dev/ttyUSB0 -U lfuse:w:FF -U hfuse:w9 -F" eingebe kommt das:
Irgendwas passt da nicht..Code:Found programmer: Id = "AVR ISP"; type = S Software Version = 1.5; Hardware Version = 2.0 Programmer supports auto addr increment. Programmer supports the following devices: Device code: 0x55 = ATtiny12 Device code: 0x01 = ATtiny13 Device code: 0x56 = ATtiny15 Device code: 0x13 = AT90S1200 Device code: 0x28 = AT90S4414 Device code: 0x20 = AT90S2313 Device code: 0x4c = AT90S2343 Device code: 0x30 = AT90S4433 Device code: 0x6c = AT90S4434 Device code: 0x38 = AT90S8515 Device code: 0x68 = AT90S8535 Device code: 0x41 = ATMEGA103 Device code: 0x02 = ATMEGA64 Device code: 0x43 = ATMEGA128 Device code: 0x03 = AT90CAN128 Device code: 0x74 = ATMEGA324 Device code: 0x0e = ATMEGA644 Device code: 0x04 = ATMEGA162 Device code: 0x64 = ATMEGA163 Device code: 0x75 = ATMEGA169 Device code: 0x14 = ATMEGA329 Device code: 0x15 = ATMEGA3290 Device code: 0x16 = ATMEGA649 Device code: 0x17 = ATMEGA6490 Device code: 0x72 = ATMEGA32 Device code: 0x60 = ATMEGA161 Device code: 0x76 = ATMEGA8 Device code: 0x3a = ATMEGA8515 Device code: 0x05 = ATMEGA8535 Device code: 0x5e = ATTINY26 Device code: 0x06 = ATMEGA48 Device code: 0x07 = ATMEGA88 Device code: 0x08 = ATMEGA168 Device code: 0x21 = ATtiny2313 Device code: 0x09 = AT90PWM2 Device code: 0x0a = AT90PWM3 Device code: 0x22 = ATtiny25 Device code: 0x23 = ATtiny45 Device code: 0x24 = ATtiny85 Device code: 0x0b = ATMEGA640 Device code: 0x0c = ATMEGA1280 Device code: 0x0d = ATMEGA1281 Device code: 0x25 = ATtiny24 Device code: 0x26 = ATtiny44 Device code: 0x27 = ATtiny84 avrdude: AVR device initialized and ready to accept instructions Reading | ################################################## | 100% 0.06s avrdude: Device signature = 0x07931e avrdude: reading input file "FF" avrdude: error opening FF: No such file or directory avrdude: input file FF auto detected as invalid format avrdude: can't open input file FF: No such file or directory avrdude: write to file 'FF' failed avrdude: safemode: Fuses OK avrdude done. Thank you.
Viele Grüße,
Johannes
Hallo Johannes,
sorry, ich hatte nur die Zeile abgetippt die avrdude-gui mir anzeigte.
So sollte es klappen:
Gruß m.a.r.v.i.nCode:"avrdude" -p m8 -c AVR910 -P com3 -U lfuse:w:0xff -U hfuse:w:0xd9 -F
Hallo,
nun kommt das:
Viele Grüße,Code:avrdude: Device signature = 0x07931e avrdude: reading input file "0xff" avrdude: error opening 0xff: No such file or directory avrdude: input file 0xff auto detected as invalid format avrdude: can't open input file 0xff: No such file or directory avrdude: write to file '0xff' failed
Johannes
OK, letzter Versuch:
Gruß m.a.r.v.i.nCode:"avrdude" -p m8 -c AVR910 -P com3 -U lfuse:w:0xff:m -U hfuse:w:0xd9:m -F
Hallo,
ok, nun geht es fast
hier nochmal der Code:
main.c
usart.cCode:#define F_CPU 16000000 #include <avr/io.h> #include <util/delay.h> #include <inttypes.h> #include "usart.c" void wait_ms(int i) { int x = 0; while(x <= i) { _delay_ms(1); x++; } } int main(void) { usart_init(); while(1) { usart_print("Test\n"); wait_ms(1000); } return 0; }
Nun kommt im Terminal immer Zeichensalat (wenigstens etwasCode:#define USART_BAUD_RATE 9600 #define USART_BAUD_SELECT (F_CPU/(USART_BAUD_RATE*16l)-1) void usart_init() { /* Set baud rate */ UBRRH = (uint8_t) (USART_BAUD_SELECT>>8); UBRRL = (uint8_t) USART_BAUD_SELECT; /* Enable Receiver and Transmitter */ UCSRB = (1<<RXEN) | (1<<TXEN); /* Set frame format: 8data, 2stop bit */ UCSRC = (1<<URSEL) | (1<<USBS) | (1<<UCSZ0); } void usart_transmit(uint8_t data) { /* Wait for empty transmit buffer */ while ( !( UCSRA & (1<<UDRE)) ) ; /* Put data into buffer, sends the data */ UDR = data; } void usart_print(char *s) { do { usart_transmit(*s); } while (*s++); })
Hast du noch eine Idee an was es liegen könnte?
Viele Grüße,
Johannes[/code]
Lesezeichen