1 2 Previous Next 16 Replies Latest reply on Sep 23, 2015 11:29 AM by user_444739275

    how to execute two alarms in different flags

    user_444739275

      Hello

         

      Define current time and date
      Define first alarm time and date
      Define second alarm time and date
      Define alarm flag1
      Define alarm flag2

         

              If alarmFlag1 is set   alarmFlag1 = 1u;

         

            and  If first alarm time ,date match with current time,date  

         

                  Then perform following task    

         

                    Alarm_LED_Write(1);

         

             CyDelay (100);

         

             alarmFlag1  = 0u;

         

            Alarm_LED_Write(0);

         

       

         

          alarmFlag2 = 1u;

         

            If second  alarm time ,date match with current time,date  

         

                  Then perform following task    

         

         Alarm_LED_Write(1);

         

             CyDelay (5000);

         

             alarmFlag2  = 0u;

         

            Alarm_LED_Write(0);

         

      how to execute two alarm in different flags ?

        • 1. Re: how to execute two alarms in different flags
          user_1377889

          As I understand RTC there is only one alarm at a time. So you will have to install the next alarm in sequence when the first has finished.

             

           

             

          Bob

          • 2. Re: how to execute two alarms in different flags
            user_444739275

            that's the problem,I did cypress forum search but not getting much information  I don't understand  how to  set next alarm ? 

            • 3. Re: how to execute two alarms in different flags
              user_1377889

              Set the next alarm just like you did setting the first. Set it  when the first Alarm finished.

                 

               

                 

              Bob

              • 4. Re: how to execute two alarms in different flags
                user_444739275

                I am not getting starting point , I don't understand what should be after ALarmISRHandler function

                   

                1. where to define next Alarm time and date , before or after the ALarmISRHandler function ?

                   

                2. where to declare  Alarm structure, before or after the ALarmISRHandler function ?

                   

                3.I Think I don't need to start    LCD , RTC after the ALarmISRHandler function, because the already ON ?

                   

                4. I think I have to set mask again after ALarmISRHandler function

                • 5. Re: how to execute two alarms in different flags
                  user_14586677

                  1. where to define next Alarm time and date , before or after the ALarmISRHandler function ?

                     

                   

                     

                  Set a flag in ISR that indicates a new alarm is needed, service outside ISR, setup the

                     

                  new alarm, and reset the flag.

                     

                   

                     

                  2. where to declare  Alarm structure, before or after the ALarmISRHandler function ?

                     

                   

                     

                  Describe it in main() as a basic part of startup for the system.

                     

                   

                     

                  3.I Think I don't need to start    LCD , RTC after the ALarmISRHandler function, because the already ON ?

                     

                   

                     

                  Correct.

                     

                   

                     

                  4. I think I have to set mask again after ALarmISRHandler function

                     

                   

                     

                  If the alarm properties change yes, like next alarm on just year vs prior alarm on year, month, hours.....

                     

                   

                     

                  Regards, Dana.

                  • 6. Re: how to execute two alarms in different flags
                    user_444739275

                    can you please check the project ,what's wrong why second alarm does not work ?

                    • 7. Re: how to execute two alarms in different flags
                      user_14586677

                      See attached. I think you should do a flow chart to confirm logic is what you

                         

                      want.

                         

                       

                         

                      Regards, Dana.

                      • 8. Re: how to execute two alarms in different flags
                        user_444739275

                        when I put following code I am getting some error

                           

                        volatile uint8 Alarm1flag = Alarm1serviced = Alarm2flag =Alarm2serviced = 0;

                           

                        /* Interrupt prototypes */
                        CY_ISR_PROTO(AlarmIsrHandler);

                           

                        CY_ISR (AlarmIsrHandler);

                           

                         {
                             If ( ( Alarm1flag == 0 ) && (Alarm2flag == 0 ) ) {               // Only set Alarm1flag if both it and Alarm2flag clear

                           

                                      Alarm1flag == 1;
                                     return;
                             }

                           

                             If ( ( Alarm1flag == 1 ) && (Alarm2flag == 0 ) ) {             // Only set Alarm2flag if Alarm1flag has been set

                           

                                      Alarm2flag == 1;
                                     return;
                             }
                        }

                           

                        int main()
                        {

                           

                         

                           

                        line 63  volatile uint8 Alarm1flag = Alarm1serviced = Alarm2flag =Alarm2serviced = 0;

                           

                        error  undeclared  Alarm1serviced

                           

                        error   undeclared Alarm2flag

                           

                        error  undeclared Alarm2serviced

                           

                        line 74 {

                           

                        error expected identifier '('

                           

                         

                           

                        how to remove errors

                        • 9. Re: how to execute two alarms in different flags
                          user_242978793

                          Vead I am reporting to you that after 1 week the sys tick of the PSOC 4 without a crystal has lost about 5 minutes.  Also I thought I told you that it is not a good ideal to use Port 2 of the PSOC 4 for digital signals as these pins are for Analog functions.  I have moved the LCD to Port 0. Also for testing purposes you should have the time and date set to current time.  Everytime I get one of your programs it is set to 3/22/2016.  Why are you setting the date and year in 2016? The Alarm will trigger but you should be setting it to current time just to make it easier to debug.

                          • 10. Re: how to execute two alarms in different flags
                            user_14586677

                            Not sure why this is not working, declare each one on a separate line.

                               

                             

                               

                            line 63  volatile uint8 Alarm1flag = Alarm1serviced = Alarm2flag = Alarm2serviced = 0;

                               

                             

                               

                            Note my code is for you to work around, to check by drawing a flow chart that the

                               

                            logic is right. It was just for example.

                               

                             

                               

                            Regards, Dana.

                            • 11. Re: how to execute two alarms in different flags
                              user_444739275

                              Hello bobgoar

                                 

                               I was waiting for your reply  I just wanted to see result. yes you told me  Port 2 of the PSOC 4 for digital signals as these pins are for Analog functions.

                                 

                              Why are you setting the date and year in 2016?

                                 

                              that was just example. next Time I will set correct time and date 

                              • 12. Re: how to execute two alarms in different flags
                                user_242978793

                                VEAD: I am working on your new file. Your time is still running at high speed.  Also you should leave the UART in the program it makes it easier to debug and also you do not need the LCD.  So I have installed the UART and have changed the ALARM_LED drive and that is working however the Alarm is working but only on the first alarm. I'll be checking the code to see what needs to be done.  The issue with this program is in the while loop.  The program is in that loop at all times and does not return to the main section at all.  That means the Alarm ISR handler needs to be set in the AlarmISrHandler and the new alarm time needs to be set in that function also.  The current program compiles.  I do not know what you did to the program to make it run so fast. 

                                • 13. Re: how to execute two alarms in different flags
                                  user_444739275

                                  Hello Mr. Bobgoar

                                     

                                  thank you for helping me , thank you very much bobgoar and dana  for your time

                                     

                                  actually I want to set the many alarm for device. when alarm is happen the device should be On and when alarm is off device should be OFF

                                     

                                  I looked Project example in Psoc creator , Then I tried to modified , also I don't know why my clock is running very fast. also I am trying to find out reason , but first I am trying to execute second alarm

                                     

                                  I am using LCD to see the current time and date. so that some one can know, on which time and date, alarm is happening , that's why I am using LCD , 

                                  • 14. Re: how to execute two alarms in different flags
                                    user_444739275

                                    Hello Mr. Dana

                                       

                                    I saw your attachment . please look Project workspace. my code is incomplete but I tried to make sequence. what I need to do ?

                                    1 2 Previous Next