??? 03/15/10 19:10 Read: times |
#174165 - Questions Responding to: ???'s previous message |
Munish Kumar said:
void ext_int_0(void) interrupt 0 ;external interrupt 0 { #pragma asm ;SRC directive must be active to use this. clr EA ;disable interrupts jb PS2_DATA, the_end ;start bit must be 0 mov R0, #08 ;bits in a byte counter clr A getbyte: ; look for +ve edge wait_till_clk_high: ;==> while(clock == low); jnb PS2_CLK, wait_till_clk_high ; look for -ve edge wait_till_clk_low: ;==> while(clock == high); jb PS2_CLK, wait_till_clk_low ; little delay mov R1, #8 djnz r1, $ ;reading LSB 20us after -ve edge ; okay go on... mov c, PS2_DATA rrc a ;LSB is clokced in first djnz R0,getbyte ;repeat for whole byte /*----now byte is in ACC----*/ ;we have only 900 us to waste finally: mov R0, write_counter ;i.e. #0x00 movx @R0, A ;save ACC to external RAM (8-bit addr) inc write_counter mov A, write_counter xrl A, #200 ;write_counter: 0-199 are valid jz pwned ;clear write_counter if = 200 ajmp wait ;else exit ISR pwned: mov write_counter,#0 ;clear write_counter wait: mov R1, #200 ;waste ~400us to allow the parity & stop bits to pass... djnz R1, $ ;MUST WASTE MIN 224us mov R1, #200 djnz R1, $ the_end: setb EA #pragma endasm /*===========================================================*/ ;end of inline ASM };ISR ends 1) Why do you think you need to disable all interrupts? 2) What will happen if you miss a few edges on PS2_CLK? 3) Why must you wait 20us? 4) Why do B and DPTR need to be saved? 5) What happens if the next character comes within 400us? 6) Why do you jump to wait ? |
Topic | Author | Date |
How to control PUSHes & POPs in interrupt? | 01/01/70 00:00 | |
Don't know in Keil but | 01/01/70 00:00 | |
What is the Code in the interupt? | 01/01/70 00:00 | |
Code in Interrupt | 01/01/70 00:00 | |
Once you use ASM, the optimiser gives up | 01/01/70 00:00 | |
OR | 01/01/70 00:00 | |
Questions![]() | 01/01/70 00:00 | |
Use alternate register set... | 01/01/70 00:00 | |
Yes, That's it. | 01/01/70 00:00 | |
Using X | 01/01/70 00:00 | |
Just Remember | 01/01/70 00:00 | |
The cost... | 01/01/70 00:00 |