This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

RTC PROBLEM

Hi I have written a simple code to display the content of the RTC_SEC register on seven segment displays. I am using the LPC2378 [MCB-2300 board]. The code works fine on the simulator but not on hardware. When it is downloaded to the hardware, no increment in the seconds is visible. Given below is my code.

#include <LPC23xx.H>

void init_pins(void)
{

PINSEL4 = 0X00000000;
// initialization of port 2 as GPIO port

PINSEL7 = 0X00000000;
// initialization of port 3 as GPIO port

FIO2DIR = 0X000000FF;
// Selection of port pins P2.0 to P2.7 as output to cathodes of SSDs FIO3DIR = 0x01800000;
// configure port pins P3.23 P3.24 as output for triggering the SSDs

FIO2PIN = 0X00000000; FIO3PIN = 0x00000000;
}

void delay_1ms(unsigned int delcount)
{ unsigned int i,j;

for(i=0;i<delcount;i++) for(j=0;j<=6000;j++);
}

int main(void)
{ unsigned int sec=0x00,min=0x00,hour=0x00; unsigned int lo_sec=0x00,hi_sec=0x00; //lo_sec = units and hi_sec = Tens place of Seconds

unsigned int pattern[] = {
0x000000C0, 0x000000F9, 0x000000A4, 0x000000B0, 0x00000099, 0x00000092, 0x00000082, 0x000000F8, 0x00000080, 0x00000090 };

init_pins();

PCONP = 0x00000200; RTC_SEC = 0x00; RTC_MIN = 0x00; RTC_HOUR = 0x00;

RTC_CCR = 0x11;

while(1) { sec = RTC_SEC; min = RTC_MIN; hour = RTC_HOUR;

// Sending the bit pattern for SECONDS to MUX Display. if(sec<10) { FIO2PIN = pattern[sec]; FIO3PIN = 0x00800000; delay_1ms(3); // Run 1-msec delay thrice. FIO2PIN = pattern[0]; FIO3PIN = 0x01000000; delay_1ms(3); } else { lo_sec = sec%10; hi_sec = sec/10;

FIO2PIN = pattern[lo_sec]; FIO3PIN = 0x00800000; delay_1ms(3); FIO2PIN = pattern[hi_sec]; FIO3PIN = 0x01000000; delay_1ms(3); }

}
}

0