LPC1768 RTC Backup register issue

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

LPC1768 RTC Backup register issue

1,930 Views
ajit_skale
Contributor I

Hi,
I am facing the same issue with LPC1768 ------> the RTC work fine only with mains power ON,even if coin battery of 3.3v connected to RTC pin. 
While initiating the program the backup registers need to be read to load the RTC value. But in my case after resetting the power the backup registers not storing the RTC value.
 suggest whats the solution?

Thanks
Ajit

Labels (1)
0 Kudos
Reply
8 Replies

1,520 Views
ajit_skale
Contributor I

My problem is .. when I reset or power cycle the board ..and try to read the RTC value stored in Backup register..The value either not getting stored in register or RTC is not able to start from the last stored backup value 

 Please explain procedure to restart RTC after power cycle or reset..

0 Kudos
Reply

1,520 Views
jeremyzhou
NXP Employee
NXP Employee

Hi Ajit Kale,

Thank you for your interest in NXP Semiconductor products and for the opportunity to serve you.
Actually, I'm not very clear with the question, whether you mean that the values will miss in the GPREG0 to GPREG4 register after POR reset.
If not, I was wondering if you can introduce it again.
Have a great day,
TIC

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
Reply

1,520 Views
ajit_skale
Contributor I

My problem is .. when I reset or power cycle the board ..and try to read the RTC value stored in Backup register..The value either not getting stored in register or RTC is not able to start from the last stored backup value 

 Please explain procedure to restart RTC after power cycle or reset..

0 Kudos
Reply

1,520 Views
jeremyzhou
NXP Employee
NXP Employee

Hi Ajit Kale,
Thanks for your reply.
The RTC contains a small set of backup registers (20 bytes) for holding data while the chip is powered off and the backup registers won't store any values automatically, in another word, after POR reset, it should reinitialize the RTC module like before.
Hope this is clear.
Have a great day,
TIC

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
Reply

1,520 Views
ajit_skale
Contributor I

Hi

    Correct ! I am doing the same ... writing the Backup register before power off and reading the backup registers after power ON .. also initalizing the RTC value after Power ON.. but RTC not getting initialized .. I tried with several boards... but same result....please clarify 

good day...

Thanks

Ajit

0 Kudos
Reply

1,520 Views
jeremyzhou
NXP Employee
NXP Employee

Hi Ajit Kale,

Thanks for your reply.
I think the root cause is the failure of writing these backup registers, in another word, the backup registers don't contain the expected values.
To confirm it, I'd highly recommend you to share a demo code which replicating this phenomenon, then I can dig much deeper into it.
Have a great day,
TIC

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
Reply

1,520 Views
ajit_skale
Contributor I

Below is my sample code cut pasted for your reference 

#include "stdio.h" 

#include "LPC17xx.h"

#include "stdint.h"  

#include "stddef.h"

//PIN Definition and register configuration

 

 

#define  PORT2DIR   LPC_GPIO2 -> FIODIR0        

#define  PIN2_10DIR   LPC_GPIO2 -> FIODIR2

 

unsigned int gpr0=0,gpr1=0,

#define  P2_10                                  LPC_GPIO2 -> FIOPIN1                                  // Pin2_10 for RTC init value config

 

unsigned int gpr0=0,gpr1=0,hr,yer,mn,sec,yr,mth,x=10 ;

unsigned char second,minut,hour,yearL,yearH,day,month

void RTC_IRQHandler(void)                                                                                                        

                {

                                                 

                                LPC_RTC->GPREG0 = 0  ;                                                              

                                LPC_RTC->GPREG1 = 0  ;

                                second= LPC_RTC -> CTIME0 & 0x0000003F;

                                gpr0 = second ;                                                                 //store Second value GPR0

                                 mn = LPC_RTC -> CTIME0 & 0x00003F00;

                                gpr0 = gpr0 | mn ;                                                            //store Minut value GPR0

                                 hr = LPC_RTC -> CTIME0 &  0x001F0000;

                                gpr0= gpr0 | hr ;                                                               //store hour value GPR0

                                LPC_RTC->GPREG0 = gpr0;

                                day = LPC_RTC -> CTIME1 & 0x0000001F;

                                gpr1  = day ;                                                                        //store day value GPR1

                                mth = LPC_RTC -> CTIME1 & 0x00000F00;

                                gpr1 = gpr1 | mth ;                                                          //store month value GPR1

                                yr = LPC_RTC ->   CTIME1 & 0x0FFF0000;

                                 gpr1 = gpr1 | yr ;                                                              //store year value GPR1

                                LPC_RTC->GPREG1 = gpr1;

                               

                               

 

                                LPC_RTC-> ILR = (1<<1)|(1<<0);

     

                                                                                                                                                                                                                                               

                }

               

