Anzeige:

Problem mit ATMEGA162 - PORTC.4; 5; 6; 7 funktioniert nicht

Hier finden sie die archivierten Beiträge des alten PHPBB Forums von www.loetstelle.net

Problem mit ATMEGA162 - PORTC.4; 5; 6; 7 funktioniert nicht

Von modellfreund am 10.02.2010 19:22

Hallo,

es geht eigentlich noch um die Stellpultsteuerung aus dem Thema "Zähler". Ich habe folgendes Problem:

Die Ausgänge (PortC.4; PortC.5; PortC.6; PortC.7) vom "ATMEGA162 16PU 0908H" funktionieren nicht. An den Ausgängen hängen Transistoren, die die Weichen schalten. Wenn ich den µC aus der Schaltung nehme und eine Drahtbrücke von +5V auf die jewailigen Pins tippe schalten die Weiche. Dann habe ich den µC in das STK500 geschteckt und ein kleines Testprogramm geschrieben wobei die LEDs blinken sollten. PortC.0 bis PortC.3 haben auch wie gedacht funktioniert, nur die LEDs von PortC.4 bis PortC.7 haben weder geleuchtet noch geblinkt.

Alle anderen Pins des µC arbeiten wie gewünscht.
Ein zweiter µC hat das selber Ergebnis gerbracht.

Wo liegt der der Fehler?

LG Felix

Re: Problem mit ATMEGA162 - PORTC.4; 5; 6; 7 funktioniert ni

Von Alv am 10.02.2010 19:33

Ich kenne diesen Kontroller nicht, aber vielleicht haben diese Pins eine Sonderfunktion und müssen erst über spezielle Register zu Ausgangspins umgeschaltet werden?

Von Sam am 10.02.2010 19:38

Kannst du mal den Quellcode posten?

Von modellfreund am 10.02.2010 19:58

Also, das aktuelle Programm sieht folgendermaßen aus:

Code:
$regfile = "M162def.dat"
$crystal = 1000000
$hwstack = 500
$swstack = 500
$framesize = 500


Led_a Alias Porta.0
Config Led_a = Output
Porta.0 = 1

Led_b Alias Porta.1
Config Led_b = Output
Porta.1 = 1

Led_c Alias Porta.2
Config Led_c = Output
Porta.2 = 1

Led_d Alias Porta.3
Config Led_d = Output
Porta.3 = 1

Led_e Alias Porta.4
Config Led_e = Output
Porta.4 = 1

Led_f Alias Porta.5
Config Led_f = Output
Porta.5 = 1

Led_g Alias Porta.6
Config Led_g = Output
Porta.6 = 1

Led_h Alias Porta.7
Config Led_h = Output
Porta.7 = 1

Led_i Alias Porte.0
Config Led_i = Output
Porte.0 = 1

Led_j Alias Porte.1
Config Led_j = Output
Porte.1 = 1

Led_k Alias Porte.2
Config Led_k = Output
Porte.2 = 1


Wa_10_1 Alias Portc.7
Config Wa_10_1 = Output

Wa_10_2 Alias Portc.6
Config Wa_10_2 = Output

Wa_11_1 Alias Portc.5
Config Wa_11_1 = Output

Wa_11_2 Alias Portc.4
Config Wa_11_2 = Output

Wa_12_1 Alias Portc.3
Config Wa_12_1 = Output

Wa_12_2 Alias Portc.2
Config Wa_12_2 = Output

Wa_13_1 Alias Portc.1
Config Wa_13_1 = Output

Wa_13_2 Alias Portc.0
Config Wa_13_2 = Output

Wa_14_1 Alias Portb.7
Config Wa_14_1 = Output

Wa_14_2 Alias Portb.6
Config Wa_14_2 = Output

Wa_15_1 Alias Portb.5
Config Wa_15_1 = Output

Wa_15_2 Alias Portb.4
Config Wa_15_2 = Output

Wa_16_1 Alias Portb.3
Config Wa_16_1 = Output

Wa_16_2 Alias Portb.2
Config Wa_16_2 = Output

Wa_17_1 Alias Portb.1
Config Wa_17_1 = Output

Wa_17_2 Alias Portb.0
Config Wa_17_2 = Output



