flat assembler
Message board for the users of flat assembler.
Index
> Main > play with lpt IRQ7 |
Author |
|
shoorick 16 Mar 2011, 10:52
theoretically, you can use flip-flop, monostable multivibrator(?) or at least capacitor to avoid chatter of button's contacts. i never played with interrupts, but thought interrupt has to disable hardware interrupts and interrupt processing subroutine must enable it again, maybe i'm wrong. under what OS you are testing that?
i mean if you run it under windows it may enable it by itself so single process will not be able to disable hardware interrupts for whole system. it may be just partially compatible to let printers print normally and protect system from hanging. |
|||
16 Mar 2011, 10:52 |
|
edfed 16 Mar 2011, 11:48
i test under win98 (that is the best for low level asm).
i just have a simple thoery, based on the flipflop. but as i don't wnat to overcomplicate the montage, i will do a software flipflop, using pit ticks counter from bios. when irq7 is fired for the first time (after the last irq7), the routine will set some flag somewhere. if after one tick T of 18.2 Hz pit (i think it is enough) the ack line is down, means it is an interrupt. else, it is not an interrupt, and then, the routine should not be executed. but how to do that. i have all the day to find a way, without modification of irq0, and with the less code inside mainloop. Code: ACK up IRQ7 action IRQ7 no action v v v v ack=0 v v ack=1 ----T----- -----T-----. --------| . /-\ /---------° V /-\ /-\ . | V | | | V | V . | | | \-/ \-/ \-°------------/ \-/ |
|||
16 Mar 2011, 11:48 |
|
shoorick 16 Mar 2011, 13:29
on the first IRQ save current ticks count into var. on the next time compare ticks with that var - the differense is small, then ignore it, otherwise it is the new interrupt - save new ticks count and process IRQ.
|
|||
16 Mar 2011, 13:29 |
|
edfed 16 Mar 2011, 14:07
the problem is with the switch release, as it will launch the same process as switch hold, i think i will be forced to use IRQ0 as a IRQ7 tester.
if IRQ7 is fired, it pass a function pointer to IRQ0. IRQ0 will wait a little time before to test the ack line, and if the ack line is clear, it is a IRQ7, ifg the ack line is set, it is not a IRQ7. but it will limit the action to one or two instruction (set or increment a flag), in order to don't use a lot of irq0 time. ones i will have a good technique for switch handling, i will be able to do it on PIC12F675, using timer. |
|||
16 Mar 2011, 14:07 |
|
shoorick 16 Mar 2011, 14:31
isn't 7400 enough?
_________________ UNICODE forever! |
||||||||||
16 Mar 2011, 14:31 |
|
edfed 16 Mar 2011, 18:34
no hardware.
just software. the hardware should be the less possible. just the switch as shown in the original post, due to some economicotechnical constraint. and then, it is done. very easy in fact. Code: org 100h push 0b800h pop es mov di,0 mov dx,37Ah in al,dx or al,10h and al,not 1 out dx,al cli mov ax,0 mov fs,ax mov eax,[fs:8*4] mov [irq0.old],eax mov word[fs:15*4],irq7 mov word[fs:8*4],irq0 mov ax,cs mov word[fs:15*4+2],ax mov word[fs:8*4+2],ax in al,21h and al,not 81h out 21h,al sti ;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@: mov al,byte[ticks] call b2h mov [es:di],al mov [es:di+2],ah cmp [ticks],100 jb @b mov al,0ffh mov dx,378h out dx,al ret ;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;; irq0: inc [.ticks] cmp [.func],0 je @f call near word[.func] @@: jmp far dword[.old] align 4 .ticks dd 0 .old dd 0 .func dw 0 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;; irq7: cmp [irq0.func],.fire je @f mov [.ticks],1 mov [irq0.func],.fire @@: mov al,20h out 20h,al iret .value db 1 .ticks db 0 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;; .fire: dec [.ticks] je @f ret @@: mov dx,379h in al,dx test al,40h jne @f inc [ticks] mov dx,378h mov al,[.value] out dx,al rol [.value],1 @@: mov [irq0.func],0 ret ;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ticks db 0 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;; include 'b2h.inc' the old IRQ0 handler is still called (jmp) and then, no problem with BIOS compatibility. i like this way to do because it is something like... simple and efficient. just wait one tick of the 18.2Hz pit, and then, read back the value of ACK bit on LPT port. if this bit is clear, IRQ7, if not, noting. and it works fine now. i've tryed with a frequency reprog.. and it don't bring any benefit, just takes more instructions to program the pit frequency. then, i adopt this code. sorry for the useage of IRQ0... but, it is there, not only for the bios, but to be used by applications. about the 7400 shematic, it is cool, but in what application i want to do, it is too much, i should do something with the les components as possible. i still should put a quartz clock because for the application, i need a precise timing (motor cycle shift light), and for the button, i need something really simple, just to program the shiftlight to a given rotation speed/2. or do it manually by a sequence of clicks. for example: 1 long click (1 or 2 second), put the device in programming mode, led on 5 fast clicks means shift light at 5000rpm, each click makes the led blink one or 2 times. 1 long click means programming done led blinking 5 times to show it is well programmed. and lets go for the circuit session. on the pic, there are some input schmit triggered, then, just a pull up resistor would be enough.. |
|||
16 Mar 2011, 18:34 |
|
shoorick 17 Mar 2011, 05:50
well, let's what it will be than
|
|||
17 Mar 2011, 05:50 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.