maygapixel

Untitled

Dec 16th, 2017
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.08 KB | None | 0 0
  1. #include <LPC21xx.h>
  2. #include<stdio.h>
  3. #include "uart0.h"
  4. #include "RTC.h"
  5. void RTCInit(void){
  6.     CCR  = 0;                                                   // Reset All Bit Control
  7.     CCR |= 0x00000010;                                      // CLKSRC = 1 = Used EXT 32.768 KHz
  8.     CCR |= 0x00000002;                                      // Reset   Clock
  9.     CCR &= 0xFFFFFFFD;                                      // Release Reset                                       
  10.     CCR |= 0x00000001;
  11.  
  12.     CIIR            = 0x00000007;                       //Enable seconds min hour counter interrupt
  13.     AMR             = 0x000000F8;   //1111 1000                 //Enable seconds min hour Alarm
  14.     //CCR           = 0x00000001;                       //Start the RTC
  15.     VICVectAddr13   = (unsigned)RTC_isr;                //Set the timer ISR vector address
  16.     VICVectCntl13   = 0x0000002D;                       //Set channel
  17.     VICIntEnable    = 0x00002000;  
  18. }                                  
  19. void RTC_isr(void)     __irq
  20. {
  21.     if(ILR& 0x00000001)                                 //Test for RTC counter interrupt
  22.     {
  23.     ILR         = 0x00000001;                    //Clear the interrupt register
  24.  
  25.     printf("RTC >> %d : %d : %d\n",HOUR,MIN,SEC);
  26.     }
  27.  
  28.     if(ILR & 0x00000002)
  29.     {
  30.     ILR         = 0x00000002;
  31.    
  32.     delay(100000);
  33.     printf("alarm !!!!!!!!\n");
  34.    
  35.     }
  36.     VICVectAddr     = 0x00000000;                       //Dummy write to signal end of interrupt
  37. }
Advertisement
Add Comment
Please, Sign In to add comment