error code in my programming - Page 1
Forum section: electronics / beginners

author: Olivares1838112
author_rank: Newbie
timestamp: May 07, 2020, 09:58:53 pm
content: Hello,I need help to make a Proteus simulation of a 16 LED shift, but it won't let me build the programming. Shows me errors in code.I'm using the PIC 18F4550first time using this program and using the PICCode:LIST P=18F4550INCLUDE <PIC18F4550.INC>;************************************************************CONFIG FOSC = HSCONFIG PWRT = ONCONFIG BOR = OFFCONFIG WDT = OFFCONFIG MCLRE = ONCONFIG PBADEN = OFFCONFIG LVP = OFFCONFIG DEBUG = OFFCONFIG XINST = OFF; CODE ******************************************************#define Conta 0x12cblockConta1Conta2Conta3Sweependc#define Time1 0x00#define Time2 0x85#define Time3 0x02ORG 0x00INICIOclrt PORTBclrt PORTCclrt PORTDclrt TRISAmovlw 0x01movwf TRISBmovwf TRISCmovwf TRISDbtfss PORTA, 0goto INICIOmovlw B'00000001'movwf SweepMOVERIGTHcall Retardorrncf Sweep, Fmovff Sweep, PORTBbtfss PORTA, 0braMOVERIGTHbraMOVELEFTMOVELEFTHcall Retardorlncf Sweep, Fmovff Sweep, PORTBbtfss PORTA, 0; btfsc PORTA, 0braMOVELEFTbraMOVERIGTHRetardomovlw Time1movwf Conta1movlw Time2movwf Conta2movlw Time3movwf Conta3Repeatdecfsz Conta1, FbraRepeatmovlw Time1movwf Conta1decfsz Conta2, FbraRepeatdecfsz Conta3braRepeatReturnENDCode:make -f nbproject/Makefile-default.mk SUBPROJECTS= .build-confmake: Entering directory 'C:/Users/guill/OneDrive/Documents/DIG_3/led_shift/Auto.X'make -f nbproject/Makefile-default.mk dist/default/production/Auto.X.production.hexmake: Entering directory 'C:/Users/guill/OneDrive/Documents/DIG_3/led_shift/Auto.X'"C:\Program Files\Microchip\xc8\v2.20\bin\xc8-cc.exe" -c -mcpu=18F4550 -mdfp="C:/Program Files (x86)/Microchip/MPLABX/v5.35/packs/Microchip/PIC18Fxxxx_DFP/1.2.26"/xc8 -fno-short-double -fno-short-float -memi=wordwrite -O0 -fasmfile -maddrqual=ignore -xassembler-with-cpp -mwarn=-3 -Wa,-a -DXPRJ_default=default -msummary=-psect,-class,+mem,-hex,-file -ginhx032 -Wl,--data-init -mno-keep-startup -mno-download -mdefault-config-bits -std=c99 -gdwarf-3 -mstack=compiled:auto:auto:auto -o build/default/production/Auto.o Auto.asmAuto.asm:1:: error: (223) digit out of rangeAuto.asm:1:: error: (876) syntax errorAuto.asm:2:: error: (844) lexical errorAuto.asm:16:: error: (876) syntax errorAuto.asm:29:: warning: (1522) RAM access bit operand not specified, assuming banked memoryAuto.asm:30:: warning: (1522) RAM access bit operand not specified, assuming banked memoryAuto.asm:31:: warning: (1522) RAM access bit operand not specified, assuming banked memoryAuto.asm:32:: warning: (1522) RAM access bit operand not specified, assuming banked memoryAuto.asm:34:: warning: (1522) RAM access bit operand not specified, assuming banked memoryAuto.asm:36:: warning: (1522) RAM access bit operand not specified, assuming banked memoryAuto.asm:38:: error: (876) syntax errorAuto.asm:40:: warning: (1522) RAM access bit operand not specified, assuming banked memoryAuto.asm:42:: warning: (1522) RAM access bit operand not specified, assuming banked memoryAuto.asm:49:: error: (876) syntax errorAuto.asm:51:: warning: (1522) RAM access bit operand not specified, assuming banked memoryAuto.asm:53:: warning: (1522) RAM access bit operand not specified, assuming banked memoryAuto.asm:55:: warning: (1522) RAM access bit operand not specified, assuming banked memoryAuto.asm:56:: error: (876) syntax errorAuto.asm:57:: warning: (1522) RAM access bit operand not specified, assuming banked memoryAuto.asm:61:: warning: (1522) RAM access bit operand not specified, assuming banked memoryAuto.asm:62:: warning: (1522) RAM access bit operand not specified, assuming banked memoryAuto.asm:65:: warning: (1522) RAM access bit operand not specified, assuming banked memory:69:: warning: (1311) missing configuration setting for config word 0x300000; using default:69:: warning: (1311) missing configuration setting for config word 0x300008; using default:69:: warning: (1311) missing configuration setting for config word 0x300009; using default:69:: warning: (1311) missing configuration setting for config word 0x30000A; using default:69:: warning: (1311) missing configuration setting for config word 0x30000B; using default:69:: warning: (1311) missing configuration setting for config word 0x30000C; using default:69:: warning: (1311) missing configuration setting for config word 0x30000D; using defaultAuto.asm:29:: error: (800) undefined symbol "PORTB"Auto.asm:30:: error: (800) undefined symbol "PORTD"Auto.asm:31:: error: (800) undefined symbol "TRISB"Auto.asm:32:: error: (800) undefined symbol "TRISD"Auto.asm:33:: error: (800) undefined symbol "Retardo"Auto.asm:34:: error: (800) undefined symbol "Sweep"Auto.asm:51:: error: (800) undefined symbol "Conta1"Auto.asm:53:: error: (800) undefined symbol "Conta2"Auto.asm:55:: error: (800) undefined symbol "Conta3"Auto.asm:44:: error: (1223) relative branch/call offset out of rangeAuto.asm:46:: error: (1223) relative branch/call offset out of rangeAuto.asm:58:: error: (1223) relative branch/call offset out of rangeAuto.asm:63:: error: (1223) relative branch/call offset out of rangeAuto.asm:66:: advisory: (1) too many errors (21)(908) exit status = 1make: Leaving directory 'C:/Users/guill/OneDrive/Documents/DIG_3/led_shift/Auto.X'make: Leaving directory 'C:/Users/guill/OneDrive/Documents/DIG_3/led_shift/Auto.X'make: *** [nbproject/Makefile-default.mk:116: build/default/production/Auto.o] Error 1make: *** [nbproject/Makefile-default.mk:91: .build-conf] Error 2make: *** [nbproject/Makefile-impl.mk:39: .build-impl] Error 2BUILD FAILED (exit value 2, total time: 1s)Thank you for the time to check my mistake

