We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
On powerup I want to read the cause of starting with the following code:
printf("\n\rPowerup Source [%04X]: ",RSIR); if(RSIR&(1<<0)) {printf("POR "); RSIR|(1<<0);} if(RSIR&(1<<1)) {printf("EXTR "); RSIR|(1<<1);} if(RSIR&(1<<2)) {printf("WDTR "); RSIR|(1<<2);} if(RSIR&(1<<3)) {printf("BODR "); RSIR|(1<<3);}
and get the following as output: Powerup Source [000B]: POR EXTR BODR
It remains the same on PowerOff/On or Reset. What's wrong with it? Peter
I'm using ULINK on my own hardware with LPC2368. There is no difference between using the debugger or not or ULINK connected or not
You should clear the Reset Source Identification Register after you have read the value. The following statement clears it.
RSIR = 0xF; // Clear RSIR flags
For the NXP user's manual: Writing a 1 to any of these bits clears the corresponding read-side bit to 0.
My code looks this:
printf("\n\rPowerup Source [%04X]: ",RSIR); if(RSIR&(1<<0)) {printf("POR "); RSIR|(1<<0);} if(RSIR&(1<<1)) {printf("EXTR ");RSIR|(1<<1);} if(RSIR&(1<<2)) {printf("WDTR ");RSIR|(1<<2);} if(RSIR&(1<<3)) {printf("BODR ");RSIR|(1<<3);}
I clear the bits individually.
Then I also tried this code:
rsir=RSIR; RSIR=0x0f; printf("\n\rPowerup Source [%04X]: ",rsir); if(rsir&(1<<0)) {printf("POR ^");} if(rsir&(1<<1)) {printf("EXTR ");} if(rsir&(1<<2)) {printf("WDTR ");} if(rsir&(1<<3)) {printf("BODR ");}
no difference, output is: Powerup Source [000B]: POR EXTR BODR
Any other idea?
I have used the code below in the BLINKY example of the MCB2300 Board and it just works fine:
char lcd_txt[20]; : sprintf (lcd_txt, "Reset Src=%X", RSIR); RSIR = 0xF; // Clear RSIR flags lcd_print (lcd_txt);
I have tried your code on MCB2300 with LPC2378 and it works as expected.
After Power-on Reset the value of RSIR = 0x03 and the register is cleared when writing 0x0F into it. Also after asserting External Reset the value in RSIR = 0x02 which is also correct.
It seems that on your HW the BODR bit is set (Brown-out detection). Maybe you have some problems with the power supply.
Thank you for your effort. I will have a look at my hardware. P.