Compare commits

..

No commits in common. "47d91da1fa7b655f11fcd2b01a5cca3b0123df78" and "52495bbfbaf3b5ad6df89bb335dd750711763aac" have entirely different histories.

24 changed files with 6045 additions and 338 deletions

2
.gitignore vendored
View File

@ -1,2 +0,0 @@
*.lst
*.cod

View File

@ -22,7 +22,7 @@ clean:
rm -f $(SRC:.c=.asm) $(SRC:.c=.cod) $(SRC:.c=.hex) $(SRC:.c=.lst) $(SRC:.c=.o)
program:
pk2cmd -M -P${PPROC} -Fmain.hex
pk2cmd -M -P${PPROC} -Fout.hex
asm: *.asm
gpasm -p ${ASMPROC} -o main.hex $^

View File

@ -1,7 +0,0 @@
# Pic GPASM examples
Pic development on linux
## Dependencies
- gputils
- SDCC (Small Device C Compiler) optional for C development
- pk2cmd for pickit programmers

View File

@ -22,7 +22,7 @@ clean:
rm -f $(SRC:.c=.asm) $(SRC:.c=.cod) $(SRC:.c=.hex) $(SRC:.c=.lst) $(SRC:.c=.o)
program:
pk2cmd -M -P${PPROC} -Fmain.hex
pk2cmd -M -P${PPROC} -Fout.hex
asm: *.asm
gpasm -p ${ASMPROC} -o main.hex $^

BIN
blink/main.cod Normal file

Binary file not shown.

0
blink/main.hex Executable file → Normal file
View File

1113
blink/main.lst Normal file

File diff suppressed because it is too large Load Diff

View File

@ -4,10 +4,10 @@ LIST P=18F4550, F=INHX32 ; Specify processor and hex format
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 = ON ; MCLR pin disabled, RE3 input enabled
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
@ -18,18 +18,13 @@ R1 EQU 0x020
R2 EQU 0x021
R3 EQU 0x024
CUENTA EQU 0x022
CUENTA2 EQU 0x034
TEMP EQU 0x23
DISP0 EQU 0x30
DISP1 EQU 0x31
DISP2 EQU 0x32
DISP3 EQU 0x33
ORG 0x0000
goto Start
ORG 0x0008
goto loop
Start:
; Initialize PORTB
@ -37,134 +32,119 @@ Start:
CLRF LATD ; Clear PORTB outputs
CLRF LATB
BCF INTCON2, RBPU
BCF INTCON2, 7
MOVLW 0xff
MOVWF TRISB ; set port b to input
movlw 0x0f
movwf ADCON1
clrf LATA
clrf TRISA
bsf RCON, IPEN ; enable priority modes
bsf INTCON, RBIF ; RB Port change interrupt
bsf INTCON, PEIE ; enable peripheral interrupts
bsf INTCON, GIE ; enable global interrupts
bsf INTCON2, RBIP ; rb to high priority
clrf LATE
clrf TRISE
clrf CUENTA2
movlw 0x06
movwf PORTE
clrf CUENTA
loop:
movf PORTB, W
bcf INTCON, RBIF
clrf CUENTA
call splitDigit
call Delay
;movlw 0x17
;movwf CUENTA
;call Delay
;call sevensw
;movwf PORTD
;goto loop
movf PORTB, W
xorlw ROTA1
btfsc STATUS, Z
goto hexa ; cuenta 1
goto leftright
xorlw ROTA2^ROTA1
btfsc STATUS, Z
goto decimal ; cuenta 2
goto right
xorlw ROTA2^ROTA3
btfsc STATUS, Z
goto des ; cuenta 3 wip
goto left
xorlw ROTA3^ROTA4
btfsc STATUS, Z
goto hexAsc
goto alternate
xorlw ROTA4^ROTA5
btfsc STATUS, Z
goto bcdt
goto centerout
xorlw ROTA5^ROTA6
btfsc STATUS, Z
goto hext
goto outcenter
goto loop
hexa:
call splitDigit
call Delay
incf CUENTA, F
call Delay
goto hexa
des:
clrf CUENTA
clrf CUENTA2
rl:
call splitDigit
call Delay
incf CUENTA, W
daw
movwf CUENTA
xorlw 0x60
btfss STATUS, Z
goto rl
clrf CUENTA
incf CUENTA2, W
daw
movwf CUENTA2
xorlw 0x60
btfsc STATUS, Z
return
goto rl
decimal:
call splitDigit
call Delay
incf CUENTA, W
daw
movwf CUENTA
Call Delay
goto decimal
hexAsc:
movlw 0xff
movwf CUENTA
rl2:
call splitDigit
call Delay
decfsz CUENTA
goto rl2
goto hexAsc
bcdt: ;; count to a thousand
clrf CUENTA
clrf CUENTA2
co:
call splitDigit
call Delay
incf CUENTA, W
daw
movwf CUENTA
btfss STATUS, C
goto co
incf CUENTA2, W
daw
movwf CUENTA2
btfss STATUS, C
goto co
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
hext:
clrf CUENTA
clrf CUENTA2
ht:
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
incf CUENTA, W
movwf CUENTA
btfss STATUS, Z
goto ht
clrf CUENTA
incf CUENTA2, W
movwf CUENTA2
btfss STATUS, Z
goto ht
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:
@ -174,20 +154,12 @@ splitDigit:
swapf CUENTA, W
andlw 0x0f
movwf DISP1
movf CUENTA2, W
andlw 0x0f
movwf DISP2
swapf CUENTA2, W
andlw 0x0f
movwf DISP3
return
disp_delay:
movlw D'250'
movwf R3
disp_delay_inner:
NOP
NOP
NOP
NOP
decfsz R3, F
@ -195,15 +167,11 @@ disp_delay_inner:
return
sevensw:
movlw high(sevenjmp)
movlw high(sevensw)
movwf PCLATH
movf TEMP, W
addwf TEMP, W
addlw low(sevenjmp)
btfsc STATUS, 0
incf PCLATH, 1
movwf PCL
sevenjmp:
addwf PCL, F
retlw 3Fh
retlw 06h
retlw 5Bh
@ -211,17 +179,15 @@ sevenjmp:
retlw 66h
retlw 6Dh
retlw 7Dh
retlw 07h ; siete
retlw 7Fh ; ocho
retlw 6Fh ; nueve
retlw 77h ; A
retlw 7Ch ; B
retlw 39h ; C
retlw 5Eh ; D
retlw 79h ; E
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
@ -232,50 +198,28 @@ Delay_Outer:
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
call display
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
display:
clrf PORTD
movff DISP0, TEMP
call sevensw
movwf PORTD
movlw 0x04
movwf PORTE
call disp_delay
clrf PORTD
movff DISP1, TEMP
call sevensw
movwf PORTD
movlw 0x02
movwf PORTE
call disp_delay
clrf PORTD
movff DISP2, TEMP
call sevensw
movwf PORTD
movlw 0x01
movwf PORTE
call disp_delay
clrf PORTD
clrf PORTE
movff DISP3, TEMP
call sevensw
movwf PORTD
movlw 0x10
movwf PORTA
call disp_delay
clrf PORTA
return
END ; End of program
;todopic y aquihayapuntes

