ds12c887 counting in the hex mode?

Status
Not open for further replies.

peter002

Member level 3
Joined
Mar 18, 2013
Messages
56
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Location
Hindusthaan
Visit site
Activity points
1,765
hello seniors, i hav successfully initialized the rtc with pic16f877a, and reading seconds data from it, hav done the conversion for ascii too.. but the problem is that the rtc sending data in hex mode, means when the lower nibble increases for 15 times then the higher nibble gets increased.. i didnt understood that why this is happening,
plz anyone hlp me regarding that
thanx in advance..
 

Because convert from hex to string or decode to 7-segment diplay are much easier than from dec.
Code:
void ValueToStringHEX_Byte (unsigned char Value, char * String)
{
   const unsigned char HEX_Var[17]={"0123456789ABCDEF"};
   * String++ =   (Value>>4)[HEX_Var];
   * String   =    (Value&0x0F)[HEX_Var];
}
 

thanx for you reply bro, but i do not use c for th programming, i use assembly for pic programming. and i m using the jhd162a lcd for display...

i was thinking that i ll get the bcd output from the chip so i made a sub to conver it to the ascii value as below..


Code dot - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
BCDTOASCII MOVF SEC,w
        ANDLW   B'11110000'
        CLRF            STATUS
        MOVWF   SECH
        SWAPF   SECH,F
        MOVLW   D'48'
        ADDWF   SECH,F
        MOVF            SEC,W
        ANDLW   B'00001111'
        MOVWF   SECL
        MOVLW   D'48'
        ADDWF   SECL,F
        RETURN


i m reading only seconds data from location 0 from the chip and used the above method to convert it to the ascii. but seems pic counting in hex either i change the data mode to binary or bcd... what else shud i do??
 
Last edited:

the problem is solved by myself, thanx to all, the mian problem was that i was using the rtc in binary mode and my b register writting routine was not having gud delay so the instructions to use pic in bcd mode was getting lost, i updated it and now it working fine...

but still my locations for century and months shows ?? in the lcd... trying to fix that and going to add a joystick and a gud menu to change various functions of the rtc..
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…