Taster_1 Alias Pind.0
Config Taster_1 = Input
Portd.0 = 1

Taster_2 Alias Pind.1
Config Taster_2 = Input
Portd.1 = 1

Taster_3 Alias Pind.2
Config Taster_3 = Input
Portd.2 = 1

Taster_4 Alias Pind.3
Config Taster_4 = Input
Portd.3 = 1

Taster_5 Alias Pind.4
Config Taster_5 = Input
Portd.4 = 1

Taster_6 Alias Pind.5
Config Taster_6 = Input
Portd.5 = 1

Taster_7 Alias Pind.6
Config Taster_7 = Input
Portd.6 = 1


Do

If Taster_1 = 0 Then
Led_a = 1
Led_b = 1
Led_c = 1
Led_d = 1
Led_e = 1
Led_f = 1
Led_g = 1
Led_h = 1
Led_i = 1
Led_j = 1
Led_k = 1
Wait 1
Led_a = 0
Led_b = 0
Led_c = 0
Led_d = 0
Led_e = 0
Led_f = 0
Led_g = 0
Led_h = 0
Led_i = 0
Led_j = 0
Led_k = 0
Wa_17_1 = 1
Waitms 250
Wa_17_1 = 0
Led_a = 1
Led_d = 1
Led_f = 1
Waitms 250
Led_a = 0
Led_d = 0
Led_f = 0
Waitms 250
Led_a = 1
Led_d = 1
Led_f = 1
Waitms 250
Led_a = 0
Led_d = 0
Led_f = 0
Waitms 250
Wa_14_1 = 1
Led_a = 1
Led_d = 1
Led_f = 1
Waitms 250
Wa_14_1 = 0
Led_a = 0
Led_d = 0
Led_f = 0
Waitms 250
Led_a = 1
Led_d = 1
Led_f = 1
Waitms 250
Led_a = 0
Led_d = 0
Led_f = 0
Waitms 250
Led_a = 1
Led_d = 1
Led_f = 1
Waitms 250
Wa_15_1 = 1
Led_a = 0
Led_d = 0
Led_f = 0
Waitms 250
Wa_15_1 = 0
Led_a = 1
Led_d = 1
Led_f = 1
Waitms 250
Led_a = 0
Led_d = 0
Led_f = 0
Waitms 250
Led_a = 1
Led_d = 1
Led_f = 1
Waitms 250
Led_a = 0
Led_d = 0
Led_f = 0
Waitms 250
Wa_13_1 = 1
Led_a = 1
Led_d = 1
Led_f = 1
Waitms 250
Wa_13_1 = 0
Led_a = 0
Led_d = 0
Led_f = 0
Waitms 250
Led_a = 1
Led_d = 1
Led_f = 1
Waitms 250
Led_a = 0
Led_d = 0
Led_f = 0
Waitms 250
Led_a = 1
Led_d = 1
Led_f = 1
Waitms 250
Wa_12_2 = 1
Led_a = 0
Led_d = 0
Led_f = 0
Waitms 250
Wa_12_2 = 0
Led_a = 1
Led_d = 1
Led_f = 1
Waitms 250
Led_a = 0
Led_d = 0
Led_f = 0
Waitms 250
Led_a = 1
Led_d = 1
Led_f = 1
Waitms 250
Led_a = 0
Led_d = 0
Led_f = 0
Waitms 250
Led_a = 1
Led_d = 1
Led_f = 1
End If


