hi, I need to find out whether the LPC2148 is reset due to POR(power-on reset) or by the RESET pin becoming low. As per the user manual UM10139, I read about the RESET SOURCE IDENTIFICATION REGISTER (RSIR). They have mentioned the 4 possible sources of reset action i.e.: POR,RESET pin, Watchdog and Brownout detection. My application needs to check for the first two conditions only. But the problem is, every time when my code checks for the RSIR register at the very beginning of the execution, both the bits (Power-On reset and RESET pin) of the RSIR register are SET to 1 no matter in what way I reset the microcontroller. Either of the 2 bits should be set based upon the type of reset i provide. Please help in finding the solution to this problem.
Regards, Karan
Are you clearing any bits after having read out the current contents?
No, My code goes like this: int main() { unsigned char Reset_Type=0; if(RSID==0x01) { Reset_Type=1; } else if(RSID==0x02) { Reset_Type=2; } else if(RSID==0x03) { Reset_Type=3; }
/* my other application logic where I check the Reset_Type variable and display on LCD debug messages. Everytime i do so, my Reset_Type variable is always 3 */
}
Yes, we have already concluded that your code doesn't work.
The interesting thing is why you just posted your code without taking into account my question.
The user manual for the chip says: "Writing a 1 to any of these bits clears the corresponding read-side bit to 0."
Don't you find that piece interesting? Interesting enough to actually consider testing it?
Next thing: have you made sure you understand the meaning of the descriptions for the different bits? Are you sure that the manual promises that you will only see one single bit at a time?
yes, I just tried writing a '1' to the zeroth and first positions of the RSID register and I could see the particular bit getting cleared. So the first part, as they mentioned "Writing a 1 to any of these bits clears the corresponding read-side bit to 0." I got it. but the 2nd thing as they ahve mentioned: "But if another Reset signal (e.g., External Reset) remains asserted after the POR signal is negated, then its bit is set. " is unclear to me as far as my hardware is concerned. I am not asserting any Reset signal after the POR condition, still how come the bit is set? And also vice-versa.
Some reset conditions can only be correctly detected if you clear the bits - so the clear isn't optional.
You are saying that you don't know what is connected to the reset pin?
No not like that, I know the Connections to the reset pin. My doubt was the fundamental thing like, if I am just providing a 0V pulse on the reset Pin, how come the POR bit in the RSID register gets set along with the RESET bit as well. As far as clearing the bits is considered, How will I come to know which event(Power-On or Reset pin) has caused the reset if I clear the bits.??
The clever thing is obviously to clear the bits _after_ you have readout the current state - needed since not all reset sources will clear other reset bits.
yup, ofcourse I have done it that way. Read the entire register, then cleared it as well by writing ones to it. But the value I am getting from the RSID register is of concern to me.
You aren't guaranteed to only get the POR bit.
yea. So that's where I am stuck. How to differentiate between the sources of resets
Depending on hardware, you may not be able to get POR without EXTR.
Don't you get only EXTR if you issue an external reset (and have first manually cleared the POR bit)?
hey, Atlast got it working.... As per your instructions, what I did now is: 1. after power-on, I checked for both the bits getting set. 2. once i got that, I simply cleared both the bits, declaring the Reset type as Power On reset. 3. After that every time I hit the reset pin low, I got only the EXTR bit set in the RSID register. 4. So i conclude that my reset is now an External reset.
The main thing was in clearing the bits. Thanks a lot.! Got it finally.!!!!!
Regards, karan
Nice!
The main thing lies in reading the relevant processor documentation two or three times and for every single sentence think: "Is this relevant to me?"
The documentation almost always contains the important hints - but they aren't always extremely visible.
Yes. Perfectly right. Thanks for the advice.!!