PIC18F26K22 Problems RE3  - Page 1
Forum section: electronics / general

author: montcler
author_rank: Contributor
timestamp: June 16, 2016, 08:56:01 am
content: Hello,I want to use the PortE3 as input with a pushbutton and Pic 18F26K22,When pulse is not responding. goes directly line "OK Break ..."Where is the error¿?On page 151 of the datasheet there is a note:Note:"On a Power-on Reset, RE3 is enabled asa digital input only if Master Clearfunctionality is disabled"Code:Device = 18F26K22Xtal = 16Config_StartFOSC = INTIO67 ' HS oscillator (high power > 16 MHz)PLLCFG = On 'On ' Oscillator multiplied by 4PRICLKEN = On ' Primary clock enabledFCMEN = OFF ' Fail-Safe Clock Monitor disabledIESO = Off ' Internal/External Oscillator Switchover mode disabledPWRTEN = On ' Power up timer enabledBOREN = SBORDIS ' Brown-out Reset enabled in hardware only (SBOREN is disabled)BORV = 190 ' Brown Out Reset Voltage set to 1.90 V nominalWDTEN = Off ' Watch dog timer is always disabled. SWDTEN has no effect.WDTPS = 128 ' Watchdog Timer Postscale 1:128CCP2MX = PORTC1 ' CCP2 input/output is multiplexed with RC1PBADEN = Off ' PORTB<5:0> pins are configured as digital I/O on ResetCCP3MX = PORTC6 ' P3A/CCP3 input/output is multiplexed with RC6HFOFST = On ' HFINTOSC output and ready status are not delayed by the oscillator stable statusT3CMX = PORTC0 ' Timer3 Clock Input (T3CKI) is on RC0P2BMX = PORTB5 ' ECCP2 B (P2B) is on RB5 MCLRE = INTMCLR ' MCLR pin enabled, RE3 input pin disabled STVREN = Off ' Stack full/underflow will not cause ResetLVP = Off ' Single-Supply ICSP disabledXINST = Off ' Instruction set extension and Indexed Addressing mode disabled (Legacy mode)Debug = Off ' DisabledCp0 = Off ' Block 0 (000800-001FFFh) not code-protectedCP1 = Off ' Block 1 (002000-003FFFh) not code-protectedCP2 = Off ' Block 2 (004000-005FFFh) not code-protectedCP3 = Off ' Block 3 (006000-007FFFh) not code-protectedCPB = Off ' Boot block (000000-0007FFh) not code-protectedCPD = Off ' Data EEPROM not code-protectedWRT0 = Off ' Block 0 (000800-001FFFh) not write-protectedWRT1 = Off ' Block 1 (002000-003FFFh) not write-protectedWRT2 = Off ' Block 2 (004000-005FFFh) not write-protectedWRT3 = Off ' Block 3 (006000-007FFFh) not write-protectedWRTC = Off ' Configuration registers (300000-3000FFh) not write-protectedWRTB = Off ' Boot Block (000000-0007FFh) not write-protectedWRTD = Off ' Data EEPROM not write-protectedEBTR0 = Off ' Block 0 (000800-001FFFh) not protected from table reads executed in other blocksEBTR1 = Off ' Block 1 (002000-003FFFh) not protected from table reads executed in other blocksEBTR2 = Off ' Block 2 (004000-005FFFh) not protected from table reads executed in other blocksEBTR3 = Off ' Block 3 (006000-007FFFh) not protected from table reads executed in other blocksEBTRB = Off ' Boot Block (000000-0007FFh) not protected from table reads executed in other blocksConfig_EndTRISE = %001000 ' PortE.3 InputSymbol Break_Key = PORTE.3 'Rename PortE3CLS 'Clear DisplayWaitPulse:Repeat 'Ini Bucle buttonPrint At 2,10,"Waiting ......"Until Break_Key =1Print At 2,10,"OK Break ..."DelayMS 3000GoTo WaitPulseENDScheme button:THX

author: ovnr
author_rank: Frequent Contributor
timestamp: June 16, 2016, 09:20:00 am
content: So you need to set the fuse which switches it to be a normal input port, not a reset pin. You even (tried to) highlighted it in the code you posted - MCLRE needs to be set to somethingelse.Also, unless you're out of pins, you should avoid using the MCLR pin as an input.

author: Rick60
author_rank: Contributor
timestamp: June 16, 2016, 09:21:10 am
content: what value is the pull down resistor ? ,as reading the pdf10.6.3 RE3 WEAK PULL-UP you may have a potential divider ( resistor across the switch ) making the voltage never go lower than 2.5v, use <= 10K

author: montcler
author_rank: Contributor
timestamp: June 16, 2016, 09:42:51 am
content: Hello,ovnr, The Fuse is "MCLRE = INTMCLR" (Disable MCLR) only input pin, page 151 datasheet.INTMCLR = Disable MCLR/Digital Input ONEXTMCLR = Enable MCLR /Digital Input OFFRick60, The resistor RE3 It´s ok 10K not problem. Vout =3.15VTHX.

author: montcler
author_rank: Contributor
timestamp: June 16, 2016, 10:07:59 am
content: Hey,Now Works perfect, I did not see that on the board there is another Reset Micro-button and pin RE3 always arrive 3V.So always goes directly "Ok Break ....."THX.

author: picandmix
author_rank: Frequent Contributor
timestamp: June 16, 2016, 08:03:38 pm
content: You might want to consider using a 10k pull up resistor and switch to ground as this will be a more compatible circuit should you want to ICSP in the future.