I'm trying to program the CMOS RTC, but I can seemingly only make the interrupt fire once. I've read that you have to read the 0xC register to make it fire multiple times but whatever I do, I cannot seem to make it work.
Here's the code I'm trying to make work:
Some defines
Code: Select all
#define CMOS 0x70
#define CMOSI 0x71
Code: Select all
uint8 get(uint8 part) {
outb(CMOS, part);
return inb(CMOSI);
}
void set(uint8 part, uint8 value) {
outb(CMOS, part);
outb(CMOSI, value);
}
Code: Select all
void Clock_Init() {
ReadDate();
// Install the RTC interrupt.
InstallInterruptCallback(40, RTC_callback);
uint8 regB = get(0xB) | 0x40;
set(0xB, regB);
}
Code: Select all
void RTC_callback(registers_t regs) {
static int ticks = 0;
printf(".\n");
ticks++;
if(ticks % 1024) {
if(c.second >= 60) {
ReadDate();
}
ticks = 0;
}
// Read status register C so the interrupt will fire again. (not working atm).
uint8 c = get(0xC);
}