Question about the RTC 
Author Message
 Question about the RTC

Hi,

I've written an assembly code which enables me to modify the value of
the Real Time Clock registers.



Thu, 08 Aug 2002 03:00:00 GMT  
 Question about the RTC

So what's the actual question?

Good Luck
Alexei A. Frounze

Quote:

> Hi,

> I've written an assembly code which enables me to modify the value of
> the Real Time Clock registers.



Thu, 08 Aug 2002 03:00:00 GMT  
 Question about the RTC

Quote:
> I've written an assembly code which enables me to modify the value of
> the Real Time Clock registers.

Hi, I don't know what happened to my initial message, there's only the
first sentence...

So this is my question :

(I run my program under w98 with a pentium)

I don't understand why the interrupt enable bit of the B Register of
the RTC has no effect on my system. I thought this bit enables, or
disables the timer interrupt which tells windows to count the time...
When I clear this bit, or put 1 in it, nothing changes...

Then, I've found another device called PIC, Programmable Interrupt
Controller if I remember well.
The documentation about the PIC tells me that :
IRQ0 is associated with a the timer, and IRQ7 with the RTC.
So I have tried to disable the interrupt number 8 associated with the
IRQ0 (timer), but it is the same, the clock of my OS is not stopped :(
I can't understand why. Should it stop it ?

Anyone understands what's happening ?

Thanks, Julien.

Sent via Deja.com http://www.deja.com/
Before you buy.



Sat, 10 Aug 2002 03:00:00 GMT  
 Question about the RTC

OKay, here it goes...

1. set up your IRQ8 ISR (Interrupt vector 70h)
2. don't forget the "out 20h,20h", "out a0h,20h" sequence at the end of
the ISR
3. don't forget to read the C register inside ISR (w/o this RTC will
genarate *only one* IRQ8, but you need 1024/sec)
4. Unmask IRQ8 with the following:
in al, 0a1h
and al, 0feh
out 0a1h, al
5. Setup frequency rate (register A <- 26h)
6. Enable RTC interrupt (register B |= 40h)

7. your code

8. Disable RTC interrupt (Register B ~= 40h)
9. Mask IRQ8:
in al, 0a1h
or al, 1
out 0a1h, al
10. restore original IRQ8 interrupt vector (70h)

Good Luck
Alexei A. Frounze

Quote:

> > I've written an assembly code which enables me to modify the value of
> > the Real Time Clock registers.

> Hi, I don't know what happened to my initial message, there's only the
> first sentence...

> So this is my question :

> (I run my program under w98 with a pentium)

> I don't understand why the interrupt enable bit of the B Register of
> the RTC has no effect on my system. I thought this bit enables, or
> disables the timer interrupt which tells windows to count the time...
> When I clear this bit, or put 1 in it, nothing changes...