void init_RTC()

{

                //RTC Configuration

                LPC_RTC->ILR = (1<<1)|(1<<0);                                                                                                

                LPC_RTC ->CCR = (0<<3)|(0<<2)|(1<<1)|(0<<0);               // for normal RTC operation

  if((P2_10 &0x04) ==0x00)                                                           ///check PIN 2_10 low for wirting                                                                                                                             //initial RTC value

 {

  LPC_RTC ->SEC = 0x00;

                LPC_RTC ->MIN = 0x00;

                LPC_RTC ->HOUR =0x10;

                LPC_RTC ->DOM = 0x01;

                LPC_RTC ->DOY = 0x12C;

                LPC_RTC ->MONTH = 0x0B;

                LPC_RTC->YEAR = 0x7E2;

                LPC_RTC ->CIIR =(0<<7)|(0<<6)|(0<<5)|(0<<4)|(0<<3)|(0<<2)|(0<<1)|(0<<0);

    }

 else                                                                                                                       // Else restore old RTC values                                                                                                                                     //stored in GPR of rtc                              

 { 

                second=    LPC_RTC ->SEC ;

                 minut = LPC_RTC ->MIN;

                hour= LPC_RTC ->HOUR;

                day= LPC_RTC ->DOM ;

                  gpr0 = LPC_RTC->GPREG0;

                  gpr1 = LPC_RTC->GPREG1;

                second=  gpr0 & 0x0000003F;

                     mn = gpr0 & 0x00003F00;

                                                 minut = (mn>>8);

                    hr = gpr0 &  0x001F0000;

                                                hour = (hr >>16);

                                day = gpr1 & 0x0000001F;

                                                  mth = gpr1 & 0x00000F00;

                                                                month = (mth >> 8);

                                                                yr = gpr1 & 0x0FFF0000;

                                                                yer = yr>>16;

                     switch (second)

                                                {  case 0x00: LPC_RTC ->SEC = 0x00;break;         /// Write old value to                                                                                                                                                        ///RTC

                                                   case 0x01: LPC_RTC ->SEC = 0x01;break;

                                                   case 0x02: LPC_RTC ->SEC = 0x02; break;

                                                                 case 0x03:LPC_RTC ->SEC = 0x03;break;

                                                   case 0x04: LPC_RTC ->SEC =0x04; break;

                                                   case 0x05:LPC_RTC ->SEC = 0x05;break;

                                                                 case 0x06:LPC_RTC ->SEC = 0x06;break;

                                                   case 0x07: LPC_RTC ->SEC = 0x07;break;

                                                   case 0x08: LPC_RTC ->SEC = 0x08;break;

                                                                 case 0x09: LPC_RTC ->SEC = 0x09;break;

                                                                 case 0x0a: LPC_RTC ->SEC = 0x0a;break;

                                                   case 0x0b:LPC_RTC ->SEC = 0x0b;break;

                                                   case 0x0c:LPC_RTC ->SEC = 0x0c;break;

                                                   case 0x0d:LPC_RTC ->SEC = 0x0d;break;

                                                                 case 0x0e: LPC_RTC ->SEC = 0x0e;break;

                                                   case 0x0f: LPC_RTC ->SEC = 0x0f;break;

                                                                 case 0x10: LPC_RTC ->SEC = 0x10;break;

                                                   case 0x11: LPC_RTC ->SEC = 0x11;break;

                                                   case 0x12: LPC_RTC ->SEC = 0x12; break;

                                                                 case 0x13:LPC_RTC ->SEC = 0x13;break;

                                                   case 0x14: LPC_RTC ->SEC =0x14; break;

                                                   case 0x15:LPC_RTC ->SEC = 0x15;break;

                                                                 case 0x16:LPC_RTC ->SEC = 0x16;break;

                                                   case 0x17: LPC_RTC ->SEC = 0x17;break;

                                                   case 0x18: LPC_RTC ->SEC = 0x18;break;

                                                                 case 0x19: LPC_RTC ->SEC = 0x19;break;

                                                                 case 0x1a: LPC_RTC ->SEC = 0x1a;break;

                                                   case 0x1b:LPC_RTC ->SEC = 0x1b;break;

                                                   case 0x1c:LPC_RTC ->SEC = 0x1c;break;

                                                   case 0x1d:LPC_RTC ->SEC = 0x1d;break;

                                                                 case 0x1e: LPC_RTC ->SEC = 0x1e;break;

                                                   case 0x1f: LPC_RTC ->SEC = 0x1f;break;

                                                                 case 0x20: LPC_RTC ->SEC = 0x20;break;

                                                   case 0x21: LPC_RTC ->SEC = 0x21;break;

                                                   case 0x22: LPC_RTC ->SEC = 0x22; break;

                                                                 case 0x23:LPC_RTC ->SEC = 0x23;break;

                                                   case 0x24: LPC_RTC ->SEC =0x24; break;

                                                   case 0x25:LPC_RTC ->SEC = 0x25;break;

                                                                 case 0x26:LPC_RTC ->SEC = 0x26;break;

                                                   case 0x27: LPC_RTC ->SEC = 0x27;break;

                                                   case 0x28: LPC_RTC ->SEC = 0x28;break;

                                                                 case 0x29: LPC_RTC ->SEC = 0x29;break;

                                                                 case 0x2a: LPC_RTC ->SEC = 0x2a;break;

                                                   case 0x2b:LPC_RTC ->SEC = 0x2b;break;

                                                   case 0x2c:LPC_RTC ->SEC = 0x2c;break;

                                                   case 0x2d:LPC_RTC ->SEC = 0x2d;break;

                                                                 case 0x2e: LPC_RTC ->SEC = 0x2e;break;

                                                   case 0x2f: LPC_RTC ->SEC = 0x2f;break;

                                                                 case 0x30: LPC_RTC ->SEC = 0x30;break;

                                                   case 0x31: LPC_RTC ->SEC = 0x31;break;

                                                   case 0x32: LPC_RTC ->SEC = 0x32; break;

                                                                 case 0x33:LPC_RTC ->SEC = 0x33;break;

                                                   case 0x34: LPC_RTC ->SEC =0x34; break;

                                                   case 0x35:LPC_RTC ->SEC = 0x35;break;

                                                                 case 0x36:LPC_RTC ->SEC = 0x36;break;

                                                   case 0x37: LPC_RTC ->SEC = 0x37;break;

                                                   case 0x38: LPC_RTC ->SEC = 0x38;break;

                                                                 case 0x39: LPC_RTC ->SEC = 0x39;break;

                                                                 case 0x3a: LPC_RTC ->SEC = 0x3a;break;

                                                   case 0x3b:LPC_RTC ->SEC = 0x3b;break;

                                                  }

 switch (minut)

                                                {  case 0x00: LPC_RTC ->MIN = 0x00;break;

                                                   case 0x01: LPC_RTC ->MIN = 0x01;break;

                                                   case 0x02: LPC_RTC ->MIN = 0x02; break;

                                                                 case 0x03:LPC_RTC ->MIN = 0x03;break;

                                                   case 0x04: LPC_RTC ->MIN =0x04; break;

                                                   case 0x05:LPC_RTC ->MIN = 0x05;break;

                                                                 case 0x06:LPC_RTC ->MIN = 0x06;break;

                                                   case 0x07: LPC_RTC ->MIN = 0x07;break;

                                                   case 0x08: LPC_RTC ->MIN = 0x08;break;

                                                                 case 0x09: LPC_RTC ->MIN = 0x09;break;

                                                                 case 0x0a: LPC_RTC ->MIN = 0x0a;break;

                                                   case 0x0b:LPC_RTC ->MIN = 0x0b;break;

                                                   case 0x0c:LPC_RTC ->MIN = 0x0c;break;

                                                   case 0x0d:LPC_RTC ->MIN = 0x0d;break;

                                                                 case 0x0e: LPC_RTC ->MIN = 0x0e;break;

                                                   case 0x0f: LPC_RTC ->MIN = 0x0f;break;

                                                                 case 0x10: LPC_RTC ->MIN = 0x10;break;

                                                   case 0x11: LPC_RTC ->MIN = 0x11;break;

                                                   case 0x12: LPC_RTC ->MIN = 0x12; break;

                                                                 case 0x13:LPC_RTC ->MIN = 0x13;break;

                                                   case 0x14: LPC_RTC ->MIN =0x14; break;

                                                   case 0x15:LPC_RTC ->MIN = 0x15;break;

                                                                 case 0x16:LPC_RTC ->MIN = 0x16;break;

                                                   case 0x17: LPC_RTC ->MIN = 0x17;break;

                                                   case 0x18: LPC_RTC ->MIN = 0x18;break;

                                                                 case 0x19: LPC_RTC ->MIN = 0x19;break;

                                                                 case 0x1a: LPC_RTC ->MIN = 0x1a;break;

                                                   case 0x1b:LPC_RTC ->MIN = 0x1b;break;

                                                   case 0x1c:LPC_RTC ->MIN = 0x1c;break;

                                                   case 0x1d:LPC_RTC ->MIN = 0x1d;break;

                                                                 case 0x1e: LPC_RTC ->MIN = 0x1e;break;

                                                   case 0x1f: LPC_RTC ->MIN = 0x1f;break;

                                                                 case 0x20: LPC_RTC ->MIN = 0x20;break;

                                                   case 0x21: LPC_RTC ->MIN = 0x21;break;

                                                   case 0x22: LPC_RTC ->MIN = 0x22; break;

                                                                 case 0x23:LPC_RTC ->MIN = 0x23;break;

                                                   case 0x24: LPC_RTC ->MIN =0x24; break;

                                                   case 0x25:LPC_RTC ->MIN = 0x25;break;

                                                                 case 0x26:LPC_RTC ->MIN = 0x26;break;

                                                   case 0x27: LPC_RTC ->MIN = 0x27;break;

                                                   case 0x28: LPC_RTC ->MIN = 0x28;break;

                                                                 case 0x29: LPC_RTC ->MIN = 0x29;break;

                                                                 case 0x2a: LPC_RTC ->MIN = 0x2a;break;

                                                   case 0x2b:LPC_RTC ->MIN = 0x2b;break;

                                                   case 0x2c:LPC_RTC ->MIN = 0x2c;break;

                                                   case 0x2d:LPC_RTC ->MIN = 0x2d;break;

                                                                 case 0x2e: LPC_RTC ->MIN = 0x2e;break;

                                                   case 0x2f: LPC_RTC ->MIN = 0x2f;break;

                                                                 case 0x30: LPC_RTC ->MIN = 0x30;break;

                                                   case 0x31: LPC_RTC ->MIN = 0x31;break;

                                                   case 0x32: LPC_RTC ->MIN = 0x32; break;

                                                                 case 0x33:LPC_RTC ->MIN = 0x33;break;

                                                   case 0x34: LPC_RTC ->MIN =0x34; break;

                                                   case 0x35:LPC_RTC ->MIN = 0x35;break;

                                                                 case 0x36:LPC_RTC ->MIN = 0x36;break;

                                                   case 0x37: LPC_RTC ->MIN = 0x37;break;

                                                   case 0x38: LPC_RTC ->MIN = 0x38;break;

                                                                 case 0x39: LPC_RTC ->MIN = 0x39;break;

                                                                 case 0x3a: LPC_RTC ->MIN = 0x3a;break;

                                                   case 0x3b:LPC_RTC ->MIN = 0x3b;break;

                                                  }

                switch (hour)

                                                {  case 0x00: LPC_RTC ->HOUR = 0x00;break;

                                                   case 0x01: LPC_RTC ->HOUR = 0x01;break;

                                                   case 0x02: LPC_RTC ->HOUR = 0x02; break;

                                                                 case 0x03:LPC_RTC ->HOUR = 0x03;break;

                                                   case 0x04: LPC_RTC ->HOUR =0x04; break;

                                                   case 0x05:LPC_RTC ->HOUR = 0x05;break;

                                                                 case 0x06:LPC_RTC ->HOUR = 0x06;break;

                                                   case 0x07: LPC_RTC ->HOUR = 0x07;break;

                                                   case 0x08: LPC_RTC ->HOUR = 0x08;break;

                                                                 case 0x09: LPC_RTC ->HOUR = 0x09;break;

                                                                 case 0x0a: LPC_RTC ->HOUR = 0x0a;break;

                                                   case 0x0b:LPC_RTC ->HOUR = 0x0b;break;

                                                   case 0x0c:LPC_RTC ->HOUR = 0x0c;break;

                                                   case 0x0d:LPC_RTC ->HOUR = 0x0d;break;

                                                                 case 0x0e: LPC_RTC ->HOUR = 0x0e;break;

                                                   case 0x0f: LPC_RTC ->HOUR = 0x0f;break;

                                                                 case 0x10: LPC_RTC ->HOUR = 0x10;break;

                                                   case 0x11: LPC_RTC ->HOUR = 0x11;break;

                                                   case 0x12: LPC_RTC ->HOUR = 0x12; break;

                                                                 case 0x13:LPC_RTC ->HOUR = 0x13;break;

                                                   case 0x14: LPC_RTC ->HOUR =0x14; break;

                                                   case 0x15:LPC_RTC ->HOUR = 0x15;break;

                                                                 case 0x16:LPC_RTC ->HOUR = 0x16;break;

                                                   case 0x17: LPC_RTC ->HOUR = 0x17;break;

                                                   case 0x18: LPC_RTC ->HOUR = 0x18;break;

                                                               

                                                  }

                 switch (day)

                                                {  case 0x00: LPC_RTC ->DOM = 0x00;break;

                                                   case 0x01: LPC_RTC ->DOM = 0x01;break;

                                                   case 0x02: LPC_RTC ->DOM = 0x02; break;

                                                                 case 0x03:LPC_RTC ->DOM = 0x03;break;

                                                   case 0x04: LPC_RTC ->DOM =0x04; break;

                                                   case 0x05:LPC_RTC ->DOM = 0x05;break;

                                                                 case 0x06:LPC_RTC ->DOM = 0x06;break;

                                                   case 0x07: LPC_RTC ->DOM = 0x07;break;

                                                   case 0x08: LPC_RTC ->DOM = 0x08;break;

                                                                 case 0x09: LPC_RTC ->DOM = 0x09;break;

                                                                 case 0x0a: LPC_RTC ->DOM = 0x0a;break;

                                                   case 0x0b:LPC_RTC ->DOM = 0x0b;break;

                                                   case 0x0c:LPC_RTC ->DOM = 0x0c;break;

                                                   case 0x0d:LPC_RTC ->DOM = 0x0d;break;

                                                                 case 0x0e: LPC_RTC ->DOM = 0x0e;break;

                                                   case 0x0f: LPC_RTC ->DOM = 0x0f;break;

                                                                 case 0x10: LPC_RTC ->DOM = 0x10;break;

                                                   case 0x11: LPC_RTC ->DOM = 0x11;break;

                                                   case 0x12: LPC_RTC ->DOM = 0x12; break;

                                                                 case 0x13:LPC_RTC ->DOM = 0x13;break;

                                                   case 0x14: LPC_RTC ->DOM =0x14; break;

                                                   case 0x15:LPC_RTC ->DOM = 0x15;break;

                                                                 case 0x16:LPC_RTC ->DOM = 0x16;break;

                                                   case 0x17: LPC_RTC ->DOM = 0x17;break;

                                                   case 0x18: LPC_RTC ->DOM = 0x18;break;

                                                                 case 0x19: LPC_RTC ->DOM = 0x19;break;

                                                                 case 0x1a: LPC_RTC ->DOM = 0x1a;break;

                                                   case 0x1b:LPC_RTC ->DOM = 0x1b;break;

                                                   case 0x1c:LPC_RTC ->DOM = 0x1c;break;

                                                   case 0x1d:LPC_RTC ->DOM = 0x1d;break;

                                                                 case 0x1e: LPC_RTC ->DOM = 0x1e;break;

                                                   case 0x1f: LPC_RTC ->DOM = 0x1f;break;

                                                  }

                                 switch (month)

                                                {  case 0x00: LPC_RTC ->MONTH = 0x00;break;

                                                   case 0x01: LPC_RTC ->MONTH = 0x01;break;

                                                   case 0x02: LPC_RTC ->MONTH = 0x02; break;

                                                                 case 0x03:LPC_RTC ->MONTH = 0x03;break;

                                                   case 0x04: LPC_RTC ->MONTH =0x04; break;

                                                   case 0x05:LPC_RTC ->MONTH = 0x05;break;

                                                                 case 0x06:LPC_RTC ->MONTH = 0x06;break;

                                                   case 0x07: LPC_RTC ->MONTH = 0x07;break;

                                                   case 0x08: LPC_RTC ->MONTH = 0x08;break;

                                                                 case 0x09: LPC_RTC ->MONTH = 0x09;break;

                                                                 case 0x0a: LPC_RTC ->MONTH = 0x0a;break;

                                                   case 0x0b:LPC_RTC ->MONTH = 0x0b;break;

                                                   case 0x0c:LPC_RTC ->MONTH = 0x0c;break;

                                                 

                                                  }

  switch (yer)

                                                {  case 0x7E0: LPC_RTC ->YEAR = 0x7E0;break;

                                                   case 0x7E1: LPC_RTC ->YEAR = 0x7E1;break;

                                                   case 0x7E2: LPC_RTC ->YEAR = 0x7E2; break;

                                                                 case 0x7E3:LPC_RTC ->YEAR = 0x7E3;break;

                                                   case 0x7E4: LPC_RTC ->YEAR =0x7E4; break;

                                                   case 0x7E5:LPC_RTC ->YEAR = 0x7E5;break;

                                                                 case 0x7E6:LPC_RTC ->YEAR = 0x7E6;break;

                                                   case 0x7E7: LPC_RTC ->YEAR = 0x7E7;break;

                                                   case 0x7E8: LPC_RTC ->YEAR = 0x7E8;break;

                                                                 case 0x7E9: LPC_RTC ->YEAR = 0x7E9;break;

                                                                 case 0x7Ea: LPC_RTC ->YEAR = 0x7Ea;break;

                                                   case 0x7Eb:LPC_RTC ->YEAR = 0x7Eb;break;

                                                   case 0x7Ec:LPC_RTC ->YEAR = 0x7Ec;break;

                                                 

                                                  }

                 LPC_RTC ->CIIR =(0<<7)|(0<<6)|(0<<5)|(0<<4)|(0<<3)|(0<<2)|(0<<1)|(0<<0);               

 } 

                LPC_RTC ->CCR = (0<<3)|(0<<2)|(0<<1)|(1<<0);

 

}

 

