- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi there,
Below is the code that I have got from sample example and modified as I require, but I am not able to get current time. Every time I read time after current time and some delay, it still reads the value that I have set to. So, what should I do to read current time and date ?
int main()
{
int second,minute,hour = 0;
int day,month,year = 0;
RTC_TIME_DATE Start;
/* Fill struct with date and time */
Start.Sec = 55u;
Start.Min = 55u;
Start.Hour = 13u;
Start.DayOfMonth = 7u;
Start.Month = 7u;
Start.Year = 2015u;
CyGlobalIntEnable;
RTC_WriteTime(&Start);
RTC_Start();
CyDelay(10000);
second = RTC_ReadSecond();
minute = RTC_ReadMinute();
hour = RTC_ReadHour();
day = RTC_ReadDayOfMonth();
month = RTC_ReadMonth();
year = RTC_ReadYear();
UART_PutString("Time: ");
UART_PutString(itoa(hour,10));
UART_PutString(":");
UART_PutString(itoa(minute,10));
UART_PutString(":");
UART_PutString(itoa(second,10));
UART_PutString("\nDate: ");
UART_PutString(itoa(day,10));
UART_PutString("-");
UART_PutString(itoa(month,10));
UART_PutString("-");
UART_PutString(itoa(year,10));
}
- Labels:
-
PSoC 5LP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
uint32 time;
uint32 date;
char timeBuffer[16u];
char dateBuffer[16u];
You are missing these commands time = RTC_GetTime(); and date = RTC_GetDate();
sprintf(timeBuffer,"%02u:%02u:%02u",RTC_GetHours(time),RTC_GetMinutes(time),RTC_GetSecond(time));
sprintf(dateBuffer,"%02u:%02u:%02u",RTC_GetMonth(date),RTC_GetDay(date),RTC_GetYear(date));
UART_UartPutString(timeBuffer);
UART_UartPutString(" | ");
UART_UartPutString(dateBuffer);
UART_UartPutString("\r");
CyDelay(200);
bobgoar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
When I add time = RTC_GetTime() and date = RTC_GetDate(); , it says implicit declaration of function 'RTC_GetTime() ' is invalid in c99.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Bob Goars project using both functions compiles. What is your RTC component
named ?
RTC_ or RTC_1_, respectivley that would be RTC_GetTime( ) or RTC_1_GetTime().
Regards, Dana.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I got RTC, not RTC_1, so I am doing it right.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I tried the sample program you took your program from and it didn't update it had the same issue you experienced with your code. I Am using a CY8CKit-059 Psoc 5 LP prototyping kit and after looking at the RTC for Psoc 4 and RTC for Psoc 5 and 3 they are different and use different code. The PSOC 5 component needs a 32Khz crystal to function. It is not loaded on the Cy8CKit -059 PSOC 5LP. So the display reads out the orginal data that was loaded at the start of the program. I had this issue with the program I sent you as I left out the SyTickISRhandler and it was not updating . So I must ask do you have a Crystal attached to your board? By the way I added the Uart to the orginal code and it is displaying the date and time but no upate.
Also the code I sent will only work on a PSOC 4 and not the PSOC 5 I assumed that the RTC component was the same for both devices but it is not.
I have not tried it on an LCD display.
Bobgoar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Ak B: your cann't use my code with the PSOC 5 Component as it program functions are completely different that is why you got the error of C99 function not found on the Get_time and date line.
Bobgoar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have found out that, my board hasn't crystal attached to chip, I am using below board.
Is there any way that I can configure crystal and get working ?
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Is there any board with crystal for Psoc5LP , that you know ?
So, have you got your time updating with Cy8CKit -059 PSOC 5LP or it is still not working ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
There are currently two (completely different) RTC components: One for PSoC4 (a new one) and one for PSoC5.
APIs are slightly different and in the PSoC5 version special a function concerning DST is missing. The 5s APIs are quite too many, so it is easy to make mistakes, but it is working correctly. Keep in mind that a watch crystal is needed, because the accuracy of the internal IMO is 1% which would mean you can be half a week off in a year, not only some minutes.
The actual CY8CKIT-050 has got a 32.768kHz xtal on board, so with that kit you will be fine off.
On the CY8CKIT-059 is room for an xtal at location Y1 where you may solder one.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I don't think the xtal is on board, from the CY8CKIT-059 user
manual -
Odd though, its shown in BOM ?
Regards, Dana.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Ahgrrr! Typo above - corrected. The CY8CKIT-050 has got an xtal.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The Crystal that is called out in the data sheet for the Cy8Ckit-059 5lp Prototyping kit is no longer available for purchase can you use a 12pf load cyrstal in its place?