+ Reply to Thread
Results 1 to 4 of 4

Thread: Assembly Language - My program keeps on restarting

  1. #1
    avinsinanan Newbie
    Join Date
    Mar 2003
    Posts
    22

    Default Assembly Language - My program keeps on restarting

    Hello,

    I wrote some code and becasue of the four lines with the asterisks (*), my program keeps on restarting ( It keeps on going back to the line ORG )x00, nop ).

    Without the four lines it gives a one second delay. Why does it keep restarting with the four lines?

    INCLUDE <P16f877.inc>
    LIST P=16F877

    count EQU 0x26
    five EQU 0x27

    ORG 0x00
    nop
    goto main
    ORG 0x10

    main
    BANKSEL OPTION_REG *
    movlw B'00100001' ;*enable counter mode, 1:4 prescaler
    movwf OPTION_REG ;*increment on rising edge
    BANKSEL TMR0*
    movlw D'250'
    movwf count
    movlw 0x10
    movwf five


    point decfsz five
    goto start
    goto here2
    start movlw D'249'
    here addlw 0xFF
    btfss STATUS,Z
    goto here
    decfsz count
    goto start
    goto point

    here2 movf TMR0,W
    clrf TMR0
    movwf PORTD

    stop sleep
    END


    Yours Respectfully
    Avin Sinanan


  2. #2
    Exo
    Exo is offline
    Exo Newbie
    Join Date
    Sep 2003
    Location
    Belgium
    Posts
    1,884

    Default

    did you disable your watchdog timer ?

  3. #3
    bonxer Newbie
    Join Date
    Jul 2004
    Location
    Ashburn, VA
    Posts
    244

    Default

    Yes, it is the watchdog timer, and if the prescaler for the timer is done incorrectly, the watchdog can bite even if turned off. Make sure your WDT is turned off in your fuse settings. Then, in the section that you have starred, you must issue a clear watchdog timer command before assigning the prescaler.
    There\'s no graphic in my signature.
    I don\'t know your IP, and I\'m not trying
    to hax0r you. You\'re welcome.

  4. #4
    pike Newbie
    Join Date
    Oct 2003
    Location
    Sydney, Australia
    Posts
    589

    Default

    OMG this problem got me so many times you wouldn't believe how frustrating it was :x :evil: . Almost quit electronics altogther!!
    www.winpicprog.co.uk - Great PIC language tutorials.

+ Reply to Thread

Tags for this Thread