You are here

RTC Example 5LP kit 059 | Cypress Semiconductor

RTC Example 5LP kit 059

Summary: 6 Replies, Latest post by hli on 22 May 2017 12:08 AM PDT
Verified Answers: 2
Last post
Log in to post new comments.
george29 -'s picture
User
2 posts

Hi,

First timer here so please forgive my simple questions as new to C and Cypress, though have done a little C++ with Arduino.

Been working though the tutorials etc and have the RTC 5LP example running ok.

The first point, though cannot see anything in the RTC datasheet, wondered if  there is any way the RTC can be programmed with the current time/date automatically  taken from host PC at programming time ? a very handy feature found on the Arduino.

The other point is about my lack of C knowledge

Was amending the RTC main.c code to display on the LCD in different layouts etc, but then found that some changes had been totally ignored.

Found the cause to be that the same code was replicated in the RtcIntHandler.c and that was overriding the changes I made in main.c

So does C demand you duplicate code like this ? or was the code put in the main.c  as well,  just to make things clearer for the newbie  to see hows it was done ?

thanks

 

part of the code in both main.c   ---

    /* Print current time */
    tmpVar = RTC_ReadSecond();
    PrintDecNumber(tmpVar, 0u, 11u);  etc etc

 

and RtcIntHandler.c

void RTC_EverySecondHandler_Callback(void)
{
    /* Get and print current seconds */
    temp = RTC_ReadSecond();        
    PrintDecNumber(temp, 0u, 11u);
    
    /* Get status */
    temp = RTC_ReadStatus();  etc etc
  

 

 

 

hli
user_78878863's picture
User
2737 posts

You did not post your project, and my crystal ball is still in repair, so I will take an educated guess.

RtcInt is an ISR that you did add to the RTC? If so, then yes it will be called whenever the interrupt gets triggered. There is no need to duplicate this functionality in main (but you should not do long-running stuff in the ISR, such as writing to the LCD - better just set a (volatile) flag which main can then read and react on).

No, there is no automatic way to set the time from the PC, and AFAIK even the Ardiuno doesn't have that (esp. when not connected to a PC...). But you can add this by yourself quite easily via the UART.

george29 -'s picture
User
2 posts

Thanks for the reply.

Its the RtcDesign Example file for the 5LP,  that comes with PSoC v4 , not any code I have written , was just amending the code to change the layout of the lcd output when I found the problem as above.

Perhaps that Example code has just been quickly put together.....

As you say, its not good practice to use  lengthy lcd routines in the ISR  , though wondered with these faster  chips if that was still a problem vs my old 8 bit Pic chips with Assembly code !

hli
user_78878863's picture
User
2737 posts

Its not the MCU speed thats the problem here - the LCD will just take a while for each characters, and your code needs to wait for that to finish.

user_1377889's picture
User
10572 posts

Welcome in the forum, George.

As hli says, it  is easier for us to help you when you post your complete project. With the help of the IDE everything is easier to follow and to check.

Concerning lengthy interrupt handlers: I have seen issues where just a character was sent via USB stalling the system. Usually you are not aware of delay function calls within the generated code, so hli's suggestion makes sense. Of course the code might be a bit longer, as long as you are able to overview all the consequences.

 

Bob

user_242978793's picture
User
1411 posts

Here is an example program that may help you. 

user_242978793's picture
User
1411 posts

Date is set for 12/31/2007 and time is set for 22:59:22 so you will need to change this to the correct date and time.

Log in to post new comments.