cleaned repo

This commit is contained in:
Fernando 2025-02-27 08:50:19 -06:00
parent 96bee98513
commit f4fdcb11c1
20 changed files with 216 additions and 5949 deletions

View File

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

7
README.md Normal file
View File

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

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@ -76,13 +76,13 @@ loop:
goto des ; cuenta 3 wip goto des ; cuenta 3 wip
xorlw ROTA3^ROTA4 xorlw ROTA3^ROTA4
btfsc STATUS, Z btfsc STATUS, Z
goto alternate goto hexAsc
xorlw ROTA4^ROTA5 xorlw ROTA4^ROTA5
btfsc STATUS, Z btfsc STATUS, Z
goto centerout goto bcdt
xorlw ROTA5^ROTA6 xorlw ROTA5^ROTA6
btfsc STATUS, Z btfsc STATUS, Z
goto outcenter goto hext
goto loop goto loop
hexa: hexa:
@ -122,29 +122,50 @@ decimal:
Call Delay Call Delay
goto decimal goto decimal
alternate: hexAsc:
movlw 0xff movlw 0xff
movwf CUENTA movwf CUENTA
call splitDigit
call Delay
rl2: rl2:
call splitDigit call splitDigit
call Delay call Delay
decfsz CUENTA decfsz CUENTA
goto rl2 goto rl2
goto alternate goto hexAsc
centerout: ;; clock bcdt: ;; count to a thousand
return clrf CUENTA
clrf CUENTA2
outcenter: co:
call splitDigit call splitDigit
call Delay call Delay
incf CUENTA, W incf CUENTA, W
daw daw
movwf CUENTA movwf CUENTA
Call Delay btfss STATUS, C
goto decimal goto co
incf CUENTA2, W
daw
movwf CUENTA2
btfss STATUS, C
goto co
return
hext:
clrf CUENTA
clrf CUENTA2
ht:
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
return
splitDigit: splitDigit:
movf CUENTA, W movf CUENTA, W

Binary file not shown.

View File

@ -1,30 +1,39 @@
:020000040000FA :020000040000FA
:10000000956A8C6A8A6AF19EFF0E936E0F0EC16E1E :0400000006EF00F017
:100010008D6A966A060E846E226A8150010AD8B4EF :0800080018EF00F0956A8C6A04
:1000200028EF00F0030AD8B43EEF00F0060AD8B477 :100010008A6AF19EFF0E936E0F0EC16E896A926A14
:1000300035EF00F00C0AD8B44AEF00F0180AD8B433 :10002000D08EF280F28CF28EF1808D6A966A346AFC
:1000400053EF00F0300AD8B464EF00F00DEF00F089 :100030008150F290226A94EC00F0C3EC00F0815001
:1000500098EC00F08336D8A028EF00F098EC00F080 :10004000010AD8B43AEF00F0030AD8B459EF00F02F
:100060008332D8A02EEF00F01200800E836E98EC41 :10005000060AD8B443EF00F00C0AD8B464EF00F0FD
:1000700000F08332D8A037EF00F0120022481200BF :10006000180AD8B46FEF00F0300AD8B482EF00F06D
:100080000700226E75EC00F098EC00F098EC00F0A0 :1000700018EF00F094EC00F0C3EC00F0222AC3EC7F
:100090003EEF00F0AA0E836E98EC00F0550E836ED2 :1000800000F03AEF00F0226A346A94EC00F0C3EC1E
:1000A00098EC00F01200180E836E98EC00F0240E0D :1000900000F022280700226E600AD8A445EF00F085
:1000B000836E98EC00F0420E836E98EC00F0810E97 :1000A000226A34280700346E600AD8B4120045EF83
:1000C000836E98EC00F01200810E836E98EC00F0C5 :1000B00000F094EC00F0C3EC00F022280700226E60
:1000D000420E836E98EC00F0240E836E98EC00F0D4 :1000C000C3EC00F059EF00F0FF0E226E94EC00F04C
:1000E000180E836E98EC00F0120022500F0B306E49 :1000D000C3EC00F0222E66EF00F064EF00F0226A1D
:1000F00022380F0B316E1200FA0E246E0000000041 :1000E000346A94EC00F0C3EC00F022280700226E82
:10010000242E7EEF00F01200010EFA6E23502324FD :1000F000D8A071EF00F034280700346ED8A071EF5B
:10011000F9263F0C060C5B0C4F0C660C6D0C7D0C2D :1001000000F01200226A346A94EC00F0C3EC00F0B4
:10012000070C7F0C6F0C770C7C0C390C5E0C710C7F :100110002228226ED8A484EF00F0226A3428346E9C
:10013000FA0E206EFA0E216E000000000000000092 :10012000D8A484EF00F0120022500F0B306E22385A
:10014000212E9CEF00F0836A040E846E30C023F0F1 :100130000F0B316E34500F0B326E34380F0B336EA1
:1001500084EC00F0836E7CEC00F0836A020E846E07 :100140001200FA0E246E0000000000000000242EB1
:1001600031C023F084EC00F0836E202E9AEF00F073 :10015000A3EF00F01200010EFA6E23502324660F65
:0201700012007B :10016000D8B0FA2AF96E3F0C060C5B0C4F0C660CEB
:100170006D0C7D0C070C7F0C6F0C770C7C0C390C14
:100180005E0C790C710CFA0E206EFA0E216E0000D6
:100190000000212EC7EF00F0D2EC00F0202EC5EFBA
:1001A00000F01200836A30C023F0ABEC00F0836EE5
:1001B000040E846EA1EC00F0836A31C023F0ABEC36
:1001C00000F0836E020E846EA1EC00F0836A32C0F0
:1001D00023F0ABEC00F0836E010E846EA1EC00F016
:1001E000836A846A33C023F0ABEC00F0836E100E98
:0A01F000806EA1EC00F0806A12009E
:020000040030CA :020000040030CA
:04000000000C1F1EB3 :04000000000C1F1EB3
:02000500038175 :020005008381F5
:060008000FC00FE00F40E5 :060008000FC00FE00F40E5
:00000001FF :00000001FF