BIN
cuenta/main.cod Executable file

Binary file not shown.

59
cuenta/main.hex Executable file → Normal file
View File

@ -1,39 +1,30 @@
:020000040000FA
:0400000006EF00F017
:0800080018EF00F0956A8C6A04
:100010008A6AF19EFF0E936E0F0EC16E896A926A14
:10002000D08EF280F28CF28EF1808D6A966A346AFC
:100030008150F290226A94EC00F0C3EC00F0815001
:10004000010AD8B43AEF00F0030AD8B459EF00F02F
:10005000060AD8B443EF00F00C0AD8B464EF00F0FD
:10006000180AD8B46FEF00F0300AD8B482EF00F06D
:1000700018EF00F094EC00F0C3EC00F0222AC3EC7F
:1000800000F03AEF00F0226A346A94EC00F0C3EC1E
:1000900000F022280700226E600AD8A445EF00F085
:1000A000226A34280700346E600AD8B4120045EF83
:1000B00000F094EC00F0C3EC00F022280700226E60
:1000C000C3EC00F059EF00F0FF0E226E94EC00F04C
:1000D000C3EC00F0222E66EF00F064EF00F0226A1D
:1000E000346A94EC00F0C3EC00F022280700226E82
:1000F000D8A071EF00F034280700346ED8A071EF5B
:1001000000F01200226A346A94EC00F0C3EC00F0B4
:100110002228226ED8A484EF00F0226A3428346E9C
:10012000D8A484EF00F0120022500F0B306E22385A
:100130000F0B316E34500F0B326E34380F0B336EA1
:100140001200FA0E246E0000000000000000242EB1
:10015000A3EF00F01200010EFA6E23502324660F65
:10016000D8B0FA2AF96E3F0C060C5B0C4F0C660CEB
:100170006D0C7D0C070C7F0C6F0C770C7C0C390C14
:100180005E0C790C710CFA0E206EFA0E216E0000D6
:100190000000212EC7EF00F0D2EC00F0202EC5EFBA
:1001A00000F01200836A30C023F0ABEC00F0836EE5
:1001B000040E846EA1EC00F0836A31C023F0ABEC36
:1001C00000F0836E020E846EA1EC00F0836A32C0F0
:1001D00023F0ABEC00F0836E010E846EA1EC00F016
:1001E000836A846A33C023F0ABEC00F0836E100E98
:0A01F000806EA1EC00F0806A12009E
: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
:020005008381F5
:02000500038175
:060008000FC00FE00F40E5
:00000001FF

