0 Members and 3 Guests are viewing this topic.
I want to find anything to avoid using IsKeyXX functions, there are really too slow.
void delay( void ){int i; for (i=0;i<5;i++){};}//int CheckKeyRow( int row ){int result=0;short*PORTB_CTRL=(void*)0xA4000102;short*PORTM_CTRL=(void*)0xA4000118;char*PORTB=(void*)0xA4000122;char*PORTM=(void*)0xA4000138;char*PORTA=(void*)0xA4000120;short smask;char cmask; smask = 0x0003 << ((row%8)*2); cmask = ~( 1 << (row%8) ); if (row<8){// configure port B as input, except for the "row to check"-bit, which has to be an output. *PORTB_CTRL = 0xAAAA ^ smask;// configure port M as input; port M is inactive with row < 8 *PORTM_CTRL = (*PORTM_CTRL & 0xFF00 ) | 0x00AA; delay(); *PORTB = cmask; // set the "row to check"-bit to 0 on port B *PORTM = (*PORTM & 0xF0 ) | 0x0F; // port M is inactive with row < 8 }else{ *PORTB_CTRL = 0xAAAA; // configure port B as input; port B is inactive with row >= 8// configure port M as input, except for the "row to check"-bit, which has to be an output. *PORTM_CTRL = ((*PORTM_CTRL & 0xFF00 ) | 0x00AA) ^ smask; delay(); *PORTB = 0xFF; // port B is inactive with row >= 8 (all to 1) *PORTM = (*PORTM & 0xF0 ) | cmask; // set the "row to check"-bit to 0 }; delay(); result = ~(*PORTA); // a pressed key in the row-to-check draws the corresponding bit to 0 delay(); *PORTB_CTRL = 0xAAAA; *PORTM_CTRL = (*PORTM_CTRL & 0xFF00 ) | 0x00AA; delay(); *PORTB_CTRL = 0x5555; *PORTM_CTRL = (*PORTM_CTRL & 0xFF00 ) | 0x0055; delay(); return result;}
Do you mean Prizm key detection in ASM/C is as slow as in BASIC?
No said about the Prgm Syscall! With a friend we could use your function to make function like FastKeyDOwn. But why sometimes the calculator show me an reboot? (On sdk, error FFFFFF8)
Quote from: DJ_O on August 31, 2011, 12:06:28 amDo you mean Prizm key detection in ASM/C is as slow as in BASIC? That particular system call is as slow as its Basic counterpart because that's what the interpreter calls when its running a Basic program. There are other much faster system calls available such as one that will return a buffer full of the keyboard data or even a non system call based one that I developed that works directly with the hardware and is extremely fast.