According to this:
https://skills.microchip.com/introdu...tecture/691929
The pull-up is disabled automatically when either TRIS is set to an output or the pin is set as an analog input. These changes to TRIS and ANSEL will override WPU settings.
I can just set all pull-ups ON, leave the unused pins unconnected and forget about them. Then use the others as I wish in ANSEL and TRIS.
The only times I need to be concerned with WPU is on pins that must not be disturbed for whatever special reason.
Code:WPUA = %11111111 '----------------------------------------------------------------' WPUB = %11111111 ' ALWAYS SET WEAK PULL-UPS ON ALL PINS FIRST ' WPUC = %11111111 '----------------------------------------------------------------' ' CHANGES TO ANSEL AND TRIS WILL OVERRIDE AS REQUIRED ' '----------------------------------------------------------------' ANSELA = %00000010 ' Pin A3 = SW input not implemented yet ' Pin A2 = ADC (B5K) not implemented yet ' Pin A1 = ADC (B5K) ' Pin A0 = ADC (voltage divider) not implemented yet ANSELB = %00000000 ANSELC = %00000000 TRISA = %00000010 ' Pin A3 = SW input not implemented yet ' Pin A2 = ADC input 2 not implemented yet ' Pin A1 = ADC input 1 ' Pin A0 = ADC input 0 not implemented yet TRISB = %00000000 ' Pin B7 = ...not available, ICSPDAT ' Pin B6 = ...not available, ICSPCLK TRISC = %11000000 ' Pin C7 = RX *** Datasheet requirement, INPUT *** ' Pin C6 = TX *** Datasheet requirement, INPUT ***
EDIT: I can even leave PORT at the top in case a pin is left as analog output.
Code:PORTA = %00000000 '-------------------------------------------' PORTB = %00000000 ' ALWAYS SET PINS LOW FIRST ' PORTC = %00000000 '-------------------------------------------'
Or did I miss something important...?![]()


Reply With Quote

Bookmarks