PDA

View Full Version : Using MCLR pin at Input



JakeMend
- 5th July 2017, 02:15
I am using a 12F683 and having no luck in disabling the MCLR pin (pin 4 bit 3) so that I can use it as an input.

In the PicBasic program, I put ANSEL = 0 to set all the pins to digital and CMCON0 = 7 to turn off the analog comparators.

In the hardware, I attached a 1K ohm pull-up resistor to pin 4, since I read that as an input, the internal pull-up is disabled.

In the meProg, configuration sections, I set Oscillator to INTOSCIO and th MCLR Pin Function to Input Pin

In the meProg, Option section, I checked both Update Configuration from File and Reread File Before Programming.

And yet, the MLCR pin 4 (bit 3) remains a Reset and not an Input.

What am I doing wrong or not doing to disable the MCLR function?

Thanks,

-Jake

p.s. I also tried to program other 12F683 chips just in case the one I was using was bad, but they all worked the same way.

HenrikOlsson
- 5th July 2017, 06:16
Hi,
To me it looks like you're doing everything right though neither ANSEL nor CMCON should have any effect on GP3 operation.
However, I don't know the details on how meProg works. Is it possible that what it's actually programming into the chip is STILL what the code says - the default config for the 12F683 is MCLR enabled?

I guess you can always try that by changing the oscillator setting in meProg and program the chip, if it STILL runs then there's something going on with the CONFIG bits not being programmed to the settings showed in meProg.

I'm sorry for not having a definitive answer.

/Henrik.

aerostar
- 5th July 2017, 09:22
I have this in my program (PBP2.60C) and am using GP3 as an input and it works fine.

@ DEVICE PIC12F683, intrc_osc_noclkout, wdt_on, mclr_off, protect_off , bod_on

INCLUDE "ALLDIGITAL.pbp"

The ALLDIGITAL.pbp just makes sure I have everything set as digital.


The problem is that the PBP assembler uses mclr and mpasm uses MCLRE , see the .inc file



;************************************************* ***************
;* 12F683.INC *
;* *
;* By : Leonard Zerman, Jeff Schmoyer *
;* Notice : Copyright (c) 2005 microEngineering Labs, Inc. *
;* All Rights Reserved *
;* Date : 08/31/05 *
;* Version : 2.46a *
;* Notes : *
;************************************************* ***************
NOLIST
ifdef PM_USED
LIST
include 'M12F683.INC' ; PM header
device pic12F683, intrc_osc_noclkout, wdt_on, mclr_on, protect_off
XALL
NOLIST
else
LIST
LIST p = 12F683, r = dec, w = -302
INCLUDE "P12F683.INC" ; MPASM Header
__config _INTRC_OSC_NOCLKOUT & _WDT_ON & _MCLRE_ON & _CP_OFF
NOLIST
endif
LIST

mpgmike
- 5th July 2017, 15:08
"device pic12F683, intrc_osc_noclkout, wdt_on, mclr_on, protect_off"
"__config _INTRC_OSC_NOCLKOUT & _WDT_ON & _MCLRE_ON & _CP_OFF"

I believe to use the MCLRE pin as a digital input these 2 lines must read "mclr_off" and "_MCLRE_OFF"

Mike

aerostar
- 5th July 2017, 20:35
"device pic12F683, intrc_osc_noclkout, wdt_on, mclr_on, protect_off"
"__config _INTRC_OSC_NOCLKOUT & _WDT_ON & _MCLRE_ON & _CP_OFF"

I believe to use the MCLRE pin as a digital input these 2 lines must read "mclr_off" and "_MCLRE_OFF"

Mike

But ONLY if you always want it OFF - and then have to remember to change it in the program, when you want it on.

The inc file is for general use, and idealy should be left unchanged, - you use the config statements in your program to over ride, as per the statement at top of post 3

@ DEVICE PIC12F683, intrc_osc_noclkout, wdt_on, mclr_off, protect_off , bod_on

JakeMend
- 5th July 2017, 20:43
I found out what to do. I need to reset the configuration file by inserting this code into beginning of the program

#config
__config _mclre_off
#endconfig

The pin 4 (bit 3) will now be an INPUT with an internal pull-up resistor.

NOTE: The underline before the config is a double underline __ and not a single underline_

There is a space after the config and before the _mclre


Thank you, Henrik, for your response.

richard
- 6th July 2017, 00:06
#config
__config _mclre_off
#endconfig

can be a bad move , all "unmentioned" config fuse settings will revert to default settings when the chip is erased


that means your config becomes possibly not whats really intended

#CONFIG
__config _EXTRC & _WDT_ON & _PWRTE_OFF & _MCLRE_OFF & _CP_OFF & _CPD_OFF & _BOD_ON & _IESO_ON & _FCMEN_ON
#ENDCONFIG


imho its best to set the lot the way you intend

JakeMend
- 6th July 2017, 16:51
I want to sincerely thank all of the people who responded with advice and suggestions.

I not only got the initial problem solved, but I learned some things that I probably would not have figured out on my own that will save me from more problems in the future.

Thanks,

-Jake :)

HenrikOlsson
- 6th July 2017, 19:04
That's great news Jake!
Please stick around, tell us about your project, participate in the discussions and ask questions (preferrably ones that haven't been answered 100 times already), it's gotten very quiet here lately and we could use some new blood!

/Henrik.

JakeMend
- 6th July 2017, 22:39
I don't know about new blood or even new problems, but I have lots of old versions of both that I will be grateful to share.

Thanks,

-Jake