CMOS/RTC Problem - SOLVED!

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
kornox

CMOS/RTC Problem - SOLVED!

Post by kornox »

Hi everyone,
I have a very strange problem (at least for me) and hope someone can help. After setting the RTC for a periodic int, everything works fine in Virtual PC. But when I boot a real pc, the cmos is messed up.
Here's the code:

void set_rtc(byte rate) {
byte buff;
buff = inport(0x70);
buff &= 0xe0;
buff |= 0x0a;
outport(0x70, buff);
buff = inport(0x71);
buff &= 0xf0;
buff |= lnibble(rate);
outport(0x71, buff);
}

void outport(word _port, byte _data)
{
__asm__ __volatile__ ("outb %b1, %w0" : : "d" ( _port) , "a" (_data));
}

byte inport(word _port)
{
byte ret;
__asm__ __volatile__ ("inb %w1, %b0" : "=a" (ret) : "d" ( _port));
return ret;
}

Anyone have an idea what can cause the problem?
Thanks
smiddy

Re:CMOS/RTC Problem

Post by smiddy »

How do you mean, the CMOS is messed up? What is messed up about it?
kornox

Re:CMOS/RTC Problem

Post by kornox »

On 2 different boxes something like "Date/Time incorrect" and "CMOS Checksum error". Don't wanna check again and tune the cmos time again. It just look like I'm writing on the wrong place, not in the A anb B registers. But why?
The code again:

void   start_rtc(byte rate) {
byte   buff;
set_rtc(rate);

buff = inport(0x70);
buff &= 0xe0;
buff |= 0x0b;
outport(0x70, buff);
outport(0x71, inport(0x71) | 0x40);
}

void set_rtc(byte rate) {
byte   buff;
buff = inport(0x70);
buff &= 0xe0;
buff |= 0x0a;
outport(0x70, buff);
buff = inport(0x71);
buff &= 0xf0;
buff |= lnibble(rate);
outport(0x71, buff);
}
kornox

Re:CMOS/RTC Problem

Post by kornox »

PROBLEM SOLVED!

I had to mask the byte rad fron inport(0x70) with 0x80 and not just 0xe0. (don't mask just the NMI bit)

cheers
Post Reply