Hello, I'm trying to create a C function to change the time and date of the RTC, already have a function that reads data from the RTC. Please help me if you can.
Thank you.
How to change date and time RTC
-
- Posts: 12
- Joined: Tue May 08, 2012 6:19 am
How to change date and time RTC
Lemon X OS
-
- Member
- Posts: 63
- Joined: Sat Apr 28, 2012 9:41 am
- Location: Earth -> Asia
Re: How to change date and time RTC
It is same as reading, use this code
And write to respective bits, but did u try this
Code: Select all
void write_cmos(unsigned char address, unsigned int value)
{
outportb(ADDRESSREGISTER, address);
outportb(DATAREGISTER,NMI_disable_bit << 7 | data);
}
Anyone has a idea of making a ntfs bootsector?if yes PM me , plz.
Re: How to change date and time RTC
Hi,
Brendan
The general idea is:AlexanderSilvaB wrote:Hello, I'm trying to create a C function to change the time and date of the RTC, already have a function that reads data from the RTC. Please help me if you can.
- Split your time into "century, year, month, week, hour, minute, second" stored in temporary variables
- Determine if the RTC is using binary format or BCD and change everything except "hour" to suit
- Determine if the RTC is using 24 hour format or 12 hour format and change "hour" to suit (note: there's 4 cases here - 24 hour binary, 24 hour BCD, 12 hour binary, 12 hour BCD)
- Determine where the "century" goes using ACPI (the "RTC century register" field at offset 108 in the Fixed ACPI Description Table), or discard it if there's no ACPI
- Wait until the RTC's "update in progress" flag goes from "set" to "clear". There's 2 ways of doing this:
- Polling: Loop until the flag becomes set, then loop until the flag becomes clear. This can waste up to 1 second of CPU time.
- Use the RTC's "update IRQ" to avoid wasting CPU time. In this case the next step will be done in the IRQ handler.
- Write the values you've already prepared into the corresponding RTC/CMOS registers, in order (seconds, then minutes, then hour, then ..., then century).
Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
-
- Posts: 12
- Joined: Tue May 08, 2012 6:19 am