Wrong time display RTC using I2C protocol.

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
NaMa_4430341
Level 1
Level 1

I am using PSoC 5lp to display time on LCD with RTC. The LCD displays wrong time and other characters in between I dont have any errors. I tried changing PLL frequency floating format and stack and heap size. Still no change

please help me in this.

Thank you.

0 Likes
1 Solution
lock attach
Attachments are accessible only for community members.
MotooTanaka
Level 9
Level 9
Distributor - Marubun (Japan)
First comment on blog Beta tester First comment on KBA

Hi,

I tried to emulate LCD with UART, as far as using UART

and when I assigned

==========

    buf[0] = 0x23 ;

    buf[1] = 0x52 ;

    buf[2] = 0x29 ;

==========

Your algorithm seems to be working fine.

004-start-ee4480.JPG

005-Update_Time.JPG

006-Temp.JPG

007-Time.JPG

So remaining possible cause of trouble are

(1) RTC

(2) LCD

About RTC,

Please test without accessing RTC, what I did was

=================

//    if(Read_I2C(ADDR_DS1307, DS1307_REG_SECOND,7,buf)){

    buf[0] = 0x23 ;

    buf[1] = 0x52 ;

    buf[2] = 0x29 ;

...

// } // <= end of if (Read..) block  

=================

If now LCD displays 9/52/23 A, then the problem was communication with the RTC.

If LCD does not display above, then the there is/are problem with the LCD.

About the LCD, by any chance are you using CY8CKIT-059?

If so, using P2[1] and P2[2] may cause you trouble as they are used for other components.

=================

LCD_Port[0] : P2[0]

LCD_Port[1] : P2[1] <- LED

LCD_Port[2] : P2[2] <- SW1

LCD_Port[3] : P2[3]

LCD_Port[4] : P2[4]

LCD_Port[5] : P2[5]

LCD_Part[6] : P2[6]

=================

moto

View solution in original post

0 Likes
11 Replies
MotooTanaka
Level 9
Level 9
Distributor - Marubun (Japan)
First comment on blog Beta tester First comment on KBA

Hi,

Would you do either

(1) Attache a project which can reproduce your problem

  To do this,

   select your project as "Set As Active Project"

   menu > Build > Clean <project name>

   menu > Archive Workspace/Project...

   then attach the result <project>.zip file

(2) Explain

    "wrong time" does the time have offset or totally different stream of letters?

    what is/are "other chars" ?

(3) At least share a part of program which is displaying the value via LCD.

moto

0 Likes

Hi, I tried to attach  the file but couldn't do it. Please let me know how can i do that?

Thank you.

0 Likes
lock attach
Attachments are accessible only for community members.

Hey , I figured it and I have attached my file. Please let me know

0 Likes
MotooTanaka
Level 9
Level 9
Distributor - Marubun (Japan)
First comment on blog Beta tester First comment on KBA

Hi,

Oh, you are using DS1307!?

Assuming that your I2C functions are working OK,

For the seconds, the MSB is CH flag, so I would write

ch_flag = (buf[0] >> 7) & 0x01 ; /* ch_flag == 1, the oscillator is disabled */

s = BCD2DEF(buf[0] & 0x7F) ;

As I don't have DS1307 and LCD,

it would be nice if you can put a picture of LCD

if it still has wrong chars or please type exact letters you are seeing.

moto

0 Likes
lock attach
Attachments are accessible only for community members.
MotooTanaka
Level 9
Level 9
Distributor - Marubun (Japan)
First comment on blog Beta tester First comment on KBA

Hi,

I tried to emulate LCD with UART, as far as using UART

and when I assigned

==========

    buf[0] = 0x23 ;

    buf[1] = 0x52 ;

    buf[2] = 0x29 ;

==========

Your algorithm seems to be working fine.

004-start-ee4480.JPG

005-Update_Time.JPG

006-Temp.JPG

007-Time.JPG

So remaining possible cause of trouble are

(1) RTC

(2) LCD

About RTC,

Please test without accessing RTC, what I did was

=================

//    if(Read_I2C(ADDR_DS1307, DS1307_REG_SECOND,7,buf)){

    buf[0] = 0x23 ;

    buf[1] = 0x52 ;

    buf[2] = 0x29 ;

...

// } // <= end of if (Read..) block  

=================

If now LCD displays 9/52/23 A, then the problem was communication with the RTC.

If LCD does not display above, then the there is/are problem with the LCD.

About the LCD, by any chance are you using CY8CKIT-059?

If so, using P2[1] and P2[2] may cause you trouble as they are used for other components.

=================

LCD_Port[0] : P2[0]

LCD_Port[1] : P2[1] <- LED

LCD_Port[2] : P2[2] <- SW1

LCD_Port[3] : P2[3]

LCD_Port[4] : P2[4]

LCD_Port[5] : P2[5]

LCD_Part[6] : P2[6]

=================

moto

0 Likes

Yes, It displays 9/52/23 and 9/2/1. it fluctuates between numbers. Well, I have connected to port12[6.0] at that time also it was the same problem.

I am using CY8CKIT -059

0 Likes
MotooTanaka
Level 9
Level 9
Distributor - Marubun (Japan)
First comment on blog Beta tester First comment on KBA

Hi,

In the page 25 of CY8CKIT-059 PSoC 5LP Prototyping Kig Guide Rev.G

there is a table like below. Please try to use the pin with only "GPIO."

007-PIN_List.JPG

moto

0 Likes

Yes, It displays 9/52/23 and 9/2/1. it fluctuates between numbers. Well, I have connected to port12[6.0] at that time also it was the same problem.

I am using CY8CKIT -059

Thank you

0 Likes
MotooTanaka
Level 9
Level 9
Distributor - Marubun (Japan)
First comment on blog Beta tester First comment on KBA

Hi,

Although it may not be the direct problem, but

P12[0]  I2C_SCL

P12[1] I2C_SDA

P12[6] UAR_RX

P12[7] UART_TX

these seem to be better to avoid.

moto

0 Likes
MotooTanaka
Level 9
Level 9
Distributor - Marubun (Japan)
First comment on blog Beta tester First comment on KBA

Another thing slightly bothering me is

sprintf(str,"%2d/%2d/%2d   ", h, m, s );

How about trying

sprintf(str, "%02d:%02d:%02d", h, m, s) ;

Note: I prefer to use color (:) for time and slash for date.

but my point is that the trailing spaces may be affecting the fluctuation..

moto

0 Likes

Hi, I tried your code. It displayed h/m/s as 2/0/7 at the beginning and displayed 2/30/17IMG_5525.JPG it is not displaying constant changing of seconds.

IMG_5526.JPG

0 Likes