If Taster_2 = 0 Then
Led_a = 1
Led_b = 1
Led_c = 1
Led_d = 1
Led_e = 1
Led_f = 1
Led_g = 1
Led_h = 1
Led_i = 1
Led_j = 1
Led_k = 1
Wait 1
Led_a = 0
Led_b = 0
Led_c = 0
Led_d = 0
Led_e = 0
Led_f = 0
Led_g = 0
Led_h = 0
Led_i = 0
Led_j = 0
Led_k = 0
Wa_17_1 = 1
Waitms 250
Wa_17_1 = 0
Led_b = 1
Led_d = 1
Led_f = 1
Waitms 250
Led_b = 0
Led_d = 0
Led_f = 0
Waitms 250
Led_b = 1
Led_d = 1
Led_f = 1
Waitms 250
Led_b = 0
Led_d = 0
Led_f = 0
Waitms 250
Wa_14_1 = 1
Led_b = 1
Led_d = 1
Led_f = 1
Waitms 250
Wa_14_1 = 0
Led_b = 0
Led_d = 0
Led_f = 0
Waitms 250
Led_b = 1
Led_d = 1
Led_f = 1
Waitms 250
Led_b = 0
Led_d = 0
Led_f = 0
Waitms 250
Led_b = 1
Led_d = 1
Led_f = 1
Waitms 250
Wa_15_1 = 1
Led_b = 0
Led_d = 0
Led_f = 0
Waitms 250
Wa_15_1 = 0
Led_b = 1
Led_d = 1
Led_f = 1
Waitms 250
Led_b = 0
Led_d = 0
Led_f = 0
Waitms 250
Led_b = 1
Led_d = 1
Led_f = 1
Waitms 250
Led_b = 0
Led_d = 0
Led_f = 0
Waitms 250
Wa_13_1 = 1
Led_b = 1
Led_d = 1
Led_f = 1
Waitms 250
Wa_13_1 = 0
Led_b = 0
Led_d = 0
Led_f = 0
Waitms 250
Led_b = 1
Led_d = 1
Led_f = 1
Waitms 250
Led_b = 0
Led_d = 0
Led_f = 0
Waitms 250
Led_b = 1
Led_d = 1
Led_f = 1
Waitms 250
Wa_12_1 = 1
Led_b = 0
Led_d = 0
Led_f = 0
Waitms 250
Wa_12_1 = 0
Led_b = 1
Led_d = 1
Led_f = 1
Waitms 250
Led_b = 0
Led_d = 0
Led_f = 0
Waitms 250
Led_b = 1
Led_d = 1
Led_f = 1
Waitms 250
Led_b = 0
Led_d = 0
Led_f = 0
Waitms 250
Led_b = 1
Led_d = 1
Led_f = 1
End If


If Taster_3 = 0 Then
Led_a = 1
Led_b = 1
Led_c = 1
Led_d = 1
Led_e = 1
Led_f = 1
Led_g = 1
Led_h = 1
Led_i = 1
Led_j = 1
Led_k = 1
Wait 1
Led_a = 0
Led_b = 0
Led_c = 0
Led_d = 0
Led_e = 0
Led_f = 0
Led_g = 0
Led_h = 0
Led_i = 0
Led_j = 0
Led_k = 0
Wa_10_1 = 1
Waitms 250
Wa_10_1 = 0
Led_c = 1
Led_e = 1
Led_f = 1
Waitms 250
Led_c = 0
Led_e = 0
Led_f = 0
Waitms 250
Led_c = 1
Led_e = 1
Led_f = 1
Waitms 250
Led_c = 0
Led_e = 0
Led_f = 0
Waitms 250
Wa_11_1 = 1
Led_c = 1
Led_e = 1
Led_f = 1
Waitms 250
Wa_11_1 = 0
Led_c = 0
Led_e = 0
Led_f = 0
Waitms 250
Led_c = 1
Led_e = 1
Led_f = 1
Waitms 250
Led_c = 0
Led_e = 0
Led_f = 0
Waitms 250
Led_c = 1
Led_e = 1
Led_f = 1
Waitms 250
Wa_13_2 = 1
Led_c = 0
Led_e = 0
Led_f = 0
Waitms 250
Wa_13_2 = 0
Led_c = 1
Led_e = 1
Led_f = 1
Waitms 250
Led_c = 0
Led_e = 0
Led_f = 0
Waitms 250
Led_c = 1
Led_e = 1
Led_f = 1
Waitms 250
Led_c = 0
Led_e = 0
Led_f = 0
Waitms 250
Wa_14_1 = 1
Led_c = 1
Led_e = 1
Led_f = 1
Waitms 250
Wa_14_1 = 0
Led_c = 0
Led_e = 0
Led_f = 0
Waitms 250
Led_c = 1
Led_e = 1
Led_f = 1
Waitms 250
Led_c = 0
Led_e = 0
Led_f = 0
Waitms 250
Led_c = 1
Led_e = 1
Led_f = 1
Waitms 250
Wa_15_1 = 1
Led_c = 0
Led_e = 0
Led_f = 0
Waitms 250
Wa_15_1 = 0
Led_c = 1
Led_e = 1
Led_f = 1
Waitms 250
Led_c = 0
Led_e = 0
Led_f = 0
Waitms 250
Led_c = 1
Led_e = 1
Led_f = 1
Waitms 250
Wa_17_1 = 1
Led_c = 0
Led_e = 0
Led_f = 0
Waitms 250
Wa_17_1 = 0
Led_c = 1
Led_e = 1
Led_f = 1
End If


