PDA

Archiv verlassen und diese Seite im Standarddesign anzeigen : Probleme mit AT89C2051 & Assambler



Groppo
23.04.2008, 19:40
Hallo ich habe folgendes Problem:

ich bin gerade dabei eine Steuerung für einen Schrittmotor in Assambler mit Proview zu programmieren.
Mein Problem ist MANCHMAL, dass ich ein Programm auf meiner Programmieroberfläche simuliere und es läuft wunderbar, aber auf dem Controller gehen manchmal einige Ausgangsbits nicht oder es geht garnix, obwohl ich nur kleine Änderungen an der Software gemacht habe. Die Hardware ist OK, fast alle Programme laufen fehlerfrei.

Dies Programm geht auf dem PC, aber nicht im Atmel. Habe bereits mehrere µC getestet, nix. Die unten hinterlegten Werte sind Wartezeiten um die Geschw. linear zu bekommen. Der Motor wird mit Halbschritten angesteuert.
Was mach ich falsch?


EDIT: Also ich hab nun die Steuerwerte über die Zeitwerte gesetzt und jetzt geht es!

komisch mein Prog hab keine 500 Byte und der Atmel kann ja 2048 Byte.
Ist der Compiler falsch eingestellt?
ich verwende noch ein kleines tool um die hex dateien in bin zu wandel (hex2bin.exe), kann da der Fehler liegen?



Danke im Vorraus


Port 1 ist der eingang
Port 3 steuert den Motor

port1: 0 ............................ 128............................. 255
motor: schnell links ...................Stillstand .................. schnell rechts



#########################Start#############
org 0
mov 12h,#1 ;Motorposition ( 1-8 )
mov p3,#0c3h




start:
mov r1,p1 ;0-255 = p1 -> +/- 0-128 => +/- = 18h , 0-128 = r2
mov a,r1
clr c
subb a,#128
mov r2,a

mov 18h,#1 ; Richtung
jnc aa

mov 18h,#0
mov a,#128
clr c
subb a,r1
mov r2,a ;0-255 -> +/- 127
aa:

mov a,r2 ;ruhezone
clr c
subb a,#3 ; Zonenbreite
jnc bb
mov a,#0
bb: mov r2,a ;ruhezone
mov a,r2

jz cc ; 0 bewegung > sprung

mov dptr,#WerteH ; zeitwerte holen
movc a,@a+dptr
mov 10h,a
mov a,r2
mov dptr,#WerteL
movc a,@a+dptr
mov 11h,a ;-



mov a,18h ; Drehrichtung
jz neg
mov a,12h
rr a
mov 12h,a
jmp e1
neg:
mov a,12h
rl a
mov 12h,a
e1:
mov 13h,#8


mov a,12h
e2: rr a
mov 16h,a
djnz 16h,e3
mov 15h,a
jmp e4
e3:
djnz 13h,e2

e4:

mov a,13h
mov dptr,#Steuerwert ; Motorsteuerwert holen
movc a,@a+dptr


orl a,#0c3h ;maskierung
mov p3,a



mov 20h,10h
mov 21h,11h

mov 23h,#12

pp1: ;Pause

pp2: nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop

djnz 21h, pp2

djnz 23h,kill3
mov p3,#0c3h
kill3:
djnz 20h, pp1

mov 22h,#0

jmp start
cc: ; 0 bewegung ziel

djnz 22h,start1

mov p3,#0c3h

start1: jmp start

WerteH: db 0, 64, 64, 64, 42, 32, 25, 21, 18, 16, 14, 12, 11, 10, 9, 9, 8, 8, 7, 7, 6, 6, 6, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
WerteL: db 0, 0, 0, 0, 0, 0, 154, 85, 73, 0, 57, 205, 163, 171, 217, 37, 137, 0, 136, 28, 189, 102, 24, 209, 145, 85, 31, 236, 190, 146, 106, 68, 33, 0, 225, 196, 168, 142, 118, 94, 72, 51, 31, 12, 250, 233, 216, 200, 185, 171, 157, 143, 131, 118, 106, 95, 84, 73, 63, 53, 43, 34, 25, 17, 8, 0, 248, 240, 233, 226, 219, 212, 206, 199, 193, 187, 181, 175, 170, 164, 159, 154, 149, 144, 139, 134, 130, 125, 121, 116, 112, 108, 104, 100, 96, 93, 89, 85, 82, 78, 75, 72, 68, 65, 62, 59, 56, 53, 50, 47, 45, 42, 39, 37
, 34, 31, 29, 26, 24, 22, 19, 17, 1, 1,1,1

Steuerwert: db 0, 4, 12, 8, 24, 16, 48, 32, 36

end

*******************************ende*************** ****