PDA

Archiv verlassen und diese Seite im Standarddesign anzeigen : Hardwarefehler? STK500 m8 Assembler



Deathadders
18.09.2006, 14:43
hallo, wie die überschrift schon sagt, ich habe ein programm im Assembler geschrieben. Nachdem ich das STK500 upgedatet habe, habe ich die hex auf den controller (ATmega8) geladen, hat auch alles geklappt. dann habe ich auf dem board umgestöpselt, so das der controller laufen sollte, aber nicht eine einzige LED leuchtet. obwohl die Simulation einwandfrei geklappt hat. Hier ist auch nochmal der code, es handelt sich um eine einfach ampelschaltung für 2 ampeln. bit 0 bis 2 an PORTB ist eine ampel und bit 3 bis 5 ist die zweite ampel. Das delay ist ein aus drei zählern zusammen gesetzt oZahl mZahl und uZahl (steht für oberer, mittlere und unterer zähler) dadurch gibt oZahl die sekundenzahl an. der rest erklärt sich glaube ich von selbst.

achja, ich habe mal eine alte hex übergespielet, und das hat gefuntzt! also am µC oder an der verkabelung liegt es nicht.


; Ampel steuerung mit ATMega 8

.include "m8def.inc"
.def temp = r16
.def uZahl = r17
.def mZahl = r18
.def oZahl = r19

ldi temp, Low(RAMEND)
out SPL, temp
ldi temp, high(RAMEND)
out SPH, temp ;Stack Pointer Intialisieren

ldi temp, 0x00
out DDRB, temp ;Byte D ist ausgang

ldi temp, 0x36
out PORTB, temp ;Alle ampeln Rot

ldi oZahl, 0x00100100
rcall delay

nop
rjmp loop


delay:
ldi mZahl, 0xff
delay_:
ldi uZahl, 201
delay__:
dec uZahl
brne delay__
dec mZahl
brne delay_
dec oZahl
brne delay
ret


loop:

ldi temp, 0b00100110 ;Rot - Rot Gelb
out PortB, temp
ldi oZahl, 1
rcall delay

ldi temp, 0b00100001 ;Rot - Grün
out PortB, temp
ldi oZahl, 5
rcall delay

ldi temp, 0b00100010 ;Rot - Gelb
out PortB, temp
ldi oZahl, 1
rcall delay

ldi temp, 0b00100100 ;Rot - Rot
out PortB, temp
ldi oZahl, 1
rcall delay

ldi temp, 0b00110100 ;Rot Gelb - Rot
out PortB, temp
ldi oZahl, 1
rcall delay

ldi temp, 0b00001100 ;Grün - Rot
out PortB, temp
ldi oZahl, 5
rcall delay

ldi temp, 0b00010100 ;Gelb - Rot
out PortB, temp
ldi oZahl, 1
rcall delay

ldi temp, 0b00100100 ;Rot - Rot
out PortB, temp
ldi oZahl, 1
rcall delay

rjmp loop


danke für die hilfe!

albundy
19.09.2006, 09:37
ldi temp, 0x00
out DDRB, temp ;Byte D ist ausgang

damit wird Portb nicht als Ausgang, sondern als Eingang definiert.

Deathadders
19.09.2006, 16:48
oh ha, stimmt ja, in der simulation wird trotzdem alles ordnungsgemäß ausgegeben!?!

Deathadders
19.09.2006, 17:49
So, also so ists jeztz richtig.

; Ampel steuerung mit ATMega 8

.include "m8def.inc"
.def temp = r16
.def uZahl = r17
.def mZahl = r18
.def oZahl = r19

ldi temp, Low(RAMEND)
out SPL, temp
ldi temp, high(RAMEND)
out SPH, temp ;Stack Pointer Intialisieren

ldi temp, 0xff
out DDRB, temp ;Port B ist ausgang


Main:

ldi temp, 0b110110 ;Rot - Rot
out PortB, temp
ldi oZahl, 25
rcall delay

ldi temp, 0b110100 ;Rot - Rot Gelb
out PortB, temp
ldi oZahl, 25
rcall delay

ldi temp, 0b110011 ;Rot - Grün
out PortB, temp
ldi oZahl, 200
rcall delay

ldi temp, 0b110101 ;Rot - Gelb
out PortB, temp
ldi oZahl, 25
rcall delay

ldi temp, 0b110110 ;Rot - Rot
out PortB, temp
ldi oZahl, 25
rcall delay

ldi temp, 0b100110 ;Rot Gelb - Rot
out PortB, temp
ldi oZahl, 25
rcall delay

ldi temp, 0b1011110 ;Grün - Rot
out PortB, temp
ldi oZahl, 200
rcall delay

ldi temp, 0b101110 ;Gelb - Rot
out PortB, temp
ldi oZahl, 25
rcall delay

rjmp main

delay: ;Delay
ldi mZahl, 209
delay_:
ldi uZahl, 0xff
delay__:
dec uZahl
brne delay__
dec mZahl
brne delay_
dec oZahl
brne delay
ret

Slein
19.09.2006, 19:06
oh ha, stimmt ja, in der simulation wird trotzdem alles ordnungsgemäß ausgegeben!?!

Ja, in der Simulation werden die Bits im Port gleich angezeigt, egal ob der Pin Eingang oder Ausgang ist. Nur schaltest du bei Ausgang den Pin, bei Eingang aber nur den Pullup Widerstand des Pins.

Sieht man aber eine Zeile tiefer bei DDRx schön (Ein-/Ausgang).

Viels Spass noch!