Author Topic: error code in my programming  (Read 2745 times)

0 Members and 1 Guest are viewing this topic.

Offline Olivares1838112Topic starter

  • Newbie
  • Posts: 1
  • Country: mx
error code in my programming
« on: May 07, 2020, 09:58:53 pm »
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 18F4550
first time using this program and using the PIC

Code: [Select]
LIST P=18F4550
INCLUDE <PIC18F4550.INC>   
;************************************************************
CONFIG  FOSC = HS
CONFIG  PWRT = ON
CONFIG  BOR = OFF
CONFIG  WDT = OFF
CONFIG  MCLRE = ON
CONFIG  PBADEN = OFF
CONFIG  LVP = OFF
CONFIG  DEBUG = OFF
CONFIG  XINST = OFF
; CODE ******************************************************
 
#define Conta   0x12
    cblock
        Conta1
        Conta2
        Conta3
        Sweep
    endc
 
#define Time1   0x00   
#define Time2   0x85   
#define Time3   0x02   
 
    ORG     0x00   
INICIO
    clrt    PORTB   
    clrt    PORTC   
    clrt    PORTD   
    clrt    TRISA   
    movlw   0x01   
    movwf   TRISB   
    movwf   TRISC   
    movwf   TRISD   
   
    btfss   PORTA, 0
    goto    INICIO
    movlw   B'00000001'
    movwf   Sweep
   
MOVERIGTH
    call    Retardo
    rrncf   Sweep, F
    movff   Sweep, PORTB
    btfss   PORTA, 0
    bra     MOVERIGTH
    bra     MOVELEFT
   
MOVELEFTH   
    call    Retardo
    rlncf   Sweep, F
    movff   Sweep, PORTB
    btfss   PORTA, 0
;   btfsc   PORTA, 0 
    bra     MOVELEFT 
    bra     MOVERIGTH
   
Retardo
    movlw   Time1
    movwf   Conta1
    movlw   Time2
    movwf   Conta2
    movlw   Time3
    movwf   Conta3
   
Repeat
    decfsz  Conta1, F
    bra     Repeat
   
    movlw   Time1
    movwf   Conta1
    decfsz  Conta2, F
    bra     Repeat
    decfsz  Conta3
    bra     Repeat
    Return
   
END     





Code: [Select]
make -f nbproject/Makefile-default.mk SUBPROJECTS= .build-conf
make[1]: 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.hex
make[2]: 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.asm
Auto.asm:1:: error: (223) digit out of range
Auto.asm:1:: error: (876) syntax error
Auto.asm:2:: error: (844) lexical error
Auto.asm:16:: error: (876) syntax error
Auto.asm:29:: warning: (1522) RAM access bit operand not specified, assuming banked memory
Auto.asm:30:: warning: (1522) RAM access bit operand not specified, assuming banked memory
Auto.asm:31:: warning: (1522) RAM access bit operand not specified, assuming banked memory
Auto.asm:32:: warning: (1522) RAM access bit operand not specified, assuming banked memory
Auto.asm:34:: warning: (1522) RAM access bit operand not specified, assuming banked memory
Auto.asm:36:: warning: (1522) RAM access bit operand not specified, assuming banked memory
Auto.asm:38:: error: (876) syntax error
Auto.asm:40:: warning: (1522) RAM access bit operand not specified, assuming banked memory
Auto.asm:42:: warning: (1522) RAM access bit operand not specified, assuming banked memory
Auto.asm:49:: error: (876) syntax error
Auto.asm:51:: warning: (1522) RAM access bit operand not specified, assuming banked memory
Auto.asm:53:: warning: (1522) RAM access bit operand not specified, assuming banked memory
Auto.asm:55:: warning: (1522) RAM access bit operand not specified, assuming banked memory
Auto.asm:56:: error: (876) syntax error
Auto.asm:57:: warning: (1522) RAM access bit operand not specified, assuming banked memory
Auto.asm:61:: warning: (1522) RAM access bit operand not specified, assuming banked memory
Auto.asm:62:: warning: (1522) RAM access bit operand not specified, assuming banked memory
Auto.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 default
Auto.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 range
Auto.asm:46:: error: (1223) relative branch/call offset out of range
Auto.asm:58:: error: (1223) relative branch/call offset out of range
Auto.asm:63:: error: (1223) relative branch/call offset out of range
Auto.asm:66:: advisory: (1) too many errors (21)
(908) exit status = 1
make[2]: Leaving directory 'C:/Users/guill/OneDrive/Documents/DIG_3/led_shift/Auto.X'
make[1]: Leaving directory 'C:/Users/guill/OneDrive/Documents/DIG_3/led_shift/Auto.X'
make[2]: *** [nbproject/Makefile-default.mk:116: build/default/production/Auto.o] Error 1
make[1]: *** [nbproject/Makefile-default.mk:91: .build-conf] Error 2
make: *** [nbproject/Makefile-impl.mk:39: .build-impl] Error 2

BUILD FAILED (exit value 2, total time: 1s)
       


Thank you for the time to check my mistake
« Last Edit: May 07, 2020, 10:05:08 pm by Olivares1838112 »
 

Offline KL27x

  • Super Contributor
  • ***
  • Posts: 4103
  • Country: us
Re: error code in my programming
« Reply #1 on: May 07, 2020, 10:43:27 pm »
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)

endc

Also, 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 bank0
banksel PORTB ; set to bank in which PORTB has been defined; in this case bank0


Also, 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.
« Last Edit: May 07, 2020, 11:15:03 pm by KL27x »
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf