This is a multi-part message in MIME format.
------=_NextPart_000_002A_01C149D8.763B0EB0
Content-Type: multipart/alternative;
boundary="----=_NextPart_001_002B_01C149D8.763B0EB0"
------=_NextPart_001_002B_01C149D8.763B0EB0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
I have alot of delay codes which i "call" at certain times to produce =
some PWM signals but these delays consume alot of space in the pic so i =
was thinking if it was possible to shorten them.
I've used JAL (a nice compiler from wouter) and there i could use =
procedures which could reduce the code size rapitly forinstance:
Procedure delay ( byte in x, byte in y, byte in z ) is=20
delay_1us ( x )
delay_1us ( y )=20
delay_1us ( z )=20
end procedure=20
As you can see its possible to adjust almost every delay with the =
variables x, y, z then i used to call the delay like this=20
delay ( 10, 100, 1000 )
This would produce a delay of 10+100+1000uS as X=3D10 , y=3D100, =
z=3D1000
As im a newbie in assembler i dont have enough experience to produce =
such features in assembler.=20
So i was hoping that some of you diehards would help me :)=20
I have attached the code.=20
Many thanks to all who wants to take a look at this !=20
Best regards
Lasse Madsen
------=_NextPart_001_002B_01C149D8.763B0EB0
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
I have alot of delay codes which i =
"call" at=20
certain times to produce some PWM signals but these delays consume alot =
of space=20
in the pic so i was thinking if it was possible to shorten=20
them.
I've used JAL (a nice compiler from =
wouter) and=20
there i could use procedures which could reduce the code size=20
rapitly forinstance:
<CODE>
Procedure delay ( byte in x, byte =
in y, byte=20
in z ) is
delay_1us ( x )
delay_1us ( y )
delay_1us ( z )
end procedure
</CODE>
As you can see its possible to adjust =
almost every=20
delay with the variables x, y, z then i used to call the delay like this =
delay ( 10, 100, 1000 )
This would produce a delay of =
10+100+1000uS as X=3D10=20
, y=3D100, z=3D1000
As im a newbie in assembler i dont have =
enough=20
experience to produce such features in assembler.
So i was hoping that some of you =
diehards would=20
help me :)
I have attached the code.
Many thanks to all who wants to take a =
look at this=20
!
Best regards
Lasse Madsen
------=_NextPart_001_002B_01C149D8.763B0EB0--
------=_NextPart_000_002A_01C149D8.763B0EB0
Content-Type: application/octet-stream;
name="myfirst.asm"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
filename="myfirst.asm"
list p=3D16f84a
radix hex =09
porta equ 0x05=09
org 0x000 =09
start movlw 0x00 =09
tris porta =09
ecount equ 0x0c
ncount equ 0x0d
mcount equ 0x0e
count equ 0x1a
counter equ 0x1b
deg CALL nr1
CALL nr2
CALL nr3
CALL nr4
CALL nr5
CALL nr6
CALL nr7
CALL nr8
GOTO deg
;--- Minimize from below ---
; PROCEDURES WHICH MIXES 2 DELAYS=20
nr1 movlw 0xFF
movwf counter
loop BCF porta,01
CALL pulse
BSF porta,01
CALL farve_1
decfsz counter,f
goto loop
BCF porta,01
return
nr2 movlw 0xFF
movwf counter
loop1 BCF porta,01
CALL pulse
BSF porta,01
CALL farve_2
decfsz counter,f
goto loop1
BCF porta,01
return
nr3 movlw 0xFF
movwf counter
loop2 BCF porta,01
CALL pulse
BSF porta,01
CALL farve_3
decfsz counter,f
goto loop2
BCF porta,01
return
nr4 movlw 0xFF
movwf counter
loop3 BCF porta,01
CALL pulse
BSF porta,01
CALL farve_4
decfsz counter,f
goto loop3
BCF porta,01
return
nr5 movlw 0xFF
movwf counter
loop4 BCF porta,01
CALL pulse
BSF porta,01
CALL farve_5
decfsz counter,f
goto loop4
BCF porta,01
return
nr6 movlw 0xFF
movwf counter
loop5 BCF porta,01
CALL pulse
BSF porta,01
CALL farve_6
decfsz counter,f
goto loop5
BCF porta,01
return
nr7 movlw 0xFF
movwf counter
loop6 BCF porta,01
CALL pulse
BSF porta,01
CALL farve_7
decfsz counter,f
goto loop6
BCF porta,01
return
nr8 movlw 0xFF
movwf counter
loop7 BCF porta,01
CALL pulse
BSF porta,01
CALL farve_8
decfsz counter,f
goto loop7
BCF porta,01
return
; --- ACTUAL PWM DELAY SUBROUTINES ---
; =3D=3D=3D Farve 1 =3D=3D=3D
farve_1 clrf mcount
clrf ecount
movlw 0x09=09
movwf mcount
l1 movlw 0x10
movwf ecount
d1 decfsz ecount,f
goto d1
decfsz mcount,f
goto l1
clrf mcount
movlw d'125'
movwf mcount
a1 decfsz mcount,f
goto a1
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
return=09
; =3D=3D=3D=3D Farve 2
farve_2 clrf mcount
clrf ecount
movlw 0x12=09
movwf mcount
l2 movlw 0x10
movwf ecount
d2 decfsz ecount,f
goto d2
decfsz mcount,f
goto l2
clrf mcount
movlw 0x0E
movwf mcount
a2 decfsz mcount,f
goto a2
NOP
NOP
NOP
NOP
NOP
return=09
; =3D=3D=3D=3D Farve 3
farve_3 clrf mcount
clrf ecount
movlw 0x14=09
movwf mcount
l3 movlw 0x11
movwf ecount
d3 decfsz ecount,f
goto d3
decfsz mcount,f
goto l3
clrf mcount
movlw 0x15
movwf mcount
a3 decfsz mcount,f
goto a3
NOP
NOP
NOP
NOP
NOP
return=09
; =3D=3D=3D=3D Farve 4
farve_4 clrf mcount
clrf ecount
movlw 0x15=09
movwf mcount
l4 movlw 0x14
movwf ecount
d4 decfsz ecount,f
goto d4
decfsz mcount,f
goto l4
clrf mcount
movlw 0x02
movwf mcount
a4 decfsz mcount,f
goto a4
NOP
NOP
NOP
NOP
return=09
; =3D=3D=3D=3D Farve 5
farve_5 clrf mcount
clrf ecount
movlw 0x17=09
movwf mcount
l5 movlw 0x15
movwf ecount
d5 decfsz ecount,f
goto d5
decfsz mcount,f
goto l5
return=09
; =3D=3D=3D=3D Farve 6
farve_6 clrf mcount
clrf ecount
movlw 0x18=09
movwf mcount
l6 movlw 0x16
movwf ecount
d6 decfsz ecount,f
goto d6
decfsz mcount,f
goto l6
clrf mcount
movlw 0x0D
movwf mcount
a6 decfsz mcount,f
goto a6
NOP
NOP
NOP
NOP
NOP
return=09
; =3D=3D=3D=3D Farve 7
farve_7 clrf mcount
clrf ecount
movlw 0x19=09
movwf mcount
l7 movlw 0x18
movwf ecount
d7 decfsz ecount,f
goto d7
decfsz mcount,f
goto l7
clrf mcount
movlw 0x02
movwf mcount
a7 decfsz mcount,f
goto a7
NOP
NOP
;fjernet 2 nop
return=09
; =3D=3D=3D=3D Farve 8
farve_8 clrf mcount
clrf ecount
movlw 0x1A=09
movwf mcount
l8 movlw 0x19
movwf ecount
d8 decfsz ecount,f
goto d8
decfsz mcount,f
goto l8
=09
clrf mcount
movlw 19
movwf mcount
a8 decfsz mcount,f
goto a8
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
return
; --- MIXING DELAY - MIXES THE ABOVE DELAYS WITH THIS AND PRODUCE A PWM =
SIGNAL
; =3D=3D=3D=3D=3D Timer Puls =3D=3D=3D=3D=3D
pulse clrf ncount
clrf count
movlw 0x52=09
movwf count
loadn movlw 0x50
movwf ncount
decn decfsz ncount,f
goto decn
decfsz count,f
goto loadn
return
end
------=_NextPart_000_002A_01C149D8.763B0EB0--
--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics