Author
|
Topic: Wants the RTC to interrupt 1024/s... (Read 186 times)
|
|
Peter_Vigren
Member
Posts: 214
|
|
Wants the RTC to interrupt 1024/s...
« on: 02/18/03 02:08 »
|
|
Hi. I try to get the Real Time Clock to generate 1024 interrupts/second but the output I get can't be that... It's much lesser than 1024... This is the code I use to setup the RTC... Anything wrong with it?
Mov Al,0xA Out 70h,Al Jmp short $+2
In Al,71h
And Al,10100110b Or Al,00100110b Push Ax
Mov Al,0xA Out 70h,Al Jmp short $+2 Pop Ax
Out 71h,Al
Mov Al,0xB Out 70h,Al Jmp short $+2 In Al,71h
And Al,01010011b Or Al,01010010b Push Ax
Mov Al,0xB Out 70h,Al Jmp short $+2 Pop Ax Out 71h,Al |
|
|
Best regards, Peter Vigren
Oh, you know the story. Girl meets boy. Girl modifies boy’s sub routines...
|
|
|
Ozgunh82
Member
Posts: 445
|
|
Re:Wants the RTC to interrupt 1024/s...
« Reply #1 on: 02/18/03 17:36 »
|
|
Hi, I think you are making a mistake here:
Because you are disabling nmi no matter what its state is. This might not be a good thing I think. It will be better to do this like:
in al, 70h ;Get current 70h and al, 0eh ;Discard lower 5 bits because we are just allowed to use them or al, 0ah ;Byte index we will get from cmos ram. out 70h, al ;Send index to 70h in al, 71h ;Get needed info from cmos.
|
|
BTW, I could not understand what these mean:
And Al,10100110b Or Al,00100110b
|
|
What do these binary values correspond to? If you can write some comments on code I might try to help more.(I am also dealing with this subject nowadays ) I hope this helps, good luck...
|
|
|
|
Pete
Member
Posts: 458
Keep it Simple
|
|
Re:Wants the RTC to interrupt 1024/s...
« Reply #2 on: 02/18/03 18:28 »
|
|
I've written a datasheet which provides info on the CMOS chip (including RTC) at xinit.port5.com
What you need to do is:-
Set bits 0-3 of Status Register A to 0110b Set bit 6 of Status Register B to 1 Read status register C after every interrupt. Bit 6 of Status Register C will be set if the interrupt was the periodic interrupt (set at 1024Hz)
Hope this helps
|
A program is never perfect, unless your B Gates when every program's perfect until the new version is released. ::OSID::
|
|
|
Peter_Vigren
Member
Posts: 214
|
|
Re:Wants the RTC to interrupt 1024/s...
« Reply #3 on: 02/18/03 19:38 »
|
|
Hi, I think you are making a mistake here:
|
| That is to invoke the port. You send the number of the port to 70h and read or write to port 71h.
And Al,10100110b Or Al,00100110b
|
|
What do these binary values correspond to? If you can write some comments on code I might try to help more.(I am also dealing with this subject nowadays ) I hope this helps, good luck...
|
| I set status A to x010 0110b. x = Update In Progress flag (left unchanged) 010 = 32 MHz or something like that... default value 0110 = what to divide 010 with
The result is how many interrupts per second there should be...
|
Best regards, Peter Vigren
Oh, you know the story. Girl meets boy. Girl modifies boy’s sub routines...
|
|
|
Peter_Vigren
Member
Posts: 214
|
|
Re:Wants the RTC to interrupt 1024/s...
« Reply #4 on: 02/18/03 19:40 »
|
|
I've written a datasheet which provides info on the CMOS chip (including RTC) at xinit.port5.com
What you need to do is:-
Set bits 0-3 of Status Register A to 0110b Set bit 6 of Status Register B to 1 Read status register C after every interrupt. Bit 6 of Status Register C will be set if the interrupt was the periodic interrupt (set at 1024Hz)
Hope this helps
|
| Thanx but I already know that. And as you can see, I set bit 0-3 to 0110...
|
Best regards, Peter Vigren
Oh, you know the story. Girl meets boy. Girl modifies boy’s sub routines...
|
|
|
Pete
Member
Posts: 458
Keep it Simple
|
|
Re:Wants the RTC to interrupt 1024/s...
« Reply #5 on: 02/18/03 20:01 »
|
|
But surely if you are only resetting the speed you leave everything else the same so surely OR al, 0110b would suffice instead of the and and or instructions. Off the top of my head the following should all that's required to enable ONLY the periodic interrupt at 1024Hz.
mov al, 0x0A out 0x70, al mov al, 0110b out 0x71, al mov al, 0x0B out 0x70, al in al, 0x71 and al, 10001111b or al, 01000000b mov bl, 0x0B out 0x70, bl out 0x71, al |
|
Then after each interrupt then do:-
mov al, 0x0C out 0x70, al in al, 0x71 |
|
Does this work?
|
A program is never perfect, unless your B Gates when every program's perfect until the new version is released. ::OSID::
|
|
|
Peter_Vigren
Member
Posts: 214
|
|
Re:Wants the RTC to interrupt 1024/s...
« Reply #6 on: 02/19/03 00:41 »
|
|
But surely if you are only resetting the speed you leave everything else the same so surely OR al, 0110b would suffice instead of the and and or instructions. |
| Or will only set the bits that is set. It will not touch the zeros... then al could become 0111b or something else unless I use and to zero the bits I want to have zeroed... (sorry for the loosy explanation... is so d*mn tired right now... and high on coffee...)
|
Best regards, Peter Vigren
Oh, you know the story. Girl meets boy. Girl modifies boy’s sub routines...
|
|
|
Peter_Vigren
Member
Posts: 214
|
|
Re:Wants the RTC to interrupt 1024/s...
« Reply #7 on: 02/19/03 00:55 »
|
|
In Al,70h And Al,10000000b Add Al,0xB Out 70h,Al Jmp short $+2 In Al,71h |
|
This seems to be the best code. It reads the NMI-info, zero all the other bits and add the port wanted etc...
And now back to the RTC... I did mistake the RTC-interrupt (IRQ8)with the timer interrupt (IRQ0) so now it has the speed I like... However, if I do anything else than increasing a counter, the code fails (the RTC-interrupt is called alot of times, and it looks like it doesn't return and then the kernel takes command and the RTC is never called again...)... I wants to test if I should update the clock being displayed and that code worked before, when I used the timer interrupt... well back to coding...
|
Best regards, Peter Vigren
Oh, you know the story. Girl meets boy. Girl modifies boy’s sub routines...
|
|
|
Peter_Vigren
Member
Posts: 214
|
|
Re:Wants the RTC to interrupt 1024/s...
« Reply #8 on: 02/19/03 02:13 »
|
|
I had to comment out a call to a routine but now it works... the clock is updating properly on the screen and the counter as well... Nice.
But I really don't understand why I had to comment out that call...
I commented out this:
Push Eax Push Esi Xor Eax,Eax Mov Al,[LEDCounter] And Al,00000011b Mov Esi,LEDBitmap Add Esi,Eax Inc Al Mov [LEDCounter],Al Call WaitForThe8042_Command Mov Al,0xED Out 0x60,Al Call WaitForThe8042_Command Lodsb Out 0x60,Al Pop Esi Pop Eax |
|
And this is the routine being called:
WaitForThe8042_Command: Push Eax WaitForThe8042_Command_Wait: In Al,0x64 Test Al,00000010b ; Check if the input buffer is full Jnz WaitForThe8042_Command_Wait Pop Eax Ret |
|
I really don't see why it don't like this...
|
Best regards, Peter Vigren
Oh, you know the story. Girl meets boy. Girl modifies boy’s sub routines...
|
|
|
beyond infinity
Member
Posts: 818
|
|
Re:Wants the RTC to interrupt 1024/s...
« Reply #9 on: 02/19/03 08:55 »
|
|
Peter, the code you have commented out: is this keyboard related code? Because of port 0x60 and port 0x64. What do you want to do with the keyboard leds?
command 0xed is as far as i remember to instruct the keyboard controller chip to set the leds. to do this you transmit the led-bitmap after having issued the command successfully.
Why do you want to do this in the rtc-interrupt code?
|
In the harbour they are safe but this is not what the ships are built for. .:OSID:.
|
|
|
Ozgunh82
Member
Posts: 445
|
|
Re:Wants the RTC to interrupt 1024/s...
« Reply #10 on: 02/19/03 09:26 »
|
|
Hi, I did a mistake in code, for discarding lower five bits I should have ANDed with e0h not with 0eh, so correct version is:
in al, 70h ;Get current 70h and al, e0h ;Discard lower 5 bits because we are just allowed to use them or al, 0ah ;Byte index we will get from cmos ram. out 70h, al ;Send index to 70h in al, 71h ;Get needed info from cmos.
|
|
Sorry...
|
|
|
|
Peter_Vigren
Member
Posts: 214
|
|
Re:Wants the RTC to interrupt 1024/s...
« Reply #11 on: 02/19/03 11:09 »
|
|
beyond infinity: Yupp the code is for setting the leds. I thought it would be cool to have flashing leds so I put the code there... I will not have it there later on... I just want to know why it don't work when the code is there so I know what I'm doing wrong...
Ozguxxx: I understood that after struggling with it a while :-) But why only the 5 lower bits and not 7? NMI is enabled/disabled by setting/clearing bit 7...
|
Best regards, Peter Vigren
Oh, you know the story. Girl meets boy. Girl modifies boy’s sub routines...
|
|
|
beyond infinity
Member
Posts: 818
|
|
Re:Wants the RTC to interrupt 1024/s...
« Reply #12 on: 02/19/03 11:46 »
|
|
To tell this, I 'll have to examine the code at home.
One question: what is the lodsb for? Doesn't it suffice to write the bitmap in LEDBitmap to the port to set the led's?
|
In the harbour they are safe but this is not what the ships are built for. .:OSID:.
|
|
|
Peter_Vigren
Member
Posts: 214
|
|
Re:Wants the RTC to interrupt 1024/s...
« Reply #13 on: 02/19/03 12:40 »
|
|
To tell this, I 'll have to examine the code at home.
One question: what is the lodsb for? Doesn't it suffice to write the bitmap in LEDBitmap to the port to set the led's?
|
| That is becuase I use LEDCounter as an index in a string containing four bytes with the appropriate bitmap for the LED. If the counter is zero, the first bitmap is chosen and sent etc...
I designed that routine because I got so tired of having alot of Cmp-commands to test for each possibility and then send the appropriate bitmap.
|
Best regards, Peter Vigren
Oh, you know the story. Girl meets boy. Girl modifies boy’s sub routines...
|
|
|
beyond infinity
Member
Posts: 818
|
|
Re:Wants the RTC to interrupt 1024/s...
« Reply #14 on: 02/19/03 12:57 »
|
|
The idea to scroll throu a set of bitmaps is good.
I also see where you take care that the counter never gets larger than 3. I like those tricks.
these commands: Test Al,00000010b ; Check if the input buffer is full Jnz WaitForThe8042_Command_Wait -> shouldn't it be "JNE waitforthe8042_command"? because you compare for equality? Possible Endless loop?
|
In the harbour they are safe but this is not what the ships are built for. .:OSID:.
|
|
|
Ozgunh82
Member
Posts: 445
|
|
Re:Wants the RTC to interrupt 1024/s...
« Reply #15 on: 02/19/03 17:29 »
|
|
But why only the 5 lower bits and not 7?
|
| Hey thats a good question... But I can only answer second part. Why not 7 bits? Well, since cmos ram only supplies 64 bytes of info, you do not need 7 bits, 6 bits are enough however, all the sources says that only least significant 5 bits of port 0x70 should be used and other bits should be leaved untouched. But in fact 5 bits are not enough to index 64 bytes. I am also confused. So thats the only help I can give for now.
|
|
|
|
Peter_Vigren
Member
Posts: 214
|
|
Re:Wants the RTC to interrupt 1024/s...
« Reply #16 on: 02/19/03 20:17 »
|
|
But why only the 5 lower bits and not 7?
|
| Hey thats a good question... But I can only answer second part. Why not 7 bits? Well, since cmos ram only supplies 64 bytes of info, you do not need 7 bits, 6 bits are enough however, all the sources says that only least significant 5 bits of port 0x70 should be used and other bits should be leaved untouched. But in fact 5 bits are not enough to index 64 bytes. I am also confused. So thats the only help I can give for now.
|
| Not all All sources... HelpPC say that bit 7 and 6 should be left untouched and bit 7 controls the NMI...
|
Best regards, Peter Vigren
Oh, you know the story. Girl meets boy. Girl modifies boy’s sub routines...
|
|
|
Ozgunh82
Member
Posts: 445
|
|
Re:Wants the RTC to interrupt 1024/s...
« Reply #17 on: 02/20/03 14:19 »
|
|
I meant all the sources I checked I think I have mistyped it ... I think you are right I was also confused but in indispensable pc hardware book and in xavier's web site it is done in the way which uses only least significant 5 bits. But helppc says in other way. Can gurus or anybody who is REALLY aware of this stuff help us? Thanx...
|
|
|
|
Peter_Vigren
Member
Posts: 214
|
|
Re:Wants the RTC to interrupt 1024/s...
« Reply #18 on: 02/20/03 20:01 »
|
|
I meant all the sources I checked I think I have mistyped it ... I think you are right I was also confused but in indispensable pc hardware book and in xavier's web site it is done in the way which uses only least significant 5 bits. But helppc says in other way. Can gurus or anybody who is REALLY aware of this stuff help us? Thanx...
|
| The most logical would be that HelpPC is correct. As you yourself stated, all 64 registers can not be accessed using only 5 bits.
|
Best regards, Peter Vigren
Oh, you know the story. Girl meets boy. Girl modifies boy’s sub routines...
|
|
|
Pete
Member
Posts: 458
Keep it Simple
|
|
Re:Wants the RTC to interrupt 1024/s...
« Reply #19 on: 02/20/03 20:24 »
|
|
I wasn't aware of having to save the top two bits of 0x70 so I just write the address to the port. This has no obvious problems I've experienced
|
A program is never perfect, unless your B Gates when every program's perfect until the new version is released. ::OSID::
|
|
|
Peter_Vigren
Member
Posts: 214
|
|
Re:Wants the RTC to interrupt 1024/s...
« Reply #20 on: 02/20/03 20:29 »
|
|
I wasn't aware of having to save the top two bits of 0x70 so I just write the address to the port. This has no obvious problems I've experienced
|
| If bit 7 is zero, NMI is disabled. And because it is disabled, you will not experience any NMI-interrupt if it would occur and then it is quite understandable that you haven't had any problems with it :-)
|
Best regards, Peter Vigren
Oh, you know the story. Girl meets boy. Girl modifies boy’s sub routines...
|
|
|
Pete
Member
Posts: 458
Keep it Simple
|
|
Re:Wants the RTC to interrupt 1024/s...
« Reply #21 on: 02/21/03 15:34 »
|
|
NMI - Non Maskable Interrupt. I thought you couldn't mask these. But aren't all exceptions up to 13h or whatever NMIs. Unfortunally I still get these
|
A program is never perfect, unless your B Gates when every program's perfect until the new version is released. ::OSID::
|
|
|
Pype.Clicker
Moderator Member
Posts: 4041
Use the Source!
|
|
Re:Wants the RTC to interrupt 1024/s...
« Reply #22 on: 02/21/03 16:21 »
|
|
You can mask NMI trough port 0x70, but not through IF in eflags, so for a CPU point of view, they aren't maskable -- that's where the name come from (before that port 0x70 was defined).
Exceptions can't be masked, neither with CLI, nor with port 0x70. And there are no reason why NMI could mask it as they are *not* hardware interrupt requests, but internal-raised signals.
You can view the NMI feature as a logic gate that would read the 7th bit of some BIOS register (mapped to IO-port 0x70) and force the IRQ2 (iirc) line to be inactive (never raises an interrupt). Therefore, it couldn't affect the internal CPU exceptions ...
|
May the Source be with You ::OSID::.:QuickLinkz:.:metawb:
|
|
|
|
|
|