> Then, I've found another device called PIC, Programmable Interrupt
> Controller if I remember well.
> The documentation about the PIC tells me that :
> IRQ0 is associated with a the timer, and IRQ7 with the RTC.
> So I have tried to disable the interrupt number 8 associated with the
> IRQ0 (timer), but it is the same, the clock of my OS is not stopped :(
> I can't understand why. Should it stop it ?

> Anyone understands what's happening ?

> Thanks, Julien.

> Sent via Deja.com http://www.deja.com/
> Before you buy.



Sat, 10 Aug 2002 03:00:00 GMT  
 Question about the RTC


Quote:

> > I've written an assembly code which enables me to modify the value of
> > the Real Time Clock registers.

> Hi, I don't know what happened to my initial message, there's only the
> first sentence...

> So this is my question :

> (I run my program under w98 with a pentium)

> I don't understand why the interrupt enable bit of the B Register of
> the RTC has no effect on my system. I thought this bit enables, or
> disables the timer interrupt which tells windows to count the time...
> When I clear this bit, or put 1 in it, nothing changes...

> Then, I've found another device called PIC, Programmable Interrupt
> Controller if I remember well.
> The documentation about the PIC tells me that :
> IRQ0 is associated with a the timer, and IRQ7 with the RTC.
> So I have tried to disable the interrupt number 8 associated with the
> IRQ0 (timer), but it is the same, the clock of my OS is not stopped :(
> I can't understand why. Should it stop it ?

> Anyone understands what's happening ?

> Thanks, Julien.

> Sent via Deja.com http://www.deja.com/
> Before you buy.

The following is an example. Instead of *RTC_Reg* it's maybe better to speak
of CMOS_Reg, but for the rest, all will work fine. Alexei A. Frounze gave
the proper steps, expt for the *enable RTC interupt*, but you can find all
below.

greetings
Warden Dave

;=====================================
; main
;=====================================

.code



         pop    ds

         mov    ax,3570h
         int    21h
         mov    word ptr saveint70,bx
         mov    word ptr saveint70+2,es
         push   ds
         push   cs
         pop    ds
         mov    dx,offset int70
         mov    ax,2570h
         int    21h
         pop    ds

         call   enable_rtc

         sub    ah,ah
         int    16h

         call   disable_rtc

         push   ds
         lds    dx,saveint70
         mov    ax,2570h
         int    21h
         pop    ds

         mov    ax,4c00h
         int    21h

;=====================================
; setup
;=====================================

   UpdateRtc = 10h     ; interrupt source: updated time
    AlarmRtc = 20h     ; interrupt source: time = alarm time
   PeriodRtc = 40h     ; interrupt source: Periodic

  enable_rtc proc near
         mov    ax,0a21h   ; rate 1111b = 65536Hz/2^rate
         call   save_wr_RTC_Reg

         in     al,0a1h
         and    al,not 1
         jmp    short $+2
         jmp    short $+2
         out    0a1h,al

         call   save_rd_RTC_Reg_B
         or     al,UpdateRtc              ; use any combination
         call   save_wr_RTC_Reg_B
         ret
  enable_rtc endp

  disable_rtc proc near
         call   save_rd_RTC_Reg_B
         and    al,not UpdateRtc
         call   save_wr_RTC_Reg_B
         in     al,0a1h
         or     al,1
         jmp    short $+2
         jmp    short $+2
         out    0a1h,al
         ret
  disable_rtc endp

;=====================================
; RTC register io    ah=idx al=val
;=====================================

  wr_RTC_Reg label near
         xchg   ah,al
         out    70h,al
         jmp    short $+2
         jmp    short $+2
         xchg   ah,al
         out    71h,al
         retn

  rd_RTC_Reg label near
         mov    al,ah
         out    70h,al
         jmp    short $+2
         jmp    short $+2
         in     al,71h
         retn

  save_rd_RTC_Reg_B label near
         mov    ah,0Bh
         db     3dh

  save_rd_RTC_Reg_C label near
         mov    ah,0Ch

  save_rd_RTC_Reg label near
         cli
         or     ah,80h                 ; mask NonMaskableInterrupt !
         call   rd_rtc_reg
         jmp    short reset_StatReg_D

  save_wr_RTC_Reg_B label near
         mov    ah,0Bh

  save_wr_RTC_Reg label near
         cli
         or     ah,80h                 ; mask NonMaskableInterrupt !
         call   wr_rtc_reg

  reset_StatReg_D label near
         push   ax
         mov    ah,0Dh                 ; statreg D
         call   rd_rtc_reg
         pop    ax
         sti
         retn

;=======================================

  IntRequest = 80h     ; There was an Interrupt Requested

  int70 proc far
         pusha

         call   save_rd_RTC_Reg_C      ; ends with sti
         test   al,IntRequest

         push   ds

         mov    ds,dx

         mov    ah,al                  ; ah = StatusReg C
         mov    al,20h
         out    0a0h,al
         out    20h,al

         test   ah,UpdateRtc

        ;....



        ;....



        ;....



         iret
  int70 endp



Sat, 10 Aug 2002 03:00:00 GMT  
 Question about the RTC

Quote:

> > I've written an assembly code which enables me to modify the value of
> > the Real Time Clock registers.

> Hi, I don't know what happened to my initial message, there's only the
> first sentence...

> So this is my question :

> (I run my program under w98 with a pentium)

> I don't understand why the interrupt enable bit of the B Register of
> the RTC has no effect on my system. I thought this bit enables, or
> disables the timer interrupt which tells windows to count the time...
> When I clear this bit, or put 1 in it, nothing changes...

> Then, I've found another device called PIC, Programmable Interrupt
> Controller if I remember well.
> The documentation about the PIC tells me that :
> IRQ0 is associated with a the timer, and IRQ7 with the RTC.
> So I have tried to disable the interrupt number 8 associated with the
> IRQ0 (timer), but it is the same, the clock of my OS is not stopped :(
> I can't understand why. Should it stop it ?

Unless you have written a VxD, the PIC and the timer are virtuallized,
and you can't affect the real one.


Sat, 10 Aug 2002 03:00:00 GMT  
 Question about the RTC

Thanks a lot J.Wesley, Warden Dave and Alexei A. Frounze for your help.
I've tried to understand what you said Alexei and Dave, but I think you
are explaining me how to hook the timer interrupt, isn't it ? In fact, I
just want to stop the clock on my PC,
I have no code to execute, so I don't have to code my ISR I think.

I have tried some bits of your code to disable the RTC, (I put 40h in
the B register) and to disable IRQ8 at the same time, but it doesn't
work actually. :(

I haven't written a VxD, but my code is running with CPL=0, I use a
trick which enables me to go ring0 via an interrupt gate.

I have tried to do the I/O commands with this famous de{*filter*} called
softice, but it still doesn't work. I really don't understand.

You see, when I call this de{*filter*} (SoftIce), it pops up and my system
clock is stopped. If I call SoftIce for 5 minutes, then the clock
dislayed by Windows 95 is 5 minutes late, until the next reboot. So I
guess when I call SoftIce, a timer interrupt must be stopped somewhere.
I would like to do the same thing with my code... But I haven't managed
to do it so far...

Quote:


> > > I've written an assembly code which enables me to modify the value
of
> > > the Real Time Clock registers.

> > Hi, I don't know what happened to my initial message, there's only
the
> > first sentence...

> > So this is my question :

> > (I run my program under w98 with a pentium)

> > I don't understand why the interrupt enable bit of the B Register of
> > the RTC has no effect on my system. I thought this bit enables, or
> > disables the timer interrupt which tells windows to count the
time...
> > When I clear this bit, or put 1 in it, nothing changes...

> > Then, I've found another device called PIC, Programmable Interrupt
> > Controller if I remember well.
> > The documentation about the PIC tells me that :
> > IRQ0 is associated with a the timer, and IRQ7 with the RTC.
> > So I have tried to disable the interrupt number 8 associated with
the
> > IRQ0 (timer), but it is the same, the clock of my OS is not stopped
:(
> > I can't understand why. Should it stop it ?

> Unless you have written a VxD, the PIC and the timer are virtuallized,
> and you can't affect the real one.

Sent via Deja.com http://www.*-*-*.com/
Before you buy.


Sat, 10 Aug 2002 03:00:00 GMT  
 Question about the RTC

Parhaps, I wrote something not very clear with C/ASM mix. :)
But anyway this works - I made a multitasking stuff based on RTC IRQ8.
It works normally in DOS and Win9x as well. I believe it will under
WinNT too.

The main problem I had - *only one* IRQ8 instead of periodical
interrupts. This has been solved by reading CMOS_C register inside IRQ8
ISR.

Good Luck
Alexei A. Frounze

Quote:

> The following is an example. Instead of *RTC_Reg* it's maybe better to speak
> of CMOS_Reg, but for the rest, all will work fine. Alexei A. Frounze gave
> the proper steps, expt for the *enable RTC interupt*, but you can find all
> below.



Sun, 11 Aug 2002 03:00:00 GMT  
 Question about the RTC

Quote:

> Thanks a lot J.Wesley, Warden Dave and Alexei A. Frounze for your help.
> I've tried to understand what you said Alexei and Dave, but I think you
> are explaining me how to hook the timer interrupt, isn't it ? In fact, I
> just want to stop the clock on my PC,
> I have no code to execute, so I don't have to code my ISR I think.

> I have tried some bits of your code to disable the RTC, (I put 40h in
> the B register) and to disable IRQ8 at the same time, but it doesn't
> work actually. :(

You should reset 6th bit of the B register but not set.

Quote:

> I haven't written a VxD, but my code is running with CPL=0, I use a
> trick which enables me to go ring0 via an interrupt gate.

Under Win9x?

What is the reason of RTC IRQ8 disabling? What do you want to get by
this?

Alexei A. Frounze



Sun, 11 Aug 2002 03:00:00 GMT  
 Question about the RTC

Quote:

> Parhaps, I wrote something not very clear with C/ASM mix. :)
> But anyway this works - I made a multitasking stuff based on RTC IRQ8.
> It works normally in DOS and Win9x as well. I believe it will under
> WinNT too.

> The main problem I had - *only one* IRQ8 instead of periodical
> interrupts. This has been solved by reading CMOS_C register inside IRQ8
> ISR.

Yes, you have to reset (acknowledge) the IRQ-logic by reading the
CMOS_C_Reg. You can see that happening at the top of *Int70* in the example
a gave.

greetings
Warden Dave



Sun, 11 Aug 2002 03:00:00 GMT  
 
 [ 10 post ] 

 Relevant Pages 

1. RTC Alarm Clock Question

2. Help !! RTC Direct & RTC via Bios

3. local RTC

4. RTC

5. mot6818-RTC needed

6. Code for RTC and or Calendar anyone

7. RTC

8. Help ! ASM call for RTC

9. RTC Troubles

10. RTC Troubles

11. setting RTC power-on (INT 1A, 09)

12. CMOS - RTC #6

 

 
Powered by phpBB® Forum Software