int main(void) 

{  

 SystemCoreClockUpdate();                        //Initialize core clocks og LPC1768

   SystemInit();                                                                                  

   P0_0_dir = 0xff;                                                                             // set display port

 P0_1_dir = 0xff;

                 

 LPC_PINCON->PINSEL4  = (0<<21)|(0<20);  //Pin2.10 as RTC set

 LPC_PINCON->PINMODE4 = (0<<21)|(0<20);

                 

 /// configuration

                 LPC_SC ->PCONP = (1<<15)|(1<<12)|(1<<9)|(1<<4);     // Enable,RTC,GPIO                                                                                                                                                        //           power control bits 

   LPC_PINCON ->PINSEL1             =             (1<<20)|(1<<18)|(1<<16)|(1<<14) ;//0x00014000; Sel ADC0 chanel1 Pin AD0.1

 LPC_PINCON ->PINMODE1        =             (0<<20)|(0<<21)|(0<<19)|(0<<18)|(1<<17)|(1<<15)|(1<<14);                                                                                                                   //neither pullup nor pulldown 

                 PORT2DIR =0x40;

                 PIN2_10DIR = 0x00;

 

  

               

init_RTC();

NVIC_EnableIRQ(RTC_IRQn);

    

               

                 LED =0x40;

                 delay();

                 delay();

                 LED=0x00;

                 delay();

   delay();

)

