Configure PIC16F628

Status
Not open for further replies.
Hello

I'm doing a project with a PIC16F628, which I havn't used before and I noticed, that I have to configure the RA5-pin to be /MCLR. How can I do that in a normal assembler code?


Electronics4you
________________________________________________
"If the day seems bad - try www.electro-tech-online.com"
 
Electronics4you said:
I'm doing a project with a PIC16F628, which I havn't used before and I noticed, that I have to configure the RA5-pin to be /MCLR. How can I do that in a normal assembler code?

What do you mean? The RA5 pin *is* MCLR. There's nothing to do there except apply 5V to it to reset your PIC. If you want to use the RA5 pin for I/O, you set the MCLRE config bit to use the internal pull-up at power-up.
 
Oh, I see, you're reading the datasheet, and it says "When configured as MCLR, this pin is active low Reset to the device".

You choose RA5's function by setting the MCLRE config bit.

In an assembly program, you simply AND the config bit values together and assign that to __CONFIG, like this :

Code:
	__CONFIG   _CP_OFF & _DATA_CP_OFF & _LVP_OFF & _BOREN_OFF & _MCLRE_OFF & _WDT_OFF & _PWRTE_ON & _INTOSC_OSC_NOCLKOUT

_MCLRE_OFF in the above example configures RA5 as MCLR.

_MCLRE_ON would let you use RA5 for normal I/O. In this case, MCLR is pulled up internally when you apply a proper supply to the Vdd pin.

See the template f628Atemp.asm that came with MPASM/MPLAB.
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…