bitem2k
New Member
Please consider the following code:
Im simulating in MPLAB.
For some reason when the ShortDelay is called
the PCL is set to the correct position(i.e MOVLW instruction), but the next time i press step into, the executing line skips to SDelayLoop.
if i press step into again, PCL Jumps away from my code to an undefined bit of memory (PCL reads Decimal:119).
My shortDelay code is never executed, and the microcontroller is no longer running any of my code!
Does anyone know whats happening here?
Many thanks
Code:
INCLUDE "P16F627A.INC"
LIST P=16F627A
__Config _INTOSC_OSC_NOCLKOUT & _DATA_CP_OFF & _CP_OFF &_LVP_OFF &_BOREN_ON & _MCLRE_OFF & _WDT_OFF & _PWRTE_OFF
cblock 0x20
SDelayCount
endc
org 0
poweron
BSF STATUS,RP0 ;MOVE TO BANK1
CLRF TRISB ;PORT B ALL OUTPUTS
CLRF TRISA ;PORT a ALL OUTPUTS, EXCLUDING A5 OBVIOUSLY
BCF STATUS, RP0 ;MOVE TO BANK0
CLRF PORTA
MOVLW 0x07 ;Turn comparators off and
MOVWF CMCON ;enable pins for I/O
again
MOVLW 0xff
movwf PORTA
MOVLW 0
MOVWF PORTB
[COLOR=Red]call ShortDelay[/COLOR]
MOVLW 0x00
movwf PORTA
MOVLW 0
MOVWF PORTB
call ShortDelay
goto again
[B][COLOR=Red]ShortDelay [/COLOR] [/B]
[COLOR=Lime][B][COLOR=Green]MOVLW H'40' [/COLOR][/B] [/COLOR] ;Get current selected multiplex rate
MOVWF SDelayCount ;Store desired delay count
[B][COLOR=Green]SDelayLoop[/COLOR][/B]
NOP
NOP
NOP
NOP
DECFSZ SDelayCount
GOTO SDelayLoop
retlw 0
END
Im simulating in MPLAB.
For some reason when the ShortDelay is called
the PCL is set to the correct position(i.e MOVLW instruction), but the next time i press step into, the executing line skips to SDelayLoop.
if i press step into again, PCL Jumps away from my code to an undefined bit of memory (PCL reads Decimal:119).
My shortDelay code is never executed, and the microcontroller is no longer running any of my code!
Does anyone know whats happening here?
Many thanks