16F676 problem

Status
Not open for further replies.

swapan

Member
Friends,
As my earlier post was not proper formated, I post the same again. Please see a portion of the codes that I have used in a project. Every thing is OK. But in a very rare case the processor behaves in improper way.If a condition of a bit test is fulfilled, the processor jumps to INV_ON where PORTA, 2 is set and then PORTC is cleared. Sometimes it is noticed that on jump of the processor to INV_ON, the first instruction to set PORTA, 2 is not carried out. But the next instructions from CLRF PORTC onwards is carried out. Is there any chance for the processor to slip over the first instruction after jumping to INV_ON? If so, could it be eliminated by using some NOPs before the first instruction?

Thanks.

swapan

Code:
INV_ON:	          MOVLW		B'00000100'
		MOVWF		PORTA
		CLRF		PORTC
		BTFSC		PORTA,3
		GOTO		$+2
		GOTO		$-2
 
I had problems with bit-setting too.
The answer was to perform an operation such as:
Code:
movlw   04h

xorwf   portA

However this is just a toggle operation and you must be sure bit 2 is 0 before the operation. 

or  to set bit 2:
movlw     04h
iorwf     portA,1
 
Last edited:
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…