??? 12/23/05 06:02 Modified: 12/23/05 06:12 Read: times |
#105810 - Getkey Responding to: ???'s previous message |
Ruksen Inanir said:
i am writing some code using i2c in keil c51 and emulating it using mon51.
here is the problem; keil says that;"The _getkey function waits for a character to be received from the serial port." but when i start the program which contains M=_getkey(); it does not wait for the user to input a key, and executes next instruction and prints a char to serial window of keil like | which is 0x11 (device control). What about I2C? Are you confused with I2C and Serial communication using UART? If yes, then there is problem. Have you set the SCON properly? What baudrate are you using? Which timer you are using for baudrate generation? Ruksen Inanir said:
does anyone know how _getkey actually works? You must see the generated code in Disassembly window under the View menu option. It looks like this. C:0x0024----3098FD---JNB------RI(0x98.0),GETKEY(C:0024) C:0x0027----AF99-----MOV------R7,SBUF(0x99) C:0x0029----C298-----CLR------RI(0x98.0) C:0x002B----7E00-----MOV------R6,#0x00 C:0x002D----22-------RET So from above, it is clear that it waits for the character to be received. See JNB RI. Here is my code and it works just fine. // Set timer T1 as 8 bit auto reload and set the baud rate as //9600 using 11.0592MHz crystal. Set SCON as 8 bit UART, receive enable. #include <REGX51.H> #include<stdio.h> unsigned char M; void main() { SCON = 0X50; TMOD = 0X02; TH0 = 0XFD; TL0 = 0XFD; TR0 = 1; M = getkey(); while(1); } Regards Sarang |
Topic | Author | Date |
_getkey() does not wait the user to .. | 01/01/70 00:00 | |
intser2.c ? | 01/01/70 00:00 | |
serial interrupt 2 | 01/01/70 00:00 | |
See for yourself | 01/01/70 00:00 | |
problem is different | 01/01/70 00:00 | |
is this the solution? | 01/01/70 00:00 | |
Getkey | 01/01/70 00:00 | |
Serial communication | 01/01/70 00:00 | |
i use both i2c and uart | 01/01/70 00:00 | |
here is the answer![]() | 01/01/70 00:00 |