File diff suppressed because it is too large Load Diff

32
interrupt/Makefile Executable file
View 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} -Fmain.hex
asm: *.asm
gpasm -p ${ASMPROC} -o main.hex $^
asmp: asm program
.PHONY: all clean

64
interrupt/main.asm Normal file
View File

@ -0,0 +1,64 @@
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
RETFIE ; Return from interrupt
END

12
interrupt/main.hex Normal file
View File

@ -0,0 +1,12 @@
:020000040000FA
:0400000006EF00F017
:0800080019EF00F0FF0E936EEA
:10001000956A8C6A0F0EC16EF19EF180F286F28EA7
:10002000F28CF288F18CF286F18A81CF83FF15EF92
:1000300000F0F2A01000815000000000000000005D
:0A00400081CF83FFF290F2921000CE
:020000040030CA
:04000000000C1F1EB3
:020005008381F5
:060008000FC00FE00F40E5
:00000001FF

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@ -1,9 +1,17 @@
SRC=*.c # 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 CC=sdcc
FAMILY=pic16 FAMILY=pic16
PROC=18f4550 PROC=18f4550
HEX:=main.hex
# ASM and program variables
PPROC=PIC18F4550
ASMPROC=18F4550
all: $(SRC:.c=.hex) all: $(SRC:.c=.hex)
@ -13,10 +21,12 @@ comp: $(SRC)
clean: clean:
rm -f $(SRC:.c=.asm) $(SRC:.c=.cod) $(SRC:.c=.hex) $(SRC:.c=.lst) $(SRC:.c=.o) rm -f $(SRC:.c=.asm) $(SRC:.c=.cod) $(SRC:.c=.hex) $(SRC:.c=.lst) $(SRC:.c=.o)
asm: *.asm program:
gpasm -p 18F4550 -o main.hex $^ pk2cmd -M -P${PPROC} -Fmain.hex
program: ${HEX} asm: *.asm
pk2cmd -M -PPIC18F4550 -F${HEX} gpasm -p ${ASMPROC} -o main.hex $^
asmp: asm program
.PHONY: all clean .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 FOSC = HS ; Use internal oscillator, RA6 as clock output
CONFIG WDT = OFF ; Watchdog Timer off CONFIG WDT = OFF ; Watchdog Timer off
CONFIG LVP = OFF ; Low-Voltage Programming 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 R1 EQU 0x020
R2 EQU 0x021 R2 EQU 0x021
@ -24,7 +24,18 @@ Start:
MOVWF TRISB MOVWF TRISB
loop: loop:
movff PORTB, PORTD movlw 0xff
addwf PORTB
btfsc STATUS, 0
goto on
goto off
on:
movlw 0x01
movwf PORTD
goto loop
off:
movlw 0x00
movwf PORTD
goto loop goto loop
END ; End of program END ; End of program

Binary file not shown.

View File

@ -1,8 +1,9 @@
:020000040000FA :020000040000FA
:10000000956A8C6A8A6AF19E0F0EC16EFF0E936E1E :10000000956A8C6A8A6AF19E0F0EC16EFF0E936E1E
:0800100081CF83FF08EF00F02F :10001000FF0E8126D8B00FEF00F013EF00F0010EB5
:0E002000836E08EF00F0000E836E08EF00F014
:020000040030CA :020000040030CA
:04000000000C1F1EB3 :04000000000C1F1EB3
:020005008381F5 :02000500038175
:060008000FC00FE00F40E5 :060008000FC00FE00F40E5
:00000001FF :00000001FF

File diff suppressed because it is too large Load Diff