can't write to port a 16f684

Thread Starter

adrenalina

Joined Jan 4, 2011
78
I'm writing a program to move a servo on a 16f684 in assembly and I ran into a very simple problem that I just can't figure out. I am not able to write anything to port a. I'm simulating it with mplab sim and there is no change on port a. I have all of the code written and its just that that is the problem.

The code below is the beginning of my program. port a is supposed to start cleared, but just to check if it was working I write to it. There is no change bit 0 doesn't go high. I just can't figure out what I'm missing.

Rich (BB code):
Start	;configure ports
		banksel	TRISA			; configure PORTA
		movlw	b'111110'		; pin 0 only output
		movwf	TRISA

		; configure TMR0
		movlw	0<<T0CS|0<<PSA|b'110'	; timer mode (T0CS=0), prescaler, 1:128
		banksel	OPTION_REG
		movwf	OPTION_REG

		; initialize variables
		movlw	.90
		banksel	pos
		movwf	pos				; default position 90 degrees
		banksel	PORTA
		movlw	b'111111'
		movwf	PORTA			; set servo pin low

		; configure interrupts
		movlw	1<<GIE|1<<T0IE	; enable timer0 and global interrupts
		movwf	INTCON
 
Last edited:

Thread Starter

adrenalina

Joined Jan 4, 2011
78
Problem solved!
I just remembered to be able to use port a as digital IO you have to disable the comparator and analog input from CMCON0 register and ANSEL register.
 
Top