Welcome GuestTuesday, 16/Apr/2024, 10:19 PM

Embedded Systems Lab Website


Length code problem? - Forum

[ New messages · Members · Forum rules · Search · RSS ]
  • Page 1 of 1
  • 1
Forum » Embedded Lab » Embedded Software Programs - PIC Assembly » Length code problem? (Reducing the number of instrucctions makes it work)
Length code problem?
gomimeluDate: Friday, 30/Oct/2015, 7:17 PM | Message # 1
Private
Group: Students
Messages: 1
Status: Offline
Hi I used pic assembler code long time ago and now i want to start using it again. So i build an eassy program for a couple of leds turn on and off forever. I wrote the code and it worked. But after adding some extra lines it stopped working, cheking my code i discovered that if I add some NOP instructions or any other simple instrucction it stops working (In my code are some NOP or register instructions comented) if you uncoment the NOP or D3 instructions the program stops working. I'm really confused because these are simple eassy instructions and can't understand why this happen. Hope some body could help me. Thanks in advance.

#include<P18f4550.INC>

CONFIG WDT=OFF; disable watchdog timer
CONFIG MCLRE = ON; MCLEAR Pin on
CONFIG DEBUG = ON; Enable Debug Mode
CONFIG LVP = OFF; Low-Voltage programming disabled (necessary for debugging)
CONFIG FOSC = HS
 
RES_VECT  CODE    0x0000            ; processor reset vector
    GOTO    START                   ; go to beginning of program

; TODO ADD INTERRUPTS HERE IF USED

MAIN_PROG CODE                      ; let linker place main program

START

D1 equ 0x23
D2 equ 0x21
D3 equ 0x22

CLRF PORTD
    CLRF PORTB
    CLRF PORTA
    CLRF PORTC

    MOVLW 0Eh
    MOVWF ADCON1
    
    CLRF TRISA

    ;NOP
    ;NOP
    ;NOP
    ;NOP
    ;NOP
    ;NOP
    ;NOP
    ;NOP
    ;NOP
    
    ;movlw D'30'
    ;movwf D3    
   
        al:
    MOVLW 0x01
    MOVWF PORTA
    call Retraso
    
    MOVLW 0x05
    call Retraso
    
    MOVLW 0x02
    MOVWF PORTA
    call Retraso
  
    goto al

Retraso:
    MOVLW 0x01
    MOVWF PORTD
    movlw D'30'
        movwf D3
        loop3:
        movlw D'24'
        movwf D2
        loop2:
        movlw D'168'
        movwf D1
        loop1:
        decfsz D1
        goto loop1
        decfsz D2
        goto loop2
        decfsz D3
        goto loop3
    
 return
      
    END
 
amykit1Date: Thursday, 22/Dec/2016, 9:51 AM | Message # 2
Private
Group: Students
Messages: 4
Status: Offline
Here you can consult experts, they can be help you.
 
Forum » Embedded Lab » Embedded Software Programs - PIC Assembly » Length code problem? (Reducing the number of instrucctions makes it work)
  • Page 1 of 1
  • 1
Search:

Login form
Search
Einstein Quotes
Our poll
Rate this Site
Total of answers: 578
Statistics