Page 1 of 1
CMOS time
Posted: Fri Apr 25, 2003 6:15 pm
by slacker
for some reason i can only read the hour and min from CMOS once and then i cant retrieve any data from those ports. why is this? i can read the DAY over and over again...
Re:CMOS time
Posted: Sun Apr 27, 2003 3:01 am
by Pype.Clicker
i don't see a particular reason for this ... maybe something wrong in your code, i know that the CMOS chip behaves a bit differently from the other component of the PC ...
Re:CMOS time
Posted: Sun Apr 27, 2003 10:37 am
by slacker
yea i found the problem but im not sure why it occurs.
i change the number i get to ascii code.
char a=CHANGETOASCII(cmoshours&f); low
char b=CHANGETOASCII(cmoushours>>4) high
when i put the ascii codes in a pointer like:
char *temp;
temp[0]=a;
temp[1]=b;
temp[2]=0;
print(temp);
.....it doesnt work...nothing prints
so i have to do:
char temp[3];
temp[0]=a;
temp[1]=b;
temp[2]=0;
WHY DOES THIS HAPPEN?
Re:CMOS time
Posted: Sun Apr 27, 2003 11:14 am
by Tim
Because you don't understand C strings. The first piece of code doesn't allocate any memory for the string. Your temp pointer points nowhere, so you're writing to a random memory address. In your second piece of code, you access temp as an array. The compiler allocates three elements for it, and everything works.
Re:CMOS time
Posted: Sun Apr 27, 2003 3:00 pm
by df
also remember the cmos timmer outputs BCD numbers which need to be converted.
Re:CMOS time
Posted: Mon Apr 28, 2003 1:08 am
by distantvoices
BCD Numbers: a nibble of a byte represents a number? also known as packed numbers in mainframe asm?