1345
cuenta/main.lst Executable file

File diff suppressed because it is too large Load Diff

View File

@ -1,32 +0,0 @@
# 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} -Fmain.hex
asm: *.asm
gpasm -p ${ASMPROC} -o main.hex $^
asmp: asm program
.PHONY: all clean

View File

@ -1,65 +0,0 @@
LIST P=18F4550
#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 = ON ; MCLR pin disabled, RE3 input enabled
ORG 0x00
GOTO INIT
ORG 0x08 ; Interrupt vector for high-priority interrupts
GOTO ISR ; Jump to Interrupt Service Routine
INIT:
; === Configure RB4-RB7 as Input ===
movlw 0xff
movwf TRISB
clrf TRISD
clrf LATD
movlw 0x0f
movwf ADCON1
; === Enable RB Port Change Interrupt ===
BCF INTCON2, RBPU ; Enable PORTB pull-ups
BSF INTCON2, 0 ; Set interrupt on high priority RBIP
BSF INTCON, RBIE ; Enable RB Port Change Interrupt
BSF INTCON, GIE ; Enable Global Interrupts
BSF INTCON, PEIE ; Enable Peripheral Interrupts
;BSF INTCON2, 6
; INT0
BSF INTCON, INT0IE
BSF INTCON2, INTEDG0
BSF INTCON, INT1IE
BSF INTCON2, INTEDG1
MAIN_LOOP:
;MOVFF PORTB, PORTD
GOTO MAIN_LOOP ; Stay in loop, wait for interrupts
; === Interrupt Service Routine ===
ISR:
;BTFSS INTCON, RBIF ; Check if RB Change interrupt occurred
;RETFIE ; Return if not triggered
;BTFSS INTCON, INT0IF
;RETFIE
MOVF PORTB, W ; Read PORTB (necessary to clear mismatch condition)
NOP
NOP
NOP
NOP
; === Your Custom Interrupt Handling Code ===
; Example: Toggle PORTD on RB change
;BTG PORTD, 0
MOVFF PORTB, PORTD
BCF INTCON, RBIF ; Clear the RBIF flag
BCF INTCON, INT0IF
BCF INTCON, INT1IF
RETFIE ; Return from interrupt
END

View File

@ -1,12 +0,0 @@
:020000040000FA
:0400000006EF00F017
:0800080017EF00F0FF0E936EEC
:10001000956A8C6A0F0EC16EF19EF180F286F28EA7
:10002000F28CF288F18CF286F18A15EF00F08150A3
:10003000000000000000000081CF83FFF290F292E8
:04004000F29010002A
:020000040030CA
:04000000000C1F1EB3
:020005008381F5
:060008000FC00FE00F40E5
:00000001FF

BIN
menu_rota/main.cod Executable file

Binary file not shown.

0
menu_rota/main.hex Executable file → Normal file
View File

1236
menu_rota/main.lst Executable file

File diff suppressed because it is too large Load Diff

BIN
sequence/main.cod Executable file

Binary file not shown.

1117
sequence/main.lst Executable file

File diff suppressed because it is too large Load Diff

View File

@ -1,17 +1,9 @@
# 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
HEX:=main.hex
all: $(SRC:.c=.hex)
@ -21,12 +13,10 @@ comp: $(SRC)
clean:
rm -f $(SRC:.c=.asm) $(SRC:.c=.cod) $(SRC:.c=.hex) $(SRC:.c=.lst) $(SRC:.c=.o)
program:
pk2cmd -M -P${PPROC} -Fmain.hex
asm: *.asm
gpasm -p ${ASMPROC} -o main.hex $^
gpasm -p 18F4550 -o main.hex $^
asmp: asm program
program: ${HEX}
pk2cmd -M -PPIC18F4550 -F${HEX}
.PHONY: all clean

View File

@ -5,7 +5,7 @@ LIST P=18F4550, F=INHX32 ; Specify processor and hex format
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 MCLRE = OFF ; MCLR pin disabled, RE3 input enabled
R1 EQU 0x020
R2 EQU 0x021
@ -26,5 +26,5 @@ Start:
loop:
movff PORTB, PORTD
goto loop
END ; End of program

BIN
test/main.cod Normal file

Binary file not shown.

2
test/main.hex Executable file → Normal file
View File

@ -3,6 +3,6 @@
:0800100081CF83FF08EF00F02F
:020000040030CA
:04000000000C1F1EB3
:02000500038175
:020005008381F5
:060008000FC00FE00F40E5
:00000001FF

1089
test/main.lst Normal file

File diff suppressed because it is too large Load Diff