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 ?
part of the code in both main.c ---
/* Print current time */
tmpVar = RTC_ReadSecond();
PrintDecNumber(tmpVar, 0u, 11u); etc etc
/* Get and print current seconds */
temp = RTC_ReadSecond();
PrintDecNumber(temp, 0u, 11u);
/* Get status */
temp = RTC_ReadStatus(); etc etc
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.
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 !
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.
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.