Discussion in "PIC Microcontroller Discussion" started by    mohansaini    Sep 11, 2013.
Wed Sep 11 2013, 10:42 am
#1
Hi Sir,

I want to update time of my rtc which is based on internal rtcc of the controller. seconds,mins and hours are updated in an interrupt. Now i want to update time from a customized computer application which sends data in ASCII(for example if i want to set 12:45 i am receiving it as 0x31,0x32:0x34,0x35) i have to convert this data to hex so that i can directly update the time.

i have tried it as
                     unsigned char Tp1,Tp2;
                      Tp1=0x31&0x0F;
                      Tp2=0x32&0x0F;
                      hours=((Tp1<<4)|Tp2); 

but its not working. Please tell what should i do.
Wed Sep 11 2013, 11:26 am
#2
I dont see any issue in conversion. What exactly is not working? is it hours getting wrong value? or what?
Wed Sep 11 2013, 12:14 pm
#3
sir when i tried to set time 12:45 it was like 19:68. from PC side i am sending data as <12:45>.
Wed Sep 11 2013, 12:35 pm
#4
ok i think your clock registers expecting data in decimal not BCD. as you're sending bcd. 12 in hex is 18 in decimal. You need to change your conversion routine.
unsigned char Tp1,Tp2;
Tp1 = 0x31 & 0x0F;
Tp2 = 0x32 & 0x0F;
hours = Tp1 * 10 + Tp2;
 mohansaini like this.

Get Social

Information

Powered by e107 Forum System

Downloads

Comments

KevinTab
Sun Apr 28 2024, 05:35 am
Tumergix
Sun Apr 28 2024, 12:59 am
StevenDrulk
Sat Apr 27 2024, 08:47 pm
StephenHauct
Sat Apr 27 2024, 09:38 am
Adamsaf
Sat Apr 27 2024, 07:12 am
Robertphype
Sat Apr 27 2024, 12:23 am
ktaletrryp
Fri Apr 26 2024, 10:55 pm
Robertrip
Fri Apr 26 2024, 11:20 am