If Taster_4 = 0 Then
Led_a = 1
Led_b = 1
Led_c = 1
Led_d = 1
Led_e = 1
Led_f = 1
Led_g = 1
Led_h = 1
Led_i = 1
Led_j = 1
Led_k = 1
Wait 1
Led_a = 0
Led_b = 0
Led_c = 0
Led_d = 0
Led_e = 0
Led_f = 0
Led_g = 0
Led_h = 0
Led_i = 0
Led_j = 0
Led_k = 0
Wa_10_1 = 1
Waitms 250
Wa_10_1 = 0
Led_c = 1
Led_g = 1
Waitms 250
Led_c = 0
Led_g = 0
Waitms 250
Led_c = 1
Led_g = 1
Waitms 250
Led_c = 0
Led_g = 0
Waitms 250
Wa_11_2 = 1
Led_c = 1
Led_g = 1
Waitms 250
Wa_11_2 = 0
Led_c = 0
Led_g = 0
Waitms 250
Led_c = 1
Led_g = 1
Waitms 250
Led_c = 0
Led_g = 0
Waitms 250
Led_c = 1
Led_g = 1
Waitms 250
Wa_14_1 = 1
Led_c = 0
Led_g = 0
Waitms 250
Wa_14_1 = 0
Led_c = 1
Led_g = 1
Waitms 250
Led_c = 0
Led_g = 0
Waitms 250
Led_c = 1
Led_g = 1
Waitms 250
Led_c = 0
Led_g = 0
Waitms 250
Wa_15_2 = 1
Led_c = 1
Led_g = 1
Waitms 250
Wa_15_2 = 0
Led_c = 0
Led_g = 0
Waitms 250
Led_c = 1
Led_g = 1
Waitms 250
Led_c = 0
Led_g = 0
Waitms 250
Led_c = 1
Led_g = 1
Waitms 250
Wa_17_1 = 1
Led_c = 0
Led_g = 0
Waitms 250
Wa_17_1 = 0
Led_c = 1
Led_g = 1
Waitms 250
Led_c = 0
Led_g = 0
Waitms 250
Led_c = 1
Led_g = 1
Waitms 250
Led_c = 0
Led_g = 0
Waitms 250
Led_c = 1
Led_g = 1
End If


If Taster_5 = 0 Then
Led_a = 1
Led_b = 1
Led_c = 1
Led_d = 1
Led_e = 1
Led_f = 1
Led_g = 1
Led_h = 1
Led_i = 1
Led_j = 1
Led_k = 1
Wait 1
Led_a = 0
Led_b = 0
Led_c = 0
Led_d = 0
Led_e = 0
Led_f = 0
Led_g = 0
Led_h = 0
Led_i = 0
Led_j = 0
Led_k = 0
Wa_10_2 = 1
Waitms 250
Wa_10_2 = 0
Led_h = 1
Led_j = 1
Waitms 250
Led_h = 0
Led_j = 0
Waitms 250
Led_h = 1
Led_j = 1
Waitms 250
Led_h = 0
Led_j = 0
Waitms 250
Wa_16_1 = 1
Led_h = 1
Led_j = 1
Waitms 250
Wa_16_1 = 0
Led_h = 0
Led_j = 0
Waitms 250
Led_h = 1
Led_j = 1
Waitms 250
Led_h = 0
Led_j = 0
Waitms 250
Led_h = 1
Led_j = 1
Waitms 250
Wa_17_2 = 1
Led_h = 0
Led_j = 0
Waitms 250
Wa_17_2 = 0
Led_h = 1
Led_j = 1
Waitms 250
Led_h = 0
Led_j = 0
Waitms 250
Led_h = 1
Led_j = 1
Waitms 250
Led_h = 0
Led_j = 0
Waitms 250
Led_h = 1
Led_j = 1
Waitms 250
Led_h = 0
Led_j = 0
Waitms 250
Led_h = 1
Led_j = 1
Waitms 250
Led_h = 0
Led_j = 0
Waitms 250
Led_h = 1
Led_j = 1
Waitms 250
Led_h = 0
Led_j = 0
Waitms 250
Led_h = 1
Led_j = 1
Waitms 250
Led_h = 0
Led_j = 0
Waitms 250
Led_h = 1
Led_j = 1
Waitms 250
Led_h = 0
Led_j = 0
Waitms 250
Led_h = 1
Led_j = 1
End If


