Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] program inside main is not getting executed when RTC is running

Status
Not open for further replies.

bikashh

Full Member level 5
Joined
Nov 28, 2009
Messages
264
Helped
3
Reputation
6
Reaction score
3
Trophy points
1,298
Location
india
Activity points
3,132
Dear friends,
I've written RTC code successfully for my LPC2368 controller and its working properly.But the remaining program is not running when RTC is ON.what must be the reason.

below is my code


main()
{
Init_UART0(9600); // Initilial UART0 = 9600,N,8,1
RTCIN();

while(1)
{
uart0Puts("RTC program\n\r");
delay_ms(2000);
}
}

void RTC_isr(void)__irq
{

if((RTC_ILR & 0x00000001)==1)
{

do
{
Week = (RTC_CTIME0 & MASKWEEK)>>24; // Read Week
Hour = (RTC_CTIME0 & MASKHR)>>16; // Read Hour
Minute = (RTC_CTIME0 & MASKMIN)>>8; // Read Minute
Second = RTC_CTIME0 & MASKSEC; // Read Second

}while(Last_Second == Second); // Update Current Second

Last_Second = Second; // Update Current Second
sprintf((char*)uart0_buf,"Real Time Clock = %2d : %2d : %2d : %2d %2d %2d %4d \n\r",Week,Hour,Minute,Second,Date,Month,Year); // Print Message String
uart0Puts((char*)uart0_buf); //printing on terminal
RTC_ILR = 0x00000001; //clear interrupt
}
VICVectAddr = 0x00000000;
}



void RTCIN(void)
{
PCONP&=0xFFFFFDFF;


/*set DATE and TIME*/
RTC_DOW =1; // Setup Day of Week
RTC_HOUR = 12; // Setup Hour
RTC_MIN = 13; // Setup Minute
RTC_SEC =56; // Setup Second

RTC_DOM = 13;//Date;
RTC_MONTH= 5;//Month;
RTC_YEAR = 2011;//Year;

/*RTC REGISTER CONFIGURATION*/

RTC_CCR |= 0x00000010; // CLKSRC = 1 = Used EXT 32.768 KHz
RTC_CCR |= 0x00000002; // Reset Clock
RTC_CCR &= 0xFFFFFFFD; // Release Reset
RTC_CIIR = 0x00000001; // Enable seconds counter interrupt
RTC_CCR |= 0x00000001; // Start RTC Clock

VICVectAddr13 = (unsigned long)RTC_isr;/*Set Interrupt Vector*/
VICVectCntl13 = 15;
VICIntEnable = (1 << 13);

}




TERMINAL OUTPUT:


Real Time Clock = 7 : 7 : 53 : 15 13 5 2011
Real Time Clock = 7 : 7 : 53 : 16 13 5 2011
Real Time Clock = 7 : 7 : 53 : 17 13 5 2011
Real Time Clock = 7 : 7 : 53 : 18 13 5 2011
Real Time Clock = 7 : 7 : 53 : 19 13 5 2011
Real Time Clock = 7 : 7 : 53 : 20 13 5 2011
Real Time Clock = 7 : 7 : 53 : 21 13 5 2011
Real Time Clock = 7 : 7 : 53 : 22 13 5 2011
Real Time Clock = 7 : 7 : 53 : 23 13 5 2011

RTC is running properly but my program inside main's while loop never get executed.

please help
thanks in advance
 

I can think two things:

1) the IRQ takes too much time to execute, so when the MCU returns from the interrupt, it immediately needs to serve another one. This is not likely as one second is a geological age for an MCU... but should be checked
2) uart0_buf is too short so sprintf damages something and the irq doesn't return correctly

I suggest you to remove the sprintf statement and check if the code works.
 

yes i did remove the sprintf from IRQ routine but same result.

even i tried the below code but still same result

void RTC_isr(void)__irq
{

if((RTC_ILR & 0x00000001)==1)
{
uart0Puts("seconds\n\r");
RTC_ILR = 0x00000001;
}
}

thanks for the reply
 
Last edited:

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top