cancel
Showing results for 
Search instead for 
Did you mean: 

PSoC 4 MCU

Anonymous
Not applicable

Hello

   

how to set  many alarms in RTC program ? psoc 4 device

   

1.first alarm [date and time ]

   

2.second alarm [date and time ]

   

3.third alarm [date and time ]

   

If first  alarm is activate[date and time ] then turn on LED for 30 second 

   

If second  alarm is activate [date and time ] then turn on LED for 30 second 

   

If third   alarm is activate [date and time ] then turn on LED for 30 second 

0 Likes
Reply
8 Replies
Esteemed Contributor

Basically set RTC alarm up with first alarm.

   

 

   

If that becomes true, alarms, then set a flag1, turn on led1, and set RTC for second alarm.

   

If second alarm becomes true, alarms, then set a flag2, turn on led2, and set RTC for third alarm.

   

If third alarm becomes true, alarms, then set a flag3, turn on led3.

   

 

   

The APIs to set alarm are in datasheet.

   

 

   

APIs to control GPIO for leds -

   

 

   

http://www.cypress.com/documentation/application-notes/an86439-psoc-4-using-gpio-pins                                                   AN86439 - PSoC® 4 - Using GPIO Pins

   

 

   

Regards, Dana.

0 Likes
Reply
Anonymous
Not applicable

Hello Mr. Dana

   

if you look zip file  there is only one LED Pin. I want to set alarm for one LED

   

1. get current time and date from RTC

   

2. print current time and date on LCD  [23:59:55 ---- 03/22/2016 ]

   

3. activate alarm date time  [ 10:02:15---- 04/22/2016 ]

   

4. If alarm is activate turn on LED for 30 second

   

5  activate alarm date time  [ 10:02:15---- 05/22/2016 ]

   

6. If alarm is activate turn on LED for 30 second

   

7. activate alarm date time  [ 10:02:15---- 06/22/2016 ]

   

8. If alarm is activate turn on LED for 30 second

   

I don't understand how to set alarms. I saw RTC datasheet there are alarm mask registers  ,there is no flag, please look my project and tell me what I have to do ?

0 Likes
Reply
Esteemed Contributor

Flag is a variable, so you declare it

   

 

   

uint8 flag = 0;

   

 

   

to set it

   

 

   

flag = 1;

   

 

   

Then you can test in code if it has been set or cleared.

   

 

   

Attached is a C book that may be of use.

   

 

   

Regards, Dana.

0 Likes
Reply
Anonymous
Not applicable

ok I am trying to write example code

   

/* Examples */

   

#define flag_1  (0)
#define flag_2  (0)
#define flag_3  (0)

   

 

   

#define flag_1  (1)
#define flag_2  (1)
#define flag_3  (1)
 

   

int main()

   

uint8 flag;

   

flag = 1;       /* set flag' */

   

flag = 0;     /* clear flag  */
 

0 Likes
Reply
Esteemed Contributor

I have filed a CASE on several things I do not understand in datasheet, lets see what we get.

   

 

   

Regards, Dana.

0 Likes
Reply
Esteemed Contributor

I have asked for an example program, should have something soon.

   

 

   

If you need professional product development help, coding, electrical design, see -

   

 

   

http://www.cypress.com/design-partner-program

   

 

   

Regards, Dana.

0 Likes
Reply
Anonymous
Not applicable

I am trying to fix problem step by step thats why I am taking time.first I am trying to set alarm.  I searched on cypress forum , also I saw datasheet. there are only four project examples, I saw all. I don't understand how to set an RTC Alarm 

   

I am trying  myself. look example code 

   

RTC_SetAlarmDateAndTime()

   

This function is used to set alarm date/time to RTC

   

  

   

#include <project.h>
#include <stdio.h>

   


#define alarm_TIME_HOUR           (0x23u)
#define alarm_TIME_MIN            (0x59u)
#define alarm_TIME_SEC            (0x55u)
#define alarm_TIME_HR_MIN_SEC     ((uint32)(TIME_HOUR << RTC_HOURS_OFFSET) | \
                            (uint32)(TIME_MIN << RTC_MINUTES_OFFSET)    | \
                             TIME_SEC)

   

                            

#define alarm_DATE_MONTH          (RTC_MARCH)
#define alarm_DATE_DAY            (0x22u)
#define alarm_DATE_YEAR           (0x2016u)
#define alarm_DATE_MONTH_DAY_YEAR ((uint32)(DATE_MONTH << RTC_MONTH_OFFSET)   | \
                            (uint32)(DATE_DAY << RTC_DAY_OFFSET)        | \
                             DATE_YEAR)        

   

#define SYSTICK_EACH_10_HZ  (10u)
#define SYSTICK_RELOAD      (CYDEV_BCLK__SYSCLK__HZ / SYSTICK_EACH_10_HZ)

   

/* Interrupt prototype */
CY_ISR_PROTO(SysTickIsrHandler);

   


int main()
{
    /* Place your initialization/startup code here (e.g. MyInst_Start()) */
 

   

    uint32 alarm_time;
    uint32 alarm_date;
    
    RTC_SetAlarmDateAndTime(alarm_TIME_HR_MIN_SEC_alarm_DATE_MONTH_DAY_YEAR);

0 Likes
Reply
Esteemed Contributor

From tech support -

   

 

   

5) "RTC_SetDateAndTime" is not clearly explained in the component datasheet. But it is provided in the component generated code as copied below:

   

 

   

*  inputTime: The time value in the HH:MM:SS format.

   

*       "HH"- The 8-bit MSB that denotes the hour value.

   

*       (0-23 for the 24-hour format and 1-12 for the 12-hour format. The MSB bit of the

   

*       value denotes AM/PM for the 12-hour format (0-AM and 1-PM).

   

*       "MM" - The 2nd 8-bit MSB denotes the minutes value, the valid entries -> 0-59.

   

*       "SS" - The 3rd 8-bit MSB denotes the seconds value, the valid entries -> 0-59.

   

*       Each byte is in the BCD format. Invalid time entries retain the

   

*       previously set values.

   

*

   

*  inputDate: The date value in the format selected in the customizer.

   

*        For the MM/DD/YYYY format:

   

*        "MM" - The 8-bit MSB denotes the month value in BCD, the valid entries -> 1-12

   

*        "DD" - The 2nd 8-bit MSB denotes a day of the month value in BCD, the valid

   

*        entries -> 1-31.

   

*        "YYYY" - The 16-bit LSB denotes a year in BCD, the valid entries -> 1900-2200.

   

*        Each byte is in the BCD format. Invalid date entries retain the

   

*        previously set values.

   

 

   

So, each digit seen on a digital clock display is coded in BCD(occupying 1 nibble).

   

 

   

Regards, Dana.

0 Likes
Reply