avrdude problem z wgraniem programu UART

To forum jest dla wszystkich pasjonatów mikrokontrolerów AVR Atmela. Wymiana doświadczeń i pomoc dla początkujących w pisaniu programów zarówno w C, Asemblerze jak i BASCOM. Zapraszam znawców tematu, aby pomogli wszystkim początkującym!
ODPOWIEDZ
Cosik
-
Posty: 6
Rejestracja: 13 wrz 2009, 17:26
Lokalizacja: Nowy Sącz /Wrocław

avrdude problem z wgraniem programu UART

Post autor: Cosik » 20 lis 2009, 13:38

Witam, mam problem z wgraniem programu obsługującego UART do atmegi8, programator jest na 100% dobrze podpięty bo inne programy wgrywa poprawnie.

kod programu jest z AVR Freaks tutorial

Kod: Zaznacz cały

#include <avr/io.h> 
#define F_CPU 8000000
#define USART_BAUDRATE 9600 
#define BAUD_PRESCALE (((F_CPU / (USART_BAUDRATE * 16UL))) - 1) 

int main (void) 
{ 
   char ReceivedByte; 

   UCSRB |= (1 << RXEN) | (1 << TXEN);   // Turn on the transmission and reception circuitry 
   UCSRC |= (1 << URSEL) | (1 << UCSZ0) | (1 << UCSZ1); // Use 8-bit character sizes 

   UBRRL = BAUD_PRESCALE; // Load lower 8-bits of the baud rate value into the low byte of the UBRR register 
   UBRRH = (BAUD_PRESCALE >> 8); // Load upper 8-bits of the baud rate value into the high byte of the UBRR register 

   for (;;) // Loop forever 
   { 
      while ((UCSRA & (1 << RXC)) == 0) {}; // Do nothing until data have been recieved and is ready to be read from UDR 
      ReceivedByte = UDR; // Fetch the recieved byte value into the variable "ByteReceived" 

      while ((UCSRA & (1 << UDRE)) == 0) {}; // Do nothing until UDR is ready for more data to be written to it 
      UDR = ReceivedByte; // Echo back the received byte back to the computer 
   }    
}
kompiluje się normalnie, ale w czasie wgrywanie wyskakuje błąd

Kod: Zaznacz cały

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.07s

avrdude: Device signature = 0x1e9307
avrdude: reading input file "main.hex"
avrdude: input file main.hex auto detected as Intel Hex
avrdude: ERROR: address 0x810010 out of range at line 93 of main.hex
avrdude: write to file 'main.hex' failed

avrdude: safemode: Fuses OK

avrdude done.  Thank you.
i tak jest na każdym programie, który ma obsłużyć UART

Awatar użytkownika
Ertew
Użytkownik
Posty: 1414
Rejestracja: 03 lip 2005, 10:36
Lokalizacja: Leszno
Kontakt:

Post autor: Ertew » 20 lis 2009, 18:40

Avrdude twierdzi, że w kodzie wynikowym main.hex znajdują się złe dane.
Możesz wstawić tu zawartość tego pliku?

Cosik
-
Posty: 6
Rejestracja: 13 wrz 2009, 17:26
Lokalizacja: Nowy Sącz /Wrocław

Post autor: Cosik » 20 lis 2009, 18:47

akurat z tym sobie już poradziłem, w tym przypadku wystarczyło zmienić pętle for na while, natomiast jest problem, bo cały czas odbiera mi śmieci, a nie znaki w gtkterm

ODPOWIEDZ