Help with Config for a PIC18F26K22 for normal INPUT operation please.

Status
Not open for further replies.

ryteker

New Member
Hi all,
I'm just 'playing' with a PIC18F26K22 chip to replace a PIC16F886, and don't seem to be able to set it up for a standard Input operation, Output operation seems to be ok.
I have 6 leds (3 on Port A , 3 on Port C) and these operate fine via the LATA and LATC registers (TRISA.TRISC have all been setup ok)
I have 3 Push Buttons on PORTB, bits 0,1,2, pulling the input to 0v when pressed.
The WPU resistors are enabled, and TRISB set for inputs etc. but can't get the input to operate correctly ....
I'm sure its to do with the Config and/or other registers not being set up correctly.
I just wondered if any of you guys have any experience with the PIC18F26K22 and if so, a bit of sample code would be much appreciated.
Regards
Roy
 
Have you set the ADCON1 reg. ( anything above 8<<2 will set the adc's on portb)

Also you MUST clear ANSELH
 
Hi Ian / nickelflipper,
It was to do with the various registers associated with Port B, in particular it was INTCON2
The PBADEN=OFF was done as part of the config bits,
I have included the listing of the ports setup that I used, and this does work correctly now.
It may help others if they experience the same problem
Thanks for your replies gents.
Regards
Roy

;SELECT THE 'SFR' REGISTERES TO THE HIGH BANK
MOVLB 0xF
;INITIALISE PORT A
CLRF PORTA
CLRF LATA
CLRF ANSELA
MOVLW B'00000000'
MOVWF TRISA
;INITIALISE PORT B
CLRF PORTB
CLRF LATB
CLRF ANSELB
CLRF INTCON2
MOVLW B'00000111'
MOVWF TRISB
MOVLW B'00000111'
MOVWF WPUB
;INITIALISE PORT C
CLRF PORTC
CLRF LATC
CLRF ANSELC
MOVLW B'00000000'
MOVWF TRISC

(DO ANY OTHER INITIALISATION REQUIREMENTS)

;SELECT THE 'SFR' REGISTERES BACK TO THE LOW BANK
MOVLB 0x0
 
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…