Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
05/17/07 09:09
Read: times


 
#139428 - here is a question !!!!
Responding to: ???'s previous message
Jan Waclawek said:
The original _getkey does the following:wait until UART receiver (hardware) signals "character ready" (by setting RI)
reads that character from the receiver
clears the flag
returns the character


is this ?

#include <reg51.h>

char _getkey ()  {
  char c;

  while (!RI);
  c = SBUF;
  RI = 0;
  return (c);
}



You have an interrupt where you scan the keyboard. So, treat this interrupt as the "hardware", let it set a flag "character ready" and store the received (and decoded) character in a global variable.


ok...
it is working....

#define keypad_mask 0x0F  
#define keypad_address (*((unsigned char xdata*)0x8007))

const char code key_table[16] = "123A456B789C*0#D";
unsigned char key;
unsigned char key_lcd;

void ex0_isr (void) interrupt 0
{
	keypad_read();
}

void keypad_read(void)
{
unsigned char keypad_scan;
    key = ((keypad_scan=keypad_address)&keypad_mask);
  	key_lcd = key_table[key];
}

.
.
.
.
	case 7 : goto_xy(17,0); putch_lcd('7'); break;
	case 8 : goto_xy(17,0); putch_lcd('8'); break;
	case 9 : goto_xy(17,0); putch_lcd('9'); break;
	case 10 : goto_xy(17,0); putch_lcd('A'); break;
	case 11 : goto_xy(17,0); putch_lcd('B'); break;
	case 12 : goto_xy(17,0); putch_lcd('C'); break;
.
.
.
.



Then, rewrite getkey, to do absolutely same, but with YOUR flag instead of RI, and with reading the character of said global variable.


here is a question !!!!
in my project is this a "!INT0" ??????
where is i must to place it in the project???
in ISR or another sobrutine????



Note, that you will need to decode some of the keys into CR (ENTER, n, 0x0D, 13, whichever you like).

Now, try this, while having still the original serial output for printf (I assume you already have some serial connection, terminal emulator on PC etc>).

Later, you can replace the putch so that the output will go to LCD rather than the UART.

JW



ok (putchar()orputstringlcd())



List of 29 messages in thread
TopicAuthorDate
writing to XDATA with KEYPAD and displaing on LCD            01/01/70 00:00      
   One step at a time            01/01/70 00:00      
      please..., see good my question...            01/01/70 00:00      
      let\'s make the guesswork, then...            01/01/70 00:00      
         yes..            01/01/70 00:00      
            So where's the problem?            01/01/70 00:00      
               how?            01/01/70 00:00      
                  Links            01/01/70 00:00      
                     i am using a KEIL            01/01/70 00:00      
                        So you're sorted, then!            01/01/70 00:00      
                           .... ok .... but ......            01/01/70 00:00      
                              relevant            01/01/70 00:00      
                                 What is the "working" code?            01/01/70 00:00      
                                    this code is working in my 89c51rd2            01/01/70 00:00      
                                       so do something like...            01/01/70 00:00      
                                          here is a question !!!!            01/01/70 00:00      
                                             Style            01/01/70 00:00      
                                                this is far from...            01/01/70 00:00      
                                                   Style vs Substance            01/01/70 00:00      
                                                      OK I take that one back...            01/01/70 00:00      
                                                         Language-Independent            01/01/70 00:00      
         Here is a typical problem caused by HLL use            01/01/70 00:00      
            When the only tool you have is a hammer            01/01/70 00:00      
               yes, registers mapped into XDATA space ......            01/01/70 00:00      
               Then the entire world looks like a nail ...            01/01/70 00:00      
   XDATA Addresses            01/01/70 00:00      
      u r right..            01/01/70 00:00      
         Fair enough, but...            01/01/70 00:00      
            :-)) u r right...            01/01/70 00:00      

Back to Subject List