Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Power UP (POR) VS MCLR Reset

Status
Not open for further replies.

Suraj143

Active Member
I’m doing these three steps in my PIC after org 0000h statement & I’m not clearing any ram.

1) After power on I’m checking a special GP registers value after org statement. So After power up it will show zeros.

2) In my main code I’m modifying that special GP register.

3) Now I’m resetting my PIC by MCLR pin. (not power off)

Now what will be the value of that register? Does it clear or still remains on the last modified value?

Thanks
 
There is no simple answer.

What the bit values are after POR or MCLR reset are detailed clearly in the datasheet. Sometimes within a register only a single bit remains unchange. For others a single bit changes while the bits stay the same.

You need to refer to the datasheet on sections "Special register Summary" and "INITIALIZATION CONDITION FOR SPECIAL REGISTERS".
 
There is no special GP register, only General Purpose register.

You are on your own to set or clear them. The PIC won't do it for you. The values they contain can be anything upon power ON and relying on them to be a fixed value(zero) without initialising is plain stupid. These registers will hold their values when power is healthy.
 
Suraj143 said:
I’m doing these three steps in my PIC after org 0000h statement & I’m not clearing any ram.

1) After power on I’m checking a special GP registers value after org statement. So After power up it will show zeros.

2) In my main code I’m modifying that special GP register.

3) Now I’m resetting my PIC by MCLR pin. (not power off)

Now what will be the value of that register? Does it clear or still remains on the last modified value?

You shouldn't rely on hoping registers maintain their values through a reset, you should ALWAYS initialise then in your startup routine.
 
I've never used MCLR but POR all the time. I have once found that the value in the GPR after POR is 0xff.
 
If you simply want to know if a power on occurred or reset was pressed then there are bits in the Status register for that purpose. A simple way to know is to check bit 3 of status, if it's set then it was a power on reset and you need to clear it, if it's clear then you pressed the reset button. Note, if you don't clear it after you check it then it will stay set after you press reset.

Mike.
 
Thanks for the replies guys.

Pommie said:
If you simply want to know if a power on occurred or reset was pressed then there are bits in the Status register for that purpose. A simple way to know is to check bit 3 of status, if it's set then it was a power on reset and you need to clear it, if it's clear then you pressed the reset button. Note, if you don't clear it after you check it then it will stay set after you press reset.

Mike.

This is my attempt I'm trying to detect whether a MCLR reset has occurred or power on reset has occurred.Earlier I did that with a GP register.But there is a dedicated bit for that purpose.:D

Thanks for that.
 
Pommie said:
If you simply want to know if a power on occurred or reset was pressed then there are bits in the Status register for that purpose. A simple way to know is to check bit 3 of status...
Mike.

Wrong.
Excluded the use of PCON register.
 
I stated a simple way to know one from the other. As the OP is a beginner testing bit 3 of STATUS will suffice. Adding complications like PCON is just likely to confuse.

Mike.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top