Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <LPC21xx.h>
- #include <stdio.h>
- #include "EXT.h"
- #include "uart0.h"
- unsigned int a=1,b=1,c=1,buf=0,buf1=0,abuf=0,abuf1=0;
- void ExtInt(void)
- {
- PINSEL0 |= 0x80000000; //Enable the EXTINT2 interrupt
- PINSEL0 |= 0x20000000; //Enable the EXTINT1 interrupt
- PINSEL0 |= 0x000C0000; //Enable the EXTINT3 interrupt
- VICVectCntl1 = 0x00000020 | 0x0000000F; //select a priority slot for a given interrupt
- VICVectAddr1 = (unsigned)EXTINT1VectoredIRQ; //pass the address of the IRQ into the VIC slot
- VICVectCntl2 = 0x00000020 | 0x00000010; //select a priority slot for a given interrupt
- VICVectAddr2 = (unsigned)EXTINT2VectoredIRQ; //pass the address of the IRQ into the VIC slot
- VICVectCntl3 = 0x00000020 | 0x00000011; //select a priority slot for a given interrupt
- VICVectAddr3 = (unsigned)EXTINT3VectoredIRQ; //pass the address of the IRQ into the VIC slot
- VICIntEnable |= 0x00020000; //enable EXTINT3 interrupt
- VICIntEnable |= 0x00010000; //enable EXTINT2 interrupt
- VICIntEnable |= 0x00008000; //enable EXTINT1 interrupt
- }
- void EXTINT1VectoredIRQ (void)__irq
- {
- delay(2500000);
- if (a == 1)
- {
- printf("current time\n");
- a++;
- buf=0;
- buf1=0;
- }
- else if(a == 2){
- printf("alarm time\n");
- a= 1;
- abuf=0;
- abuf1=0;
- }
- EXTINT = 0x00000002; //Clear the peripheral interrupt flag
- VICVectAddr = 0x00000000; //Dummy write to signal end of interrupt
- }
- void EXTINT2VectoredIRQ (void)__irq
- {
- delay(2500000);
- if (a == 2)
- {
- if(b==1 && buf==0){
- printf("current time ok\n");
- b++;
- buf=1;
- abuf1=0;
- }
- else if (b==2 && buf==1){
- printf("current hour\n");
- b++;
- abuf1=0;
- }
- else if (b==3 && buf==1){
- printf("current min\n");
- b++;
- abuf1=0;
- }
- else if (b==4 && buf==1){
- printf("current sec\n");
- b= 2;
- abuf1=0;
- }
- }
- else if (a == 1){
- if(c==1 && abuf==0){
- printf("alarm time ok\n");
- abuf++;
- c++;
- abuf1=0;
- }
- else if (c==2 && abuf==1){
- printf("alarm hour\n");
- c++;
- abuf1=0;
- }
- else if (c==3 && abuf==1){
- printf("alarm min\n");
- c++;
- abuf1=0;
- }
- else if (c==4 && abuf==1){
- printf("alarm sec\n");
- c= 2;
- abuf1=0;
- }
- }
- EXTINT = 0x00000004; //Clear the peripheral interrupt flag
- VICVectAddr = 0x00000000;
- }
- void EXTINT3VectoredIRQ (void)__irq
- {
- delay(2500000);
- if (a == 2 && b==2)
- { if(buf1==0){
- printf("set sec ok\n");
- buf1=1;
- }
- else if (buf1==1){
- if(SEC>58){
- SEC=0;
- printf("%d\n",SEC);
- }
- else{
- printf("%d\n",SEC+1) ;
- SEC++;
- }
- }
- }
- else if (a == 2 && b==4)
- { if(buf1==0){
- printf("set min ok\n");
- buf1=1;
- }
- else if (buf1==1){
- if(MIN>58){
- MIN=0;
- printf("%d\n",MIN);
- }
- else{
- printf("%d\n",MIN+1) ;
- MIN++;
- }
- }
- }
- else if (a == 2 && b==3)
- { if(buf1==0){
- printf("set hour ok\n");
- buf1=1;
- }
- else if (buf1==1){
- if(HOUR>22){
- HOUR=0;
- printf("%d\n",HOUR);
- }
- else{
- printf("%d\n",HOUR+1) ;
- HOUR++;
- }
- }
- }
- if (a == 1 && c==2)
- { if(abuf1==0){
- printf("set sec ok\n");
- abuf1=1;
- }
- else if (abuf1==1){
- if(ALSEC>58){
- ALSEC=0;
- printf("%d\n",ALSEC);
- }
- else{
- printf("%d\n",ALSEC+1) ;
- ALSEC++;
- }
- }
- }
- else if (a == 1 && c==4)
- { if(abuf1==0){
- printf("set min ok\n");
- abuf1=1;
- }
- else if (abuf1==1){
- if(ALMIN>58){
- ALMIN=0;
- printf("%d\n",ALMIN);
- }
- else{
- printf("%d\n",ALMIN+1) ;
- ALMIN++;
- }
- }
- }
- else if (a == 1 && c==3)
- { if(abuf1==0){
- printf("set hour ok\n");
- abuf1=1;
- }
- else if (abuf1==1){
- if(ALHOUR>22){
- ALHOUR=0;
- printf("%d\n",ALHOUR);
- }
- else{
- printf("%d\n",ALHOUR+1) ;
- ALHOUR++;
- }
- }
- }
- EXTINT = 0x00000008; //Clear the peripheral interrupt flag
- VICVectAddr = 0x00000000; //Dummy write to signal end of interrupt
- }
Advertisement
Add Comment
Please, Sign In to add comment