First commit
This commit is contained in:
commit
52495bbfba
32
Makefile
Executable file
32
Makefile
Executable file
|
|
@ -0,0 +1,32 @@
|
||||||
|
# My pic workflow makefile by Fernando R Jacobo
|
||||||
|
# Dependencies
|
||||||
|
# SDCC Small Device C Compiler
|
||||||
|
# pk2cmd for pickit pic programmers
|
||||||
|
|
||||||
|
# C compiler variables
|
||||||
|
SRC=*.c
|
||||||
|
CC=sdcc
|
||||||
|
FAMILY=pic16
|
||||||
|
PROC=18f4550
|
||||||
|
|
||||||
|
# ASM and program variables
|
||||||
|
PPROC=PIC18F4550
|
||||||
|
ASMPROC=18F4550
|
||||||
|
|
||||||
|
all: $(SRC:.c=.hex)
|
||||||
|
|
||||||
|
comp: $(SRC)
|
||||||
|
$(CC) --use-non-free -m$(FAMILY) -p$(PROC) $^
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -f $(SRC:.c=.asm) $(SRC:.c=.cod) $(SRC:.c=.hex) $(SRC:.c=.lst) $(SRC:.c=.o)
|
||||||
|
|
||||||
|
program:
|
||||||
|
pk2cmd -M -P${PPROC} -Fout.hex
|
||||||
|
|
||||||
|
asm: *.asm
|
||||||
|
gpasm -p ${ASMPROC} -o main.hex $^
|
||||||
|
|
||||||
|
asmp: asm program
|
||||||
|
|
||||||
|
.PHONY: all clean
|
||||||
32
blink/Makefile
Executable file
32
blink/Makefile
Executable file
|
|
@ -0,0 +1,32 @@
|
||||||
|
# My pic workflow makefile by Fernando R Jacobo
|
||||||
|
# Dependencies
|
||||||
|
# SDCC Small Device C Compiler
|
||||||
|
# pk2cmd for pickit pic programmers
|
||||||
|
|
||||||
|
# C compiler variables
|
||||||
|
SRC=*.c
|
||||||
|
CC=sdcc
|
||||||
|
FAMILY=pic16
|
||||||
|
PROC=18f4550
|
||||||
|
|
||||||
|
# ASM and program variables
|
||||||
|
PPROC=PIC18F4550
|
||||||
|
ASMPROC=18F4550
|
||||||
|
|
||||||
|
all: $(SRC:.c=.hex)
|
||||||
|
|
||||||
|
comp: $(SRC)
|
||||||
|
$(CC) --use-non-free -m$(FAMILY) -p$(PROC) $^
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -f $(SRC:.c=.asm) $(SRC:.c=.cod) $(SRC:.c=.hex) $(SRC:.c=.lst) $(SRC:.c=.o)
|
||||||
|
|
||||||
|
program:
|
||||||
|
pk2cmd -M -P${PPROC} -Fout.hex
|
||||||
|
|
||||||
|
asm: *.asm
|
||||||
|
gpasm -p ${ASMPROC} -o main.hex $^
|
||||||
|
|
||||||
|
asmp: asm program
|
||||||
|
|
||||||
|
.PHONY: all clean
|
||||||
45
blink/main.asm
Executable file
45
blink/main.asm
Executable file
|
|
@ -0,0 +1,45 @@
|
||||||
|
LIST P=18F4550, F=INHX32 ; Specify processor and hex format
|
||||||
|
#include <p18f4550.inc>
|
||||||
|
|
||||||
|
CONFIG FOSC = HS ; Use internal oscillator, RA6 as clock output
|
||||||
|
;CONFIG FOSC = XT_XT ; Use internal oscillator, RA6 as clock output
|
||||||
|
CONFIG WDT = OFF ; Watchdog Timer off
|
||||||
|
CONFIG LVP = OFF ; Low-Voltage Programming off
|
||||||
|
CONFIG MCLRE = OFF ; MCLR pin disabled, RE3 input enabled
|
||||||
|
R1 EQU 0x020
|
||||||
|
R2 EQU 0x021
|
||||||
|
|
||||||
|
ORG 0x00 ; Program starts at address 0
|
||||||
|
|
||||||
|
Start:
|
||||||
|
; Initialize PORTB
|
||||||
|
CLRF TRISD ; Set all PORTB pins as output
|
||||||
|
CLRF LATD ; Clear PORTB outputs
|
||||||
|
|
||||||
|
Loop:
|
||||||
|
call Delay ; Delay
|
||||||
|
; RLCF PORTD, F
|
||||||
|
MOVLW 0x15
|
||||||
|
MOVWF PORTD
|
||||||
|
CALL Delay ; Delay
|
||||||
|
MOVLW 0x00
|
||||||
|
MOVWF PORTD
|
||||||
|
goto Loop ; Repeat the loop
|
||||||
|
|
||||||
|
; Delay subroutine (approx 500ms)
|
||||||
|
Delay:
|
||||||
|
MOVLW D'250' ; Outer loop count
|
||||||
|
MOVWF R1
|
||||||
|
Delay_Outer:
|
||||||
|
MOVLW D'250' ; Inner loop count
|
||||||
|
MOVWF R2
|
||||||
|
Delay_Inner:
|
||||||
|
NOP ; Do nothing (No Operation)
|
||||||
|
NOP
|
||||||
|
DECFSZ R2, F ; Decrement inner loop counter
|
||||||
|
GOTO Delay_Inner ; Repeat inner loop
|
||||||
|
DECFSZ R1, F ; Decrement outer loop counter
|
||||||
|
GOTO Delay_Outer ; Repeat outer loop
|
||||||
|
RETURN ; Return from delay
|
||||||
|
|
||||||
|
END ; End of program
|
||||||
BIN
blink/main.cod
Normal file
BIN
blink/main.cod
Normal file
Binary file not shown.
10
blink/main.hex
Normal file
10
blink/main.hex
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
:020000040000FA
|
||||||
|
:10000000956A8C6A0CEC00F0150E836E0CEC00F017
|
||||||
|
:10001000000E836E02EF00F0FA0E206EFA0E216ED3
|
||||||
|
:1000200000000000212E10EF00F0202E0EEF00F057
|
||||||
|
:020030001200BC
|
||||||
|
:020000040030CA
|
||||||
|
:04000000000C1F1EB3
|
||||||
|
:02000500038175
|
||||||
|
:060008000FC00FE00F40E5
|
||||||
|
:00000001FF
|
||||||
1113
blink/main.lst
Normal file
1113
blink/main.lst
Normal file
File diff suppressed because it is too large
Load Diff
25
cuenta/Makefile
Executable file
25
cuenta/Makefile
Executable file
|
|
@ -0,0 +1,25 @@
|
||||||
|
# Makefile para pic
|
||||||
|
SRC=*.c
|
||||||
|
|
||||||
|
CC=sdcc
|
||||||
|
FAMILY=pic16
|
||||||
|
PROC=18f4550
|
||||||
|
HEX:=main.hex
|
||||||
|
|
||||||
|
all: $(SRC:.c=.hex)
|
||||||
|
|
||||||
|
comp: $(SRC)
|
||||||
|
$(CC) --use-non-free -m$(FAMILY) -p$(PROC) $^
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -f $(SRC:.c=.asm) $(SRC:.c=.cod) $(SRC:.c=.hex) $(SRC:.c=.lst) $(SRC:.c=.o)
|
||||||
|
|
||||||
|
asm: *.asm
|
||||||
|
gpasm -p 18F4550 -o main.hex $^
|
||||||
|
|
||||||
|
program: ${HEX}
|
||||||
|
pk2cmd -M -PPIC18F4550 -F${HEX}
|
||||||
|
|
||||||
|
asmp: asm program
|
||||||
|
|
||||||
|
.PHONY: all clean
|
||||||
225
cuenta/main.asm
Executable file
225
cuenta/main.asm
Executable file
|
|
@ -0,0 +1,225 @@
|
||||||
|
LIST P=18F4550, F=INHX32 ; Specify processor and hex format
|
||||||
|
#include <p18f4550.inc>
|
||||||
|
|
||||||
|
CONFIG FOSC = HS ; Use internal oscillator, RA6 as clock output
|
||||||
|
CONFIG WDT = OFF ; Watchdog Timer off
|
||||||
|
CONFIG LVP = OFF ; Low-Voltage Programming off
|
||||||
|
CONFIG MCLRE = OFF ; MCLR pin disabled, RE3 input enabled
|
||||||
|
;CONFIG PBADEN = OFF
|
||||||
|
|
||||||
|
ORG 0x00 ; Program starts at address 0
|
||||||
|
ROTA1 EQU 0x01
|
||||||
|
ROTA2 EQU 0x02
|
||||||
|
ROTA3 EQU 0x04
|
||||||
|
ROTA4 EQU 0x08
|
||||||
|
ROTA5 EQU 0x10
|
||||||
|
ROTA6 EQU 0x20
|
||||||
|
R1 EQU 0x020
|
||||||
|
R2 EQU 0x021
|
||||||
|
R3 EQU 0x024
|
||||||
|
CUENTA EQU 0x022
|
||||||
|
TEMP EQU 0x23
|
||||||
|
DISP0 EQU 0x30
|
||||||
|
DISP1 EQU 0x31
|
||||||
|
DISP2 EQU 0x32
|
||||||
|
DISP3 EQU 0x33
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Start:
|
||||||
|
; Initialize PORTB
|
||||||
|
CLRF TRISD ; Set all PORTB pins as output
|
||||||
|
CLRF LATD ; Clear PORTB outputs
|
||||||
|
|
||||||
|
CLRF LATB
|
||||||
|
BCF INTCON2, 7
|
||||||
|
MOVLW 0xff
|
||||||
|
MOVWF TRISB ; set port b to input
|
||||||
|
movlw 0x0f
|
||||||
|
movwf ADCON1
|
||||||
|
|
||||||
|
|
||||||
|
clrf LATE
|
||||||
|
clrf TRISE
|
||||||
|
|
||||||
|
movlw 0x06
|
||||||
|
movwf PORTE
|
||||||
|
|
||||||
|
clrf CUENTA
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
loop:
|
||||||
|
;movlw 0x17
|
||||||
|
;movwf CUENTA
|
||||||
|
;call Delay
|
||||||
|
;call sevensw
|
||||||
|
;movwf PORTD
|
||||||
|
;goto loop
|
||||||
|
movf PORTB, W
|
||||||
|
xorlw ROTA1
|
||||||
|
btfsc STATUS, Z
|
||||||
|
goto leftright
|
||||||
|
xorlw ROTA2^ROTA1
|
||||||
|
btfsc STATUS, Z
|
||||||
|
goto right
|
||||||
|
xorlw ROTA2^ROTA3
|
||||||
|
btfsc STATUS, Z
|
||||||
|
goto left
|
||||||
|
xorlw ROTA3^ROTA4
|
||||||
|
btfsc STATUS, Z
|
||||||
|
goto alternate
|
||||||
|
xorlw ROTA4^ROTA5
|
||||||
|
btfsc STATUS, Z
|
||||||
|
goto centerout
|
||||||
|
xorlw ROTA5^ROTA6
|
||||||
|
btfsc STATUS, Z
|
||||||
|
goto outcenter
|
||||||
|
goto loop
|
||||||
|
|
||||||
|
leftright:
|
||||||
|
CALL Delay ; Delay
|
||||||
|
RLCF PORTD, f
|
||||||
|
BTFSS STATUS,0
|
||||||
|
GOTO leftright ; Repeat the loop
|
||||||
|
lright:
|
||||||
|
CALL Delay ; Delay
|
||||||
|
RRCF PORTD, F
|
||||||
|
BTFSS STATUS,0
|
||||||
|
GOTO lright ; Repeat the loop
|
||||||
|
return
|
||||||
|
|
||||||
|
left:
|
||||||
|
MOVLW 0x80
|
||||||
|
MOVWF PORTD
|
||||||
|
rl: CALL Delay ; Delay
|
||||||
|
RRCF PORTD, F
|
||||||
|
BTFSS STATUS,0
|
||||||
|
GOTO rl ; Repeat the loop
|
||||||
|
return
|
||||||
|
|
||||||
|
right:
|
||||||
|
infsnz CUENTA, W
|
||||||
|
return
|
||||||
|
daw
|
||||||
|
movwf CUENTA
|
||||||
|
call splitDigit
|
||||||
|
call Delay
|
||||||
|
CALL Delay
|
||||||
|
goto right
|
||||||
|
|
||||||
|
alternate:
|
||||||
|
movlw 0xaa
|
||||||
|
movwf PORTD
|
||||||
|
call Delay
|
||||||
|
movlw 0x55
|
||||||
|
movwf PORTD
|
||||||
|
call Delay
|
||||||
|
return
|
||||||
|
|
||||||
|
centerout:
|
||||||
|
movlw 0x18
|
||||||
|
movwf PORTD
|
||||||
|
call Delay
|
||||||
|
movlw 0x24
|
||||||
|
movwf PORTD
|
||||||
|
call Delay
|
||||||
|
movlw 0x42
|
||||||
|
movwf PORTD
|
||||||
|
call Delay
|
||||||
|
movlw 0x81
|
||||||
|
movwf PORTD
|
||||||
|
call Delay
|
||||||
|
return
|
||||||
|
|
||||||
|
outcenter:
|
||||||
|
movlw 0x81
|
||||||
|
movwf PORTD
|
||||||
|
call Delay
|
||||||
|
movlw 0x42
|
||||||
|
movwf PORTD
|
||||||
|
call Delay
|
||||||
|
movlw 0x24
|
||||||
|
movwf PORTD
|
||||||
|
call Delay
|
||||||
|
movlw 0x18
|
||||||
|
movwf PORTD
|
||||||
|
call Delay
|
||||||
|
return
|
||||||
|
|
||||||
|
splitDigit:
|
||||||
|
movf CUENTA, W
|
||||||
|
andlw 0x0f
|
||||||
|
movwf DISP0
|
||||||
|
swapf CUENTA, W
|
||||||
|
andlw 0x0f
|
||||||
|
movwf DISP1
|
||||||
|
return
|
||||||
|
|
||||||
|
disp_delay:
|
||||||
|
movlw D'250'
|
||||||
|
movwf R3
|
||||||
|
disp_delay_inner:
|
||||||
|
NOP
|
||||||
|
NOP
|
||||||
|
decfsz R3, F
|
||||||
|
goto disp_delay_inner
|
||||||
|
return
|
||||||
|
|
||||||
|
sevensw:
|
||||||
|
movlw high(sevensw)
|
||||||
|
movwf PCLATH
|
||||||
|
movf TEMP, W
|
||||||
|
addwf TEMP, W
|
||||||
|
addwf PCL, F
|
||||||
|
retlw 3Fh
|
||||||
|
retlw 06h
|
||||||
|
retlw 5Bh
|
||||||
|
retlw 4Fh
|
||||||
|
retlw 66h
|
||||||
|
retlw 6Dh
|
||||||
|
retlw 7Dh
|
||||||
|
retlw 07h
|
||||||
|
retlw 7Fh
|
||||||
|
retlw 6Fh ; A
|
||||||
|
retlw 77h ; B
|
||||||
|
retlw 7Ch ; C
|
||||||
|
retlw 39h ; D
|
||||||
|
retlw 5Eh ; E
|
||||||
|
retlw 71h ; F
|
||||||
|
|
||||||
|
; Delay subroutine (approx 500ms)
|
||||||
|
Delay:
|
||||||
|
MOVLW D'250' ; Outer loop count
|
||||||
|
MOVWF R1
|
||||||
|
Delay_Outer:
|
||||||
|
MOVLW D'250' ; Inner loop count
|
||||||
|
MOVWF R2
|
||||||
|
Delay_Inner:
|
||||||
|
NOP ; Do nothing (No Operation)
|
||||||
|
NOP
|
||||||
|
NOP
|
||||||
|
NOP
|
||||||
|
DECFSZ R2, F ; Decrement inner loop counter
|
||||||
|
GOTO Delay_Inner ; Repeat inner loop
|
||||||
|
;; Multiplex code
|
||||||
|
clrf PORTD
|
||||||
|
movlw 0x04
|
||||||
|
movwf PORTE
|
||||||
|
movff DISP0, TEMP
|
||||||
|
call sevensw
|
||||||
|
movwf PORTD
|
||||||
|
call disp_delay
|
||||||
|
clrf PORTD
|
||||||
|
movlw 0x02
|
||||||
|
movwf PORTE
|
||||||
|
movff DISP1, TEMP
|
||||||
|
call sevensw
|
||||||
|
movwf PORTD
|
||||||
|
|
||||||
|
DECFSZ R1, F ; Decrement outer loop counter
|
||||||
|
GOTO Delay_Outer ; Repeat outer loop
|
||||||
|
RETURN ; Return from delay
|
||||||
|
|
||||||
|
END ; End of program
|
||||||
|
;todopic y aquihayapuntes
|
||||||
BIN
cuenta/main.cod
Executable file
BIN
cuenta/main.cod
Executable file
Binary file not shown.
30
cuenta/main.hex
Normal file
30
cuenta/main.hex
Normal file
|
|
@ -0,0 +1,30 @@
|
||||||
|
:020000040000FA
|
||||||
|
:10000000956A8C6A8A6AF19EFF0E936E0F0EC16E1E
|
||||||
|
:100010008D6A966A060E846E226A8150010AD8B4EF
|
||||||
|
:1000200028EF00F0030AD8B43EEF00F0060AD8B477
|
||||||
|
:1000300035EF00F00C0AD8B44AEF00F0180AD8B433
|
||||||
|
:1000400053EF00F0300AD8B464EF00F00DEF00F089
|
||||||
|
:1000500098EC00F08336D8A028EF00F098EC00F080
|
||||||
|
:100060008332D8A02EEF00F01200800E836E98EC41
|
||||||
|
:1000700000F08332D8A037EF00F0120022481200BF
|
||||||
|
:100080000700226E75EC00F098EC00F098EC00F0A0
|
||||||
|
:100090003EEF00F0AA0E836E98EC00F0550E836ED2
|
||||||
|
:1000A00098EC00F01200180E836E98EC00F0240E0D
|
||||||
|
:1000B000836E98EC00F0420E836E98EC00F0810E97
|
||||||
|
:1000C000836E98EC00F01200810E836E98EC00F0C5
|
||||||
|
:1000D000420E836E98EC00F0240E836E98EC00F0D4
|
||||||
|
:1000E000180E836E98EC00F0120022500F0B306E49
|
||||||
|
:1000F00022380F0B316E1200FA0E246E0000000041
|
||||||
|
:10010000242E7EEF00F01200010EFA6E23502324FD
|
||||||
|
:10011000F9263F0C060C5B0C4F0C660C6D0C7D0C2D
|
||||||
|
:10012000070C7F0C6F0C770C7C0C390C5E0C710C7F
|
||||||
|
:10013000FA0E206EFA0E216E000000000000000092
|
||||||
|
:10014000212E9CEF00F0836A040E846E30C023F0F1
|
||||||
|
:1001500084EC00F0836E7CEC00F0836A020E846E07
|
||||||
|
:1001600031C023F084EC00F0836E202E9AEF00F073
|
||||||
|
:0201700012007B
|
||||||
|
:020000040030CA
|
||||||
|
:04000000000C1F1EB3
|
||||||
|
:02000500038175
|
||||||
|
:060008000FC00FE00F40E5
|
||||||
|
:00000001FF
|
||||||
1345
cuenta/main.lst
Executable file
1345
cuenta/main.lst
Executable file
File diff suppressed because it is too large
Load Diff
25
menu_rota/Makefile
Executable file
25
menu_rota/Makefile
Executable file
|
|
@ -0,0 +1,25 @@
|
||||||
|
# Makefile para pic
|
||||||
|
SRC=*.c
|
||||||
|
|
||||||
|
CC=sdcc
|
||||||
|
FAMILY=pic16
|
||||||
|
PROC=18f4550
|
||||||
|
HEX:=main.hex
|
||||||
|
|
||||||
|
all: $(SRC:.c=.hex)
|
||||||
|
|
||||||
|
comp: $(SRC)
|
||||||
|
$(CC) --use-non-free -m$(FAMILY) -p$(PROC) $^
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -f $(SRC:.c=.asm) $(SRC:.c=.cod) $(SRC:.c=.hex) $(SRC:.c=.lst) $(SRC:.c=.o)
|
||||||
|
|
||||||
|
asm: *.asm
|
||||||
|
gpasm -p 18F4550 -o main.hex $^
|
||||||
|
|
||||||
|
program: ${HEX}
|
||||||
|
pk2cmd -M -PPIC18F4550 -F${HEX}
|
||||||
|
|
||||||
|
asmp: asm program
|
||||||
|
|
||||||
|
.PHONY: all clean
|
||||||
145
menu_rota/main.asm
Executable file
145
menu_rota/main.asm
Executable file
|
|
@ -0,0 +1,145 @@
|
||||||
|
LIST P=18F4550, F=INHX32 ; Specify processor and hex format
|
||||||
|
#include <p18f4550.inc>
|
||||||
|
|
||||||
|
CONFIG FOSC = HS ; Use internal oscillator, RA6 as clock output
|
||||||
|
CONFIG WDT = OFF ; Watchdog Timer off
|
||||||
|
CONFIG LVP = OFF ; Low-Voltage Programming off
|
||||||
|
CONFIG MCLRE = OFF ; MCLR pin disabled, RE3 input enabled
|
||||||
|
CONFIG PBADEN = OFF
|
||||||
|
|
||||||
|
ORG 0x00 ; Program starts at address 0
|
||||||
|
ROTA1 EQU 0x01
|
||||||
|
ROTA2 EQU 0x02
|
||||||
|
ROTA3 EQU 0x04
|
||||||
|
ROTA4 EQU 0x08
|
||||||
|
ROTA5 EQU 0x10
|
||||||
|
ROTA6 EQU 0x20
|
||||||
|
R1 EQU 0x020
|
||||||
|
R2 EQU 0x021
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Start:
|
||||||
|
; Initialize PORTB
|
||||||
|
CLRF TRISD ; Set all PORTB pins as output
|
||||||
|
CLRF LATD ; Clear PORTB outputs
|
||||||
|
|
||||||
|
CLRF LATB
|
||||||
|
BCF INTCON2, 7
|
||||||
|
MOVLW 0xff
|
||||||
|
MOVWF TRISB ; set port b to input
|
||||||
|
movlw 0x0f
|
||||||
|
movwf ADCON1
|
||||||
|
|
||||||
|
MOVLW 0x01
|
||||||
|
MOVWF PORTD
|
||||||
|
|
||||||
|
loop:
|
||||||
|
movf PORTB, W
|
||||||
|
xorlw ROTA1
|
||||||
|
btfsc STATUS, Z
|
||||||
|
goto leftright
|
||||||
|
xorlw ROTA2^ROTA1
|
||||||
|
btfsc STATUS, Z
|
||||||
|
goto right
|
||||||
|
xorlw ROTA2^ROTA3
|
||||||
|
btfsc STATUS, Z
|
||||||
|
goto left
|
||||||
|
xorlw ROTA3^ROTA4
|
||||||
|
btfsc STATUS, Z
|
||||||
|
goto alternate
|
||||||
|
xorlw ROTA4^ROTA5
|
||||||
|
btfsc STATUS, Z
|
||||||
|
goto centerout
|
||||||
|
xorlw ROTA5^ROTA6
|
||||||
|
btfsc STATUS, Z
|
||||||
|
goto outcenter
|
||||||
|
goto loop
|
||||||
|
|
||||||
|
leftright:
|
||||||
|
CALL Delay ; Delay
|
||||||
|
RLCF PORTD, f
|
||||||
|
BTFSS STATUS,0
|
||||||
|
GOTO leftright ; Repeat the loop
|
||||||
|
lright:
|
||||||
|
CALL Delay ; Delay
|
||||||
|
RRCF PORTD, F
|
||||||
|
BTFSS STATUS,0
|
||||||
|
GOTO lright ; Repeat the loop
|
||||||
|
return
|
||||||
|
|
||||||
|
left:
|
||||||
|
MOVLW 0x80
|
||||||
|
MOVWF PORTD
|
||||||
|
rl: CALL Delay ; Delay
|
||||||
|
RRCF PORTD, F
|
||||||
|
BTFSS STATUS,0
|
||||||
|
GOTO rl ; Repeat the loop
|
||||||
|
return
|
||||||
|
|
||||||
|
right:
|
||||||
|
MOVLW 0x01
|
||||||
|
MOVWF PORTD
|
||||||
|
rr: CALL Delay ; Delay
|
||||||
|
RLCF PORTD, F
|
||||||
|
BTFSS STATUS,0
|
||||||
|
GOTO rr ; Repeat the loop
|
||||||
|
return
|
||||||
|
|
||||||
|
alternate:
|
||||||
|
movlw 0xaa
|
||||||
|
movwf PORTD
|
||||||
|
call Delay
|
||||||
|
movlw 0x55
|
||||||
|
movwf PORTD
|
||||||
|
call Delay
|
||||||
|
return
|
||||||
|
|
||||||
|
centerout:
|
||||||
|
movlw 0x18
|
||||||
|
movwf PORTD
|
||||||
|
call Delay
|
||||||
|
movlw 0x24
|
||||||
|
movwf PORTD
|
||||||
|
call Delay
|
||||||
|
movlw 0x42
|
||||||
|
movwf PORTD
|
||||||
|
call Delay
|
||||||
|
movlw 0x81
|
||||||
|
movwf PORTD
|
||||||
|
call Delay
|
||||||
|
return
|
||||||
|
|
||||||
|
outcenter:
|
||||||
|
movlw 0x81
|
||||||
|
movwf PORTD
|
||||||
|
call Delay
|
||||||
|
movlw 0x42
|
||||||
|
movwf PORTD
|
||||||
|
call Delay
|
||||||
|
movlw 0x24
|
||||||
|
movwf PORTD
|
||||||
|
call Delay
|
||||||
|
movlw 0x18
|
||||||
|
movwf PORTD
|
||||||
|
call Delay
|
||||||
|
return
|
||||||
|
|
||||||
|
; Delay subroutine (approx 500ms)
|
||||||
|
Delay:
|
||||||
|
MOVLW D'250' ; Outer loop count
|
||||||
|
MOVWF R1
|
||||||
|
Delay_Outer:
|
||||||
|
MOVLW D'250' ; Inner loop count
|
||||||
|
MOVWF R2
|
||||||
|
Delay_Inner:
|
||||||
|
NOP ; Do nothing (No Operation)
|
||||||
|
NOP
|
||||||
|
DECFSZ R2, F ; Decrement inner loop counter
|
||||||
|
GOTO Delay_Inner ; Repeat inner loop
|
||||||
|
DECFSZ R1, F ; Decrement outer loop counter
|
||||||
|
GOTO Delay_Outer ; Repeat outer loop
|
||||||
|
RETURN ; Return from delay
|
||||||
|
|
||||||
|
END ; End of program
|
||||||
|
;todopic y aquihayapuntes
|
||||||
BIN
menu_rota/main.cod
Executable file
BIN
menu_rota/main.cod
Executable file
Binary file not shown.
22
menu_rota/main.hex
Normal file
22
menu_rota/main.hex
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
:020000040000FA
|
||||||
|
:10000000956A8C6A8A6AF19EFF0E936E0F0EC16E1E
|
||||||
|
:10001000010E836E8150010AD8B425EF00F0030A67
|
||||||
|
:10002000D8B43BEF00F0060AD8B432EF00F00C0A67
|
||||||
|
:10003000D8B444EF00F0180AD8B44DEF00F0300AFD
|
||||||
|
:10004000D8B45EEF00F00AEF00F06FEC00F08336FA
|
||||||
|
:10005000D8A025EF00F06FEC00F08332D8A02BEF92
|
||||||
|
:1000600000F01200800E836E6FEC00F08332D8A097
|
||||||
|
:1000700034EF00F01200010E836E6FEC00F0833657
|
||||||
|
:10008000D8A03DEF00F01200AA0E836E6FEC00F0D6
|
||||||
|
:10009000550E836E6FEC00F01200180E836E6FEC3D
|
||||||
|
:1000A00000F0240E836E6FEC00F0420E836E6FEC56
|
||||||
|
:1000B00000F0810E836E6FEC00F01200810E836EF3
|
||||||
|
:1000C0006FEC00F0420E836E6FEC00F0240E836E36
|
||||||
|
:1000D0006FEC00F0180E836E6FEC00F01200FA0E59
|
||||||
|
:1000E000206EFA0E216E00000000212E73EF00F04A
|
||||||
|
:0800F000202E71EF00F0120058
|
||||||
|
:020000040030CA
|
||||||
|
:04000000000C1F1EB3
|
||||||
|
:02000500018177
|
||||||
|
:060008000FC00FE00F40E5
|
||||||
|
:00000001FF
|
||||||
1236
menu_rota/main.lst
Executable file
1236
menu_rota/main.lst
Executable file
File diff suppressed because it is too large
Load Diff
22
sequence/Makefile
Executable file
22
sequence/Makefile
Executable file
|
|
@ -0,0 +1,22 @@
|
||||||
|
SRC=*.c
|
||||||
|
|
||||||
|
CC=sdcc
|
||||||
|
FAMILY=pic16
|
||||||
|
PROC=18f4550
|
||||||
|
HEX:=main.hex
|
||||||
|
|
||||||
|
all: $(SRC:.c=.hex)
|
||||||
|
|
||||||
|
comp: $(SRC)
|
||||||
|
$(CC) --use-non-free -m$(FAMILY) -p$(PROC) $^
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -f $(SRC:.c=.asm) $(SRC:.c=.cod) $(SRC:.c=.hex) $(SRC:.c=.lst) $(SRC:.c=.o)
|
||||||
|
|
||||||
|
asm: *.asm
|
||||||
|
gpasm -p 18F4550 -o main.hex $^
|
||||||
|
|
||||||
|
program: ${HEX}
|
||||||
|
pk2cmd -M -PPIC18F4550 -F${HEX}
|
||||||
|
|
||||||
|
.PHONY: all clean
|
||||||
48
sequence/main.asm
Executable file
48
sequence/main.asm
Executable file
|
|
@ -0,0 +1,48 @@
|
||||||
|
LIST P=18F4550, F=INHX32 ; Specify processor and hex format
|
||||||
|
#include <p18f4550.inc>
|
||||||
|
|
||||||
|
CONFIG FOSC = INTOSCIO_EC ; Use internal oscillator, RA6 as clock output
|
||||||
|
CONFIG WDT = OFF ; Watchdog Timer off
|
||||||
|
CONFIG LVP = OFF ; Low-Voltage Programming off
|
||||||
|
CONFIG MCLRE = OFF ; MCLR pin disabled, RE3 input enabled
|
||||||
|
R1 EQU 0x020
|
||||||
|
R2 EQU 0x021
|
||||||
|
|
||||||
|
ORG 0x00 ; Program starts at address 0
|
||||||
|
|
||||||
|
Start:
|
||||||
|
; Initialize PORTB
|
||||||
|
CLRF TRISD ; Set all PORTB pins as output
|
||||||
|
CLRF LATD ; Clear PORTB outputs
|
||||||
|
MOVLW 0x01
|
||||||
|
MOVWF PORTD
|
||||||
|
|
||||||
|
left:
|
||||||
|
CALL Delay ; Delay
|
||||||
|
RLCF PORTD, F
|
||||||
|
BTFSS STATUS,0
|
||||||
|
GOTO left ; Repeat the loop
|
||||||
|
right:
|
||||||
|
CALL Delay ; Delay
|
||||||
|
RRCF PORTD, F
|
||||||
|
BTFSS STATUS,0
|
||||||
|
GOTO right ; Repeat the loop
|
||||||
|
GOTO left
|
||||||
|
|
||||||
|
; Delay subroutine (approx 500ms)
|
||||||
|
Delay:
|
||||||
|
MOVLW D'250' ; Outer loop count
|
||||||
|
MOVWF R1
|
||||||
|
Delay_Outer:
|
||||||
|
MOVLW D'250' ; Inner loop count
|
||||||
|
MOVWF R2
|
||||||
|
Delay_Inner:
|
||||||
|
NOP ; Do nothing (No Operation)
|
||||||
|
NOP
|
||||||
|
DECFSZ R2, F ; Decrement inner loop counter
|
||||||
|
GOTO Delay_Inner ; Repeat inner loop
|
||||||
|
DECFSZ R1, F ; Decrement outer loop counter
|
||||||
|
GOTO Delay_Outer ; Repeat outer loop
|
||||||
|
RETURN ; Return from delay
|
||||||
|
|
||||||
|
END ; End of program
|
||||||
BIN
sequence/main.cod
Executable file
BIN
sequence/main.cod
Executable file
Binary file not shown.
10
sequence/main.hex
Executable file
10
sequence/main.hex
Executable file
|
|
@ -0,0 +1,10 @@
|
||||||
|
:020000040000FA
|
||||||
|
:10000000956A8C6A010E836E12EC00F08336D8A0DC
|
||||||
|
:1000100004EF00F012EC00F08332D8A00AEF00F0F9
|
||||||
|
:1000200004EF00F0FA0E206EFA0E216E00000000C0
|
||||||
|
:0E003000212E16EF00F0202E14EF00F012002B
|
||||||
|
:020000040030CA
|
||||||
|
:0400000000081F1EB7
|
||||||
|
:02000500038175
|
||||||
|
:060008000FC00FE00F40E5
|
||||||
|
:00000001FF
|
||||||
1117
sequence/main.lst
Executable file
1117
sequence/main.lst
Executable file
File diff suppressed because it is too large
Load Diff
22
test/Makefile
Executable file
22
test/Makefile
Executable file
|
|
@ -0,0 +1,22 @@
|
||||||
|
SRC=*.c
|
||||||
|
|
||||||
|
CC=sdcc
|
||||||
|
FAMILY=pic16
|
||||||
|
PROC=18f4550
|
||||||
|
HEX:=main.hex
|
||||||
|
|
||||||
|
all: $(SRC:.c=.hex)
|
||||||
|
|
||||||
|
comp: $(SRC)
|
||||||
|
$(CC) --use-non-free -m$(FAMILY) -p$(PROC) $^
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -f $(SRC:.c=.asm) $(SRC:.c=.cod) $(SRC:.c=.hex) $(SRC:.c=.lst) $(SRC:.c=.o)
|
||||||
|
|
||||||
|
asm: *.asm
|
||||||
|
gpasm -p 18F4550 -o main.hex $^
|
||||||
|
|
||||||
|
program: ${HEX}
|
||||||
|
pk2cmd -M -PPIC18F4550 -F${HEX}
|
||||||
|
|
||||||
|
.PHONY: all clean
|
||||||
30
test/main.asm
Executable file
30
test/main.asm
Executable file
|
|
@ -0,0 +1,30 @@
|
||||||
|
; Input output test
|
||||||
|
LIST P=18F4550, F=INHX32 ; Specify processor and hex format
|
||||||
|
#include <p18f4550.inc>
|
||||||
|
|
||||||
|
CONFIG FOSC = HS ; Use internal oscillator, RA6 as clock output
|
||||||
|
CONFIG WDT = OFF ; Watchdog Timer off
|
||||||
|
CONFIG LVP = OFF ; Low-Voltage Programming off
|
||||||
|
;CONFIG MCLRE = OFF ; MCLR pin disabled, RE3 input enabled
|
||||||
|
R1 EQU 0x020
|
||||||
|
R2 EQU 0x021
|
||||||
|
|
||||||
|
ORG 0x00 ; Program starts at address 0
|
||||||
|
|
||||||
|
Start:
|
||||||
|
; Initialize PORTB
|
||||||
|
CLRF TRISD ; Set all PORTB pins as output
|
||||||
|
CLRF LATD ; Clear PORTB outputs
|
||||||
|
|
||||||
|
CLRF LATB
|
||||||
|
BCF INTCON2, 7
|
||||||
|
movlw 0fh ; Set all pins to digital I/0
|
||||||
|
movwf ADCON1
|
||||||
|
MOVLW 0xFF
|
||||||
|
MOVWF TRISB
|
||||||
|
|
||||||
|
loop:
|
||||||
|
movff PORTB, PORTD
|
||||||
|
goto loop
|
||||||
|
|
||||||
|
END ; End of program
|
||||||
BIN
test/main.cod
Normal file
BIN
test/main.cod
Normal file
Binary file not shown.
8
test/main.hex
Normal file
8
test/main.hex
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
:020000040000FA
|
||||||
|
:10000000956A8C6A8A6AF19E0F0EC16EFF0E936E1E
|
||||||
|
:0800100081CF83FF08EF00F02F
|
||||||
|
:020000040030CA
|
||||||
|
:04000000000C1F1EB3
|
||||||
|
:020005008381F5
|
||||||
|
:060008000FC00FE00F40E5
|
||||||
|
:00000001FF
|
||||||
1089
test/main.lst
Normal file
1089
test/main.lst
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user