PCF8563 RTC: Reading Date problem

Go To Last Post
5 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello Friends,

I have interfaced pcf8563 chip with my atmega8( 8Mhz freq). I would like to transmit date and time on hyperterminal using UART.

I am using code vision avr cross compiler for programming.
It provides me ready to use functions to get date and time for pcf8563. I am able to successfully read & transmit( through UART) the time , but my problem is with Date:

1. I have set the date using function

rtc_set_date(21, 2, 9);

Even used variables to do the same

2. To get the date :

rtc_get_date(&read_date, &read_month, &read_year);

All the variables are unsigned char type

I get correct values of read_date and read_month which I am successfully transmitting through UART.

But I am getting strange value (;7 on hyperterminal) for the read_year(which is set as 9)

3.I am converting date and time parameters to ascii using following piece of code:

unsigned char msb_byte=0, lsb_byte=0;

// convert data value to ascii
msb_byte = (( data/10) |0x30);

lsb_byte = ((data%10) |0x30);

// transmit ascii value of msb byte
UDR=msb_byte;
delay_ms(10);
while(data_transmitted==0);

UDR=lsb_byte;
delay_ms(10);
while(data_transmitted==0);

Question: What could be the problem?
1. Whether I am getting wrong year value after reading pcf8563?
2. Am I making mistake while transmitting year value?
3. How to resolve this issue?

Please help me.
Thanks in Advance

:)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
rtc_get_date(&read_date, &read_month, &read_year);

All the variables are unsigned char type

Does the compiler not complain about you using an instead of a for the year ?

David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks David,
I was getting warning : suspicious pointer conversion.

I have changed the data type to unsigned.
But the problem with Year field still persist.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Have you understood the reason ?

David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello David,

What I understood is that the year value returned might be 2009 which can't be stored in a char.

My Problem has been resolved.

Thanks a lot !! David :D
Have a nice day !!