print correctly BCD CMOS RTC values
print correctly BCD CMOS RTC values
hi,
i'm trying to implement a rtc with cmos(it isn't updated in github)i can get the values, but when i try to print it i only get something buggy.when i was reading some other post, i understood that this is cause it is in BCD and not as int values, so i have to convert it, but the only two abiavle ways that can compile with my code, doesn't work, they just display the same.how can i convert a BCD to a int value?
i'm trying to implement a rtc with cmos(it isn't updated in github)i can get the values, but when i try to print it i only get something buggy.when i was reading some other post, i understood that this is cause it is in BCD and not as int values, so i have to convert it, but the only two abiavle ways that can compile with my code, doesn't work, they just display the same.how can i convert a BCD to a int value?
Re: print correctly BCD CMOS RTC values
thanks, but this actually didn't work for me.
Re: print correctly BCD CMOS RTC values
How so? Elaborate please.alberinfo wrote:thanks, but this actually didn't work for me.
Re: print correctly BCD CMOS RTC values
i didn't see anything to 'convert' BCD to INT, also the only two ways that i see that are:
and:
makes the same result as the image above
Code: Select all
(((hour & 0xF0) >> 4) < 10)
Code: Select all
((hour & 0xF0) >> 4) * 10 + (hour & 0x0F)
Re: print correctly BCD CMOS RTC values
Then, perhaps, the problem is not in conversion but in reading the values from the chip or your prgram being somehow broken (not read from disk correctly, not having correct values in e.g. segment registers).
Re: print correctly BCD CMOS RTC values
CMOS Please look at the wiki before posting.
Re: print correctly BCD CMOS RTC values
You can look at how I've implemented it: https://gitlab.com/sortix/sortix/blob/m ... y/cmos.cpp
That should be a readable & good example. It also avoids race conditions when the value is being updated.
That should be a readable & good example. It also avoids race conditions when the value is being updated.
Re: print correctly BCD CMOS RTC values
thanks, but either the CMOS method or the method provided by sortie didnt work, still displaying the 'S' in the screen
Re: print correctly BCD CMOS RTC values
Can you test separately:alberinfo wrote:thanks, but either the CMOS method or the method provided by sortie didnt work, still displaying the 'S' in the screen
- single character printing
- string printing
- conversion of integer to hex digits and hex chars ('0'-'9','A'-'F')
- conversion of integer to decimal digits and chars ('0'-'9')
- conversion from BCD to integer
Re: print correctly BCD CMOS RTC values
Could you post your source, since your github is severely outdated.
Re: print correctly BCD CMOS RTC values
i've updated it, but anyway, i don't know what or why fails
Re: print correctly BCD CMOS RTC values
You've swapped around your outb functions, the correct syntax for you outb function is and you're using also you should really reorganise your project a good example for this is Meaty_Skeleton.
And because you have copied and pasted so much code by @pvc there are 2 outb functions outb and outportb, OSDev is more than just copying code from others it's about writing code yourself and creating your own OS.
Code: Select all
void outb(word port, word value);
Code: Select all
void outb(word value, word port);
And because you have copied and pasted so much code by @pvc there are 2 outb functions outb and outportb, OSDev is more than just copying code from others it's about writing code yourself and creating your own OS.
Last edited by thomtl on Mon Oct 15, 2018 8:23 am, edited 1 time in total.
Re: print correctly BCD CMOS RTC values
i see in the outportb function that is first the port and then the data as you say.
Re: print correctly BCD CMOS RTC values
Please read my edit