PDA

Archiv verlassen und diese Seite im Standarddesign anzeigen : Programmieren mit AVR Studio



Overholt
15.11.2012, 21:41
Hey Leute,

ich habe eine ganz elementare Frage. Wie programmiere ich das RN-Control 1.4 in C mit Avr Studio 6? Es gibt unzählige Links dazu, die decken aber
ganz andere Probleme ab.
Ich weiß, dass ich ein .hex file erzeugen muss (was auch klappt). Der Programmer(STK 500) wird ebenfalls erkannt, nur kriege ich das .hex File anscheinend nicht
auf den Controller. Es gibt keine Kompilierfehler und unter "Tools" -> "Device Programming" -> "Memories" kann ich den Pfad des erzeugten .hex Files auch manuell eingeben, jedoch
macht der Controller nachdem ich auf "programmieren" drücke (und er arbeitet) nichts. :(
Was mache ich falsch?
Danke.

MfG
Overholt

Kampi
16.11.2012, 08:33
Hey,

poste doch mal dein Programm. Vielleicht steckt da ein Fehler drin.

Overholt
16.11.2012, 14:36
Hallo Kampi,

danke für deine Antwort. Im Folgenden ist der Programmcode. Atmel Studio sagt mir, dass er erfolgreich flashen konnte und die Hex Datei ist auch nicht leer. Wenn ich vom uC lese
erhalte ich auch das korrekte .hex File. Nur macht er nichts, obwohl er was machen sollte. Defekt ist das Board mit ziemlicher Sicherheit nicht, weil bis vor kurzem das bei Auslieferung bespielte Testprog.
noch einwandfrei geklappt hat.

SourceCode:


#include <util/delay.h>
#include <avr/io.h>

/*### Ports setzen ###*/

//Ports auf HIGH setzen
static inline void setportaon(const uint8_t n)
{PORTA |= (1<<n);} //set PORTA.n high

static inline void setportbon(const uint8_t n)
{PORTB |= (1<<n);} //set PORTB.n high

static inline void setportcon(const uint8_t n)
{PORTC |= (1<<n);} //set PORTC.n high

static inline void setportdon(const uint8_t n)
{PORTD |= (1<<n);} //set PORTD.n high



//Ports auf LOW setzen
static inline void setportaoff(const uint8_t n)
{PORTA &= ~(1<<n);} //set PORTA.n low

static inline void setportboff(const uint8_t n)
{PORTB &= ~(1<<n);} //set PORTB.n low

static inline void setportcoff(const uint8_t n)
{PORTC &= ~(1<<n);} //set PORTC.n low

static inline void setportdoff(const uint8_t n)
{PORTD &= ~(1<<n);} //set PORTD.n low

int main(){
int i=0;
for(i=0;i<8;i++)
setportaon(i);
while(1);
}
23762

MfG
Overholt

Hubert.G
16.11.2012, 19:08
ICh weiss nicht was du genau machen willst, aber du musst die Ports auf Ausgang setzen, so schaltest du nur die internen PullUp ein und aus.

Overholt
17.11.2012, 01:58
Haha, da war doch was.. super dankeschön! :D

Kampi
17.11.2012, 06:29
Huch nicht gesehen das du den Code gepostet hast.....
Aber schön wenn es jetzt funktioniert :)
Setz Quellcode nächste mal aber bitte zwischen
[&code] und [/&code] (ohne das "&").
Dann sieht es so aus




#include <util/delay.h>
#include <avr (http://www.rn-wissen.de/index.php/AVR-Einstieg_leicht_gemacht)/io.h>

/*### Ports setzen ###*/

//Ports auf HIGH setzen
static inline void setportaon(const uint8_t n)
{PORTA |= (1<<n);} //set PORTA.n high

static inline void setportbon(const uint8_t n)
{PORTB |= (1<<n);} //set PORTB.n high

static inline void setportcon(const uint8_t n)
{PORTC |= (1<<n);} //set PORTC.n high

static inline void setportdon(const uint8_t n)
{PORTD |= (1<<n);} //set PORTD.n high



//Ports auf LOW setzen
static inline void setportaoff(const uint8_t n)
{PORTA &= ~(1<<n);} //set PORTA.n low

static inline void setportboff(const uint8_t n)
{PORTB &= ~(1<<n);} //set PORTB.n low

static inline void setportcoff(const uint8_t n)
{PORTC &= ~(1<<n);} //set PORTC.n low

static inline void setportdoff(const uint8_t n)
{PORTD &= ~(1<<n);} //set PORTD.n low

int main(){
int i=0;
for(i=0;i<8;i++)
setportaon(i);
while(1);
}


und ist ein bisschen Übersichtlicher.