0 Kudos
Reply

1,520 Views
jeremyzhou
NXP Employee
NXP Employee

Hi Ajit Kale,

Thanks for your reply.
Your code seems a bit complicated to replicate the phenomenon, so I've used the simple demo for testing.
The following below code is used to get the current time and store these values to General purpose registers.

    // Get and print current time
    RTC_GetFullTime (LPC_RTC, &RTCFullTime);
    _DBG( "Current time set to: ");
    _DBD((RTCFullTime.HOUR)); _DBG (":");
    _DBD ((RTCFullTime.MIN)); _DBG (":");
    _DBD ((RTCFullTime.SEC)); _DBG("  ");
    _DBD ((RTCFullTime.DOM)); _DBG("/");
    _DBD ((RTCFullTime.MONTH)); _DBG("/");
    _DBD16 ((RTCFullTime.YEAR)); _DBG_("");
    
    
    // Store the time to General purpose registers
    RTC_WriteGPREG (LPC_RTC, 0, RTCFullTime.YEAR);
    RTC_WriteGPREG (LPC_RTC, 1, RTCFullTime.MONTH);
    RTC_WriteGPREG (LPC_RTC, 2, RTCFullTime.DOM);
    RTC_WriteGPREG (LPC_RTC, 3, RTCFullTime.SEC);
    RTC_WriteGPREG (LPC_RTC, 4, RTCFullTime.MIN);‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

According to the Fig 1, we can find the storing operation works fine.

2018-11-06_14-31-16.jpg

Fig 1

After power reset, the General purpose registers still keep the timer values.

2018-11-06_14-36-08.jpg

Fig 2

After the testing, it shows that the General purpose registers can keep information when the main power supply is off and the value in these registers is not affected by chip reset.
I've attached the complete demo, please refer to it for details and give a try.
Have a great day,
TIC

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
Reply