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
CMOS/RTC Problem - SOLVED!
Re:CMOS/RTC Problem
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);
}
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);
}
Re:CMOS/RTC Problem
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
I had to mask the byte rad fron inport(0x70) with 0x80 and not just 0xe0. (don't mask just the NMI bit)
cheers