author: KL27x
author_rank: Super Contributor
timestamp: May 07, 2020, 10:43:27 pm
content: In general, you shouldn't have gotten nearly this far before trying to assemble. Then you don't have a million error codes to sort through.If you double-click on any error (or warning) code, the IDE should jump to that part of the code. That context is kinda helpful, and you can't expect folks to do that for you.That said, some obvious things jump out at me.Your counters are not showing as undefined. This is because you used cblock incorrectly. Cblock has an additional operand; it needs the starting address. You just defined "Conta" as 0x12, so I assume you want these registers to start at that address. So you should have that after the cblock instruction.E.g.Cblock Conta ;(or Cblock 0x12)…endcAlso, stuff like "PORTB" is showing as undefined. So make sure you have that .inc file available? Not sure on that.Also, it seems evident that you are not familiar with banks. I'm pretty sure that TRIS and PORT are not on the same bank in this PIC, but I could be wrong. That is a whole other barrel of fun that you will have to learn. The memory in this particular PIC is divided into what is probably something like 16 or 32 banks. If you want to program this in assembly, you will have to refer to the memory map and make sure that the bank bits are set for the right bank you are accessing. The easiest way to set those bits on this PIC is to use the banksel directive. Banksel must be followed by any literal address that falls in the range of the bank you want to select, but you will most commonly just write a register name after it.banksel 0h ; set to bank0banksel PORTB ; set to bank in which PORTB has been defined; in this case bank0Also, you should buy David Gooligum's tutorials on PIC assembly. They are the bomb. And you are not even remotely close to having working code, yet. Even if you fixed all the error codes, the program would not do what you intend, and you wouldn't have any hope of debugging it without going back and working through the basics. The Gooligium tutorials are very brief, but nearly every single thing in there must be kept in mind for almost every line of code you write.Also, writing assembly for PIC18 is really extra annoying. You have to pay attention to the number of instruction cycles for each instruction. With 16F architecture, almost all instructions are 1 cycle. There are quite a few in PIC18 that take more. E.g., if you use a skipif instruction, it will skip the next program memory spot. If that instruction is multi-cycle, then it will jump into the second part of that instruction rather than skipping the entire thing.