DECFSZ [NOT AN] issue on the PIC 16F1509 ?

EDIT: I hate going to the message board… naturally I am licking my wounds from getting scolded for daring to use cblock…

GPR_VAR UDATA

var_name  RES 1

…. took care of this issue… at least that fiasco is over.. and I thought the PWM was going to be the hard part!  /EDIT

This code is killing me. I’ve pulled it out of something I’m working on… it has been kicking my ass for two days now.

The LED on PORTC,2 should be pulses for a few hundred nanoseconds and then go off….. right?  No.. the decfsz sits in an endless loop it seems. Why? I’ve messed up somewhere here?

 

  errorlevel -230, -302, -303, -313
    LIST R=DEC

#include "p16f1509.inc"


    __CONFIG _CONFIG1, _FOSC_INTOSC & _WDTE_OFF & _PWRTE_OFF & _CLKOUTEN_OFF
    __CONFIG _CONFIG2, _LVP_OFF & _STVREN_ON


cblock
    int_delay1
    int_delay2
endc

RES_VECT  CODE    0x0000            ; processor reset vector
    GOTO    START                   ; go to beginning of program


MAIN_PROG CODE                      ; let linker place main program


INIT:
                            ;RC5 = PWM1
    BANKSEL LATA            ;Data Latch
    CLRF LATA               ;
    BANKSEL ANSELC          ;
    CLRF ANSELC             ;Digital IO
    BANKSEL PORTC           ;
    BCF PORTC,5             ;Clear PWM1
    BANKSEL TRISC           ;Set all PORTC to outputs
    CLRF TRISC

    BANKSEL OSCCON
    MOVLW   0x78            ;16MHZ Clock
    MOVWF   OSCCON

    RETURN


START
    CALL    INIT

           BANKSEL int_delay1
            MOVLW   0x01
            MOVWF   int_delay1
            BSF PORTC,2
OLOOP
            NOP
            BANKSEL int_delay1
            DECFSZ int_delay1,1
            GOTO OLOOP
            BCF PORTC,2



    NOP

LOOP:
    NOP
    GOTO LOOP                ;loop forever

    END

Author: Chas

I don't know why I blog, because? I have no agenda, just love electronics and want to share. I love to follow other experimenters/hardware hackers just to see what other people are working on. Shoot me a message if you blog.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: