// Defines values for the RTC #define HRS ((LPC_RTC->CTIME0) >> 16) & 0x1F // Hour #define MNS ((LPC_RTC->CTIME0) >> 8) & 0x3F // Minute #define SCS ((LPC_RTC->CTIME0) >> 0) & 0x3F // Second #define DAY ((LPC_RTC->CTIME1) >> 0) & 0x1F // Day #define MNT ((LPC_RTC->CTIME1) >> 8) & 0x0F // Month #define YRS ((LPC_RTC->CTIME1) >> 16) & 0xFFF // Year |
NVIC_EnableIRQ (RTC_IRQn); // Set the RTC Interrupts LPC_GPIO1->FIODIR |= (1<<28); // GPIO1.28 as a output pin with a LED LPC_SC->PCONP |= (1<<9); // Set the power and the clock signal to the Real Time Clock LPC_RTC->CCR |= (1<<0); // Disable the RTC LPC_RTC->ILR |= (1<<0); // The Counter Increment Interrupt block generated an interrupt LPC_RTC->CIIR |= (1<<0); // An increment of the Second value generates an interrupt LPC_RTC->HOUR = 0; // Set the hour LPC_RTC->MIN = 0; // Set the minutes LPC_RTC->SEC = 0; // Set the seconds LPC_RTC->DOM = 0; // Set the day of month LPC_RTC->MONTH = 0; // Set the month LPC_RTC->YEAR = 0; // Set the year LPC_RTC->CCR |= (1<<0); // Enable the RTC |
// Interrupt function for RTC void RTC_IRQHandler (void) { LPC_GPIO1->FIOPIN ^= (1<<28); // Toggle LED UART0_SendByte (HRS); // Send HOUR UART0_SendByte (MNS); // Send MIN UART0_SendByte (SCS); // Send SEC UART0_SendByte (DAY); // Send DAY UART0_SendByte (MNT); // Send MONTH UART0_SendByte (YRS); // Send YEAR LPC_RTC->ILR |= (1<<0); // Reset the interrupt } |
NVIC_EnableIRQ (RTC_IRQn); // Set the RTC Interrupts LPC_GPIO1->FIODIR |= (1<<28); // GPIO1.28 as a output pin with a LED LPC_GPIO2->FIODIR |= (1<<5)|(1<<6); // GPIO1.28 as a output pin with a LED LPC_GPIO2->FIOSET |= (1<<5); LPC_GPIO2->FIOCLR |= (1<<6); LPC_SC->PCONP |= (1<<9); // Set the power and the clock signal to the Real Time Clock LPC_RTC->CCR = 0; LPC_RTC->AMR = 0; LPC_RTC->CIIR = 0; LPC_RTC->CIIR |= (1<<0); // An increment of the Second value generates an interrupt LPC_RTC->HOUR = 9; // Set the hour LPC_RTC->MIN = 49; // Set the minutes LPC_RTC->SEC = 0; // Set the seconds LPC_RTC->DOM = 28; // Set the day LPC_RTC->MONTH = 6; // Set the month LPC_RTC->YEAR = 12; // Set the year LPC_RTC->CCR |= (1<<0); // Enable the RTC |