Good Day,
I am studying digital systems using Pic Trix by Pat Ellis. We need to use MPLABX to write and simulate our projects which need to be .asm files, but I am struggling to get any type coding running in the MPLabX environment. I found these examples Mplab examples for the p16F1829 but they just give errors when I try to build them.
I am hoping someone could give me advice on how to tackle figuring this out or recommend a good tutorial or something.
CODE BLINKING LED
#include <p16F1829.inc>
__CONFIG _CONFIG1, (_FOSC_INTOSC & _WDTE_OFF & _PWRTE_OFF & _MCLRE_OFF & _CP_OFF & _CPD_OFF & _BOREN_ON & _CLKOUTEN_OFF & _IESO_OFF & _FCMEN_OFF);
__CONFIG _CONFIG2, (_WRT_OFF & _PLLEN_OFF & _STVREN_OFF & _LVP_OFF);
errorlevel -302 ;supress the 'not in bank0' warning
cblock 0x70 ;shared memory location that is accessible from all banks
Delay1 ;Define two file registers for the delay loop in shared memory
Delay2
endc
; -------------------LATC-----------------
; Bit#: -7---6---5---4---3---2---1---0---
; LED: ---------------|DS4|DS3|DS2|DS1|-
; -----------------------------------------
ORG 0
Start:
banksel OSCCON ;bank1
movlw b'00111000' ;set cpu clock speed of 500KHz ->correlates to (1/(500K/4)) for each instruction
movwf OSCCON ;move contents of the working register into OSCCON
bcf TRISC,0 ;make IO Pin C0 an output for DS1
banksel LATC ;bank2
clrf LATC ;start by turning off all of the LEDs
MainLoop:
bsf LATC, 0 ;turn on DS1
OndelayLoop:
decfsz Delay1,f ;Waste time.
bra OndelayLoop ;The Inner loop takes 3 instructions per loop * 256 loops = 768 instructions
decfsz Delay2,f ;The outer loop takes an additional 3 instructions per lap * 256 loops
bra OndelayLoop ;(768+3) * 256 = 197376 instructions / 125K instructions per second = 1.579 sec.
bcf LATC,0 ;Turn off LED C0 - NOTE: do not need to switch banks with 'banksel' since bank2 is still selected
OffDelayLoop:
decfsz Delay1,f ;same delay as above
bra OffDelayLoop
decfsz Delay2,f
bra OffDelayLoop
bra MainLoop ;Do it again...
end
ERROR
make -f nbproject/Makefile-default.mk SUBPROJECTS= .build-conf
make[2]: *** No rule to make target 'build/default/production/newfile.o', needed by 'dist/default/production/Test.X.production.hex'. Stop.
make[1]: Entering directory 'C:/Users/MisterFisk/MPLABXProjects/Test.X'
make[1]: *** [.build-conf] Error 2
make -f nbproject/Makefile-default.mk dist/default/production/Test.X.production.hex
make: *** [.build-impl] Error 2
make[2]: Entering directory 'C:/Users/MisterFisk/MPLABXProjects/Test.X'
make[2]: Leaving directory 'C:/Users/MisterFisk/MPLABXProjects/Test.X'
nbproject/Makefile-default.mk:91: recipe for target '.build-conf' failed
make[1]: Leaving directory 'C:/Users/MisterFisk/MPLABXProjects/Test.X'
nbproject/Makefile-impl.mk:39: recipe for target '.build-impl' failed
BUILD FAILED (exit value 2, total time: 105ms)
I am studying digital systems using Pic Trix by Pat Ellis. We need to use MPLABX to write and simulate our projects which need to be .asm files, but I am struggling to get any type coding running in the MPLabX environment. I found these examples Mplab examples for the p16F1829 but they just give errors when I try to build them.
I am hoping someone could give me advice on how to tackle figuring this out or recommend a good tutorial or something.
CODE BLINKING LED
#include <p16F1829.inc>
__CONFIG _CONFIG1, (_FOSC_INTOSC & _WDTE_OFF & _PWRTE_OFF & _MCLRE_OFF & _CP_OFF & _CPD_OFF & _BOREN_ON & _CLKOUTEN_OFF & _IESO_OFF & _FCMEN_OFF);
__CONFIG _CONFIG2, (_WRT_OFF & _PLLEN_OFF & _STVREN_OFF & _LVP_OFF);
errorlevel -302 ;supress the 'not in bank0' warning
cblock 0x70 ;shared memory location that is accessible from all banks
Delay1 ;Define two file registers for the delay loop in shared memory
Delay2
endc
; -------------------LATC-----------------
; Bit#: -7---6---5---4---3---2---1---0---
; LED: ---------------|DS4|DS3|DS2|DS1|-
; -----------------------------------------
ORG 0
Start:
banksel OSCCON ;bank1
movlw b'00111000' ;set cpu clock speed of 500KHz ->correlates to (1/(500K/4)) for each instruction
movwf OSCCON ;move contents of the working register into OSCCON
bcf TRISC,0 ;make IO Pin C0 an output for DS1
banksel LATC ;bank2
clrf LATC ;start by turning off all of the LEDs
MainLoop:
bsf LATC, 0 ;turn on DS1
OndelayLoop:
decfsz Delay1,f ;Waste time.
bra OndelayLoop ;The Inner loop takes 3 instructions per loop * 256 loops = 768 instructions
decfsz Delay2,f ;The outer loop takes an additional 3 instructions per lap * 256 loops
bra OndelayLoop ;(768+3) * 256 = 197376 instructions / 125K instructions per second = 1.579 sec.
bcf LATC,0 ;Turn off LED C0 - NOTE: do not need to switch banks with 'banksel' since bank2 is still selected
OffDelayLoop:
decfsz Delay1,f ;same delay as above
bra OffDelayLoop
decfsz Delay2,f
bra OffDelayLoop
bra MainLoop ;Do it again...
end
ERROR
make -f nbproject/Makefile-default.mk SUBPROJECTS= .build-conf
make[2]: *** No rule to make target 'build/default/production/newfile.o', needed by 'dist/default/production/Test.X.production.hex'. Stop.
make[1]: Entering directory 'C:/Users/MisterFisk/MPLABXProjects/Test.X'
make[1]: *** [.build-conf] Error 2
make -f nbproject/Makefile-default.mk dist/default/production/Test.X.production.hex
make: *** [.build-impl] Error 2
make[2]: Entering directory 'C:/Users/MisterFisk/MPLABXProjects/Test.X'
make[2]: Leaving directory 'C:/Users/MisterFisk/MPLABXProjects/Test.X'
nbproject/Makefile-default.mk:91: recipe for target '.build-conf' failed
make[1]: Leaving directory 'C:/Users/MisterFisk/MPLABXProjects/Test.X'
nbproject/Makefile-impl.mk:39: recipe for target '.build-impl' failed
BUILD FAILED (exit value 2, total time: 105ms)