If Taster_6 = 0 Then
Led_a = 1
Led_b = 1
Led_c = 1
Led_d = 1
Led_e = 1
Led_f = 1
Led_g = 1
Led_h = 1
Led_i = 1
Led_j = 1
Led_k = 1
Wait 1
Led_a = 0
Led_b = 0
Led_c = 0
Led_d = 0
Led_e = 0
Led_f = 0
Led_g = 0
Led_h = 0
Led_i = 0
Led_j = 0
Led_k = 0
Wa_17_1 = 1
Waitms 250
Wa_17_1 = 0
Led_i = 1
Waitms 250
Led_i = 0
Waitms 250
Led_i = 1
Waitms 250
Led_i = 0
Waitms 250
Wa_15_1 = 1
Led_i = 1
Waitms 250
Wa_15_1 = 0
Led_i = 0
Waitms 250
Led_i = 1
Waitms 250
Led_i = 0
Waitms 250
Led_i = 1
Waitms 250
Wa_14_2 = 1
Led_i = 0
Waitms 250
Wa_14_2 = 0
Led_i = 1
Waitms 250
Led_i = 0
Waitms 250
Led_i = 1
Waitms 250
Led_i = 0
Waitms 250
Led_i = 1
Waitms 250
Led_i = 0
Waitms 250
Led_i = 1
Waitms 250
Led_i = 0
Waitms 250
Led_i = 1
Waitms 250
Led_i = 0
Waitms 250
Led_i = 1
Waitms 250
Led_i = 0
Waitms 250
Led_i = 1
Waitms 250
Led_i = 0
Waitms 250
Led_i = 1
End If


If Taster_7 = 0 Then
Led_a = 1
Led_b = 1
Led_c = 1
Led_d = 1
Led_e = 1
Led_f = 1
Led_g = 1
Led_h = 1
Led_i = 1
Led_j = 1
Led_k = 1
Wait 1
Led_a = 0
Led_b = 0
Led_c = 0
Led_d = 0
Led_e = 0
Led_f = 0
Led_g = 0
Led_h = 0
Led_i = 0
Led_j = 0
Led_k = 0
Wa_10_2 = 1
Waitms 250
Wa_10_2 = 0
Led_h = 1
Led_k = 1
Waitms 250
Led_h = 0
Led_k = 0
Waitms 250
Led_h = 1
Led_k = 1
Waitms 250
Led_h = 0
Led_k = 0
Waitms 250
Wa_16_2 = 1
Led_h = 1
Led_k = 1
Waitms 250
Wa_16_2 = 0
Led_h = 0
Led_k = 0
Waitms 250
Led_h = 1
Led_k = 1
Waitms 250
Led_h = 0
Led_k = 0
Waitms 250
Led_h = 1
Led_k = 1
Waitms 250
Led_h = 0
Led_k = 0
Waitms 250
Led_h = 1
Led_k = 1
Waitms 250
Led_h = 0
Led_k = 0
Waitms 250
Led_h = 1
Led_k = 1
Waitms 250
Led_h = 0
Led_k = 0
Waitms 250
Led_h = 1
Led_k = 1
Waitms 250
Led_h = 0
Led_k = 0
Waitms 250
Led_h = 1
Led_k = 1
Waitms 250
Led_h = 0
Led_k = 0
Waitms 250
Led_h = 1
Led_k = 1
Waitms 250
Led_h = 0
Led_k = 0
Waitms 250
Led_h = 1
Led_k = 1
Waitms 250
Led_h = 0
Led_k = 0
Waitms 250
Led_h = 1
Led_k = 1
Waitms 250
Led_h = 0
Led_k = 0
Waitms 250
Led_h = 1
Led_k = 1
End If

