| ??? 06/28/06 19:46 Read: times |
#119285 - some code Responding to: ???'s previous message |
Here's some of the code. I omitted some stuff and put ... in its place.
The application is a PS/2 proxy. It is a man in the middle between a keyboard and a computer. Its job is to intercept key combinations and perform macros and things like that. The computer tells the keyboard it has some data to send by doing a procedure I call the dance. pc_clk_isr validates this dance. If the procedure was done to pc_clk_isr's satisfaction, pc_clk_isr turns on TR0. t0_isr's job is to come back every 30usec or so and clock and receive bits from the computer. In the course of editing the code to post it, I noticed there's a bug in t0_isr in that it always turns TR0 back on when it leaves. It's a mistake; it shouldn't *always* turn TR0 back on. It should stop after the entire byte is received. But it doesn't seem relevant, because I know from setting LEDs (code omitted here) that t0_isr is never entered. Thanks for looking. Hopefully it's a dumb simple error because it's my first project.
pc_clk equ INT0
pc_data equ T0
kbd_clk equ INT1
kbd_data equ RD
interrupt_on_pc_clk equ EX0
interrupt_on_kbd_clk equ EX1
kbd_work_byte equ 8
kbd_num_bits equ 9
pc_work_byte equ 0xa
pc_num_bits equ 0xb
kbd_buf_read_index equ 0xc
kbd_buf_write_index equ 0xd
pc_buf_read_index equ 0xe
pc_buf_write_index equ 0xf
kbd_buf equ 0x10
pc_buf equ 0x18
previous_was_left_shift equ 0
previous_was_right_shift equ 1
previous_was_0xf0 equ 2
previous_was_0xed equ 3
translate equ 4
kbd_buf_is_empty equ 5
pc_buf_is_empty equ 6
receiving_from_kbd equ 7
receiving_from_pc equ 8
; - - - - - - - -
org 0
sjmp start
org 3
ljmp pc_clk_isr
org 0xb
ljmp t0_isr
org 0x13
ljmp kbd_clk_isr
; - - - - - - - -
start:
mov kbd_work_byte, #0
mov kbd_num_bits, #0
mov pc_work_byte, #0
mov pc_num_bits, #0
mov kbd_buf_read_index, #0
mov kbd_buf_write_index, #0
mov pc_buf_read_index, #0
mov pc_buf_write_index, #0
mov 0x20, #0
mov 0x21, #0
mov SP, #0x21
mov DPTR, #table
mov TMOD, 00000010b
mov TH0, #-30
setb kbd_buf_is_empty
setb pc_buf_is_empty
setb interrupt_on_pc_clk
setb IT0
setb interrupt_on_kbd_clk
setb IT1
setb ET0
setb EA
clr P3.5 ; power up the keyboard
...
; - - - - - - - -
pc_clk_isr:
push PSW
push 0
...
setb TR0
setb receiving_from_pc
mov pc_num_bits, #0
pci_exit:
pop 0
pop PSW
reti
; - - - - - - - -
t0_isr:
clr TR0
clr interrupt_on_pc_clk
push PSW
push ACC
push 0
...
; at this point the byte received is in pc_work_byte
clr TR0
mov pc_num_bits, #0
clr receiving_from_pc
...
t0i_exit:
pop 0
pop ACC
pop PSW
setb interrupt_on_pc_clk
setb TR0
reti
; - - - - - - - -
end
|
| Topic | Author | Date |
| timer0 problem | 01/01/70 00:00 | |
| LEDs and the eye | 01/01/70 00:00 | |
| I never turn it off | 01/01/70 00:00 | |
| use simulator | 01/01/70 00:00 | |
| what's in IE | 01/01/70 00:00 | |
| IE | 01/01/70 00:00 | |
| with reti, not ret? | 01/01/70 00:00 | |
| yes, reti. I know why ret would screw up | 01/01/70 00:00 | |
| time to show the formatted and commented | 01/01/70 00:00 | |
| I will work on cutting it down | 01/01/70 00:00 | |
| easy | 01/01/70 00:00 | |
| Timer O ISR | 01/01/70 00:00 | |
| addition | 01/01/70 00:00 | |
| that's good thinking | 01/01/70 00:00 | |
| enough guesses | 01/01/70 00:00 | |
| some code | 01/01/70 00:00 | |
| comments which you do not have | 01/01/70 00:00 | |
| re | 01/01/70 00:00 | |
| there is no such thing | 01/01/70 00:00 | |
| re | 01/01/70 00:00 | |
| EDT | 01/01/70 00:00 | |
| if you want get help... | 01/01/70 00:00 | |
| he can't do that | 01/01/70 00:00 | |
| ???splitting | 01/01/70 00:00 | |
if you look at me, you will know :) | 01/01/70 00:00 |



