Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <LPC21xx.h>
- #include<stdio.h>
- #include "uart0.h"
- #include "RTC.h"
- void RTCInit(void){
- CCR = 0; // Reset All Bit Control
- CCR |= 0x00000010; // CLKSRC = 1 = Used EXT 32.768 KHz
- CCR |= 0x00000002; // Reset Clock
- CCR &= 0xFFFFFFFD; // Release Reset
- CCR |= 0x00000001;
- CIIR = 0x00000007; //Enable seconds min hour counter interrupt
- AMR = 0x000000F8; //1111 1000 //Enable seconds min hour Alarm
- //CCR = 0x00000001; //Start the RTC
- VICVectAddr13 = (unsigned)RTC_isr; //Set the timer ISR vector address
- VICVectCntl13 = 0x0000002D; //Set channel
- VICIntEnable = 0x00002000;
- }
- void RTC_isr(void) __irq
- {
- if(ILR& 0x00000001) //Test for RTC counter interrupt
- {
- ILR = 0x00000001; //Clear the interrupt register
- printf("RTC >> %d : %d : %d\n",HOUR,MIN,SEC);
- }
- if(ILR & 0x00000002)
- {
- ILR = 0x00000002;
- delay(100000);
- printf("alarm !!!!!!!!\n");
- }
- VICVectAddr = 0x00000000; //Dummy write to signal end of interrupt
- }
Advertisement
Add Comment
Please, Sign In to add comment