Loop
End


Das Programm ist sicherlich nicht optimal Programmiert, ich komme in dieser Art und Weise relativ gut klar Rolling Eyes .

LG Felix

Re: Problem mit ATMEGA162 - PORTC.4; 5; 6; 7 funktioniert ni

Von gerold am 10.02.2010 20:05

modellfreund hat folgendes geschrieben:
PortC.4; PortC.5; PortC.6; PortC.7

Hallo Felix!

Diese Pins sind mit dem JTAG-Interface vorbelegt. JTAG musst du über die Fuse-Bits deaktivieren. Dann läuft es.

lg
Gerold
Smile

Von gerold am 10.02.2010 20:11

modellfreund hat folgendes geschrieben:
Code:
$hwstack = 500
$swstack = 500
$framesize = 500

Hallo Felix!

Laut Datenblatt hat der ATmega162 1024 Byte SRAM. Davon verbrauchst du mit den von dir gezeigten Anweisungen ca. 150 %. Wink Du hattest bis jetzt nur Glück, dass du noch keine Variablen und Prozeduren gebraucht hast -- sonst wäre dein Programm irgendwie unkontrollierbar im Speicherwirrwarr abgesoffen. Wink

Stelle HWSTACK, SWSTACK und FRAMESIZE auf jeweil 100 zurück. Damit hast du viel mehr als genug -- auch für große Projekte.

lg
Gerold
Smile

Re: Problem mit ATMEGA162 - PORTC.4; 5; 6; 7 funktioniert ni

Von modellfreund am 10.02.2010 20:18

gerold hat folgendes geschrieben:
Diese Pins sind mit dem JTAG-Interface vorbelegt. JTAG musst du über die Fuse-Bits deaktivieren.

Hallo Gerold,

vielen Dank für deine Schnelle Nachricht. Ich habe noch 2 Fragen:

- Was ist ein JTAG-Interface?
- Wie und wo kann ich (der/die/das) JTAG über die Fuse-Bits deaktivieren

LG Felix


Edit: ich werde deinen letzten Beirag beherzigen Cool

Re: Problem mit ATMEGA162 - PORTC.4; 5; 6; 7 funktioniert ni

Von gerold am 10.02.2010 20:43

modellfreund hat folgendes geschrieben:
- Was ist ein JTAG-Interface?

Hallo Felix!

Kurz gesagt: Es ist wie die ISP (In System Programming) Schnittstelle, eine Möglichkeit, das Programm vom Computer zum µC zu übertragen. JTAG hat den Vorteil, dass man damit das Programm zusätzlich auch debuggen (sozusagen, beim Laufen beobachten) kann. Das ist für Assembler oder C-Programmierer manchmal nicht schlecht, für Bascom-Hardcore-Programmierer vielleicht mal interessant, aber für dich und mich absolut unwichtig und kann gefahrlos deaktiviert werden.


modellfreund hat folgendes geschrieben:
- Wie und wo kann ich (der/die/das) JTAG über die Fuse-Bits deaktivieren

Mit welchem Programm änderst du die Fuse-Bits?

Lesestoff: http://halvar.at/elektronik/kleiner_bascom_avr_kurs/ Kapitel 22, 23, 24

Eine genaue Anleitung für den ATmega162 kann ich dir nicht geben. Ich habe weder einen ATmega162, noch im Moment irgend ein Elektronik-Programm auf meinem Computer installiert.

mfg
Gerold
Smile

Von Elektron am 10.02.2010 20:46

Zu der Frage was ein JTAG-Interface ist (ich wusste es ehrlich gesagt auch nicht so genau): http://de.wikipedia.org/wiki/JTAG

Das umstellen der Fuse Bits sollte mit dem Programm geschehen, mit dem du deinen Code auf den µC bringst. Ich habe nur in C programmiert und mit PonyProg2000 gab es da jedenfalls ein extra Menü.

edit:
Ups, da war gerold schneller^^

Von BellaD am 10.02.2010 21:28

Zitat:
- Wie und wo kann ich (der/die/das) JTAG über die Fuse-Bits deaktivieren



Das ist der Standardfehler " Datenblatt nicht gelesen "
^^
mfg

Anzeige: