;**********************************************************************

; set I/O directions and default values
portio	
	; port A (all inputs, RA6,7 not implimented)
	bsf	STATUS,RP0		; bank 1
	movlw	b'00111111'
	movwf	TRISA			; Port A all inputs
	bcf	STATUS,RP0		; bank 0
	movlw	b'00000000'
	movwf	PORTA			; Port A all outputs low

	; port B (RB7-RB0 outputs for LCD data)
	bsf	STATUS,RP0		; bank 1
	movlw	b'00000000'
	movwf	TRISB			; Port B all outputs
	bsf	OPTION_REG,NOT_RBPU	; disable port B week pull-ups
	bcf	STATUS,RP0		; bank 0
	movlw	b'00000000'
	movwf	PORTB			; Port B all outputs low

	; port C (all inputs)
	bsf	STATUS,RP0		; bank 1
	movlw	b'10111111'
	movwf	TRISC			; RC6 RS232 out, rest inputs
	bcf	STATUS,RP0		; bank 0
	movlw	b'01000000'
	movwf	PORTC			; all outputs low except stop bit

	; port D (all outputs) RD5, RD6, RD7 outputs for LCD control
	bsf	STATUS,RP0		; bank 1
	movlw	b'00000000'
	movwf	TRISD			; Port D all outputs
	bcf	STATUS,RP0		; bank 0
	movlw	b'00000000'
	movwf	PORTD			; Port D all outputs low

	; default values for port D
	bsf	PORTD,CSLD1		; disable A/D #1
	bsf	PORTD,CSLD2		; disable A/D #2
	bcf	PORTD,SCLK		; clear A/D clock line
	bcf	PORTD,DOUT		; clear data out line
	bsf	PORTD,ADRST		; don't reset the A/D

	; port E (RE2-RE0 inputs, PSP port disabled)
	bsf	STATUS,RP0		; bank 1
	movlw	b'00000111'		; set for general purpose I/O
	movwf	TRISE			; all inputs
	bcf	STATUS,RP0		; bank 0
	movlw	b'00000000'
	movwf	PORTE			; all outputs low

	return

;*************************************************************************
