- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
hello.
I'm working on an rtc based project although this is my first time of using it. the external rtc I interfaced with psoc4 is reading random values. can someone pls tell me what could be the problem. Attached below is the code.
Solved! Go to Solution.
- Labels:
-
PSoC 4 Architecture
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I briefly read your source.
According to the datasheet of DS1307
The data read from the RTC module seems to be hex data and you are trying to write them as a string.
How about changing your program as below
(1) include "stdio.h" after "project.h" to use sprintf()
#include "project.h"
#include "stdio.h"
(2) add work char after uint8 RTC_TIME[ARRAY_SIZE] ;
uint8 RTC_TIME [ARRAY_SIZE} ;
char str[16] ; // HH:MM:SS\r\n+NULL = 12bytes (16 is with some extra)
(3) comment out line 63
// UART_SpiUartWriteTxData((uint32)RTC_TIME) ;
(4) modify lien 69
> UART_SpiUartPutArray(RTC_TIME, ARRAY_SIZE) ;
to
sprintf(str, "%02X/%02X/%02X ", RTC_TIME[5], RTC_TIME[4], RTC_TIME[3]) ;
UART_UartPutString(str) ;
sprintf(str, "%02:%02:%02\r\n", RTC_TIME[2], RTC_TIME[1], RTC_TIME[0]) ;
UART_UartPutString(str) ;
moto
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi NaAd_4382031,
Please refer to the code example CE222306 – PSoC 4 I2C Master that shows the implementation of I2C low level Apis.
Also check the status of I2C_I2CMasterWriteByte(0x00, timeOut);. Proceed further only if status returns I2C_I2C_MSTR_NO_ERROR.
Also please probe the I2C lines and check if there is any issues in the data sent from the master.
Regards,
Bragadeesh
Bragadeesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I briefly read your source.
According to the datasheet of DS1307
The data read from the RTC module seems to be hex data and you are trying to write them as a string.
How about changing your program as below
(1) include "stdio.h" after "project.h" to use sprintf()
#include "project.h"
#include "stdio.h"
(2) add work char after uint8 RTC_TIME[ARRAY_SIZE] ;
uint8 RTC_TIME [ARRAY_SIZE} ;
char str[16] ; // HH:MM:SS\r\n+NULL = 12bytes (16 is with some extra)
(3) comment out line 63
// UART_SpiUartWriteTxData((uint32)RTC_TIME) ;
(4) modify lien 69
> UART_SpiUartPutArray(RTC_TIME, ARRAY_SIZE) ;
to
sprintf(str, "%02X/%02X/%02X ", RTC_TIME[5], RTC_TIME[4], RTC_TIME[3]) ;
UART_UartPutString(str) ;
sprintf(str, "%02:%02:%02\r\n", RTC_TIME[2], RTC_TIME[1], RTC_TIME[0]) ;
UART_UartPutString(str) ;
moto