-2
#include <reg51.h>
#include "_LCD_R8C.c"
#define INPUT_LENGTH 11
char input[INPUT_LENGTH]; /* The input from the serial port */
int input_pos = 0; /* Current position to write in the input buffer */
int main()
{
int i;
lcd_init();
lcd_clear();
SCON = 0x50;
TMOD = 0x20; /* timer 1, mode 2, 8-bit reload */
TH1 = 0xFD; /* reload value for 2400 baud */
TR1 = 1;
TI = 1;
RI = 1;
while (1 == 1)
{
/* read the next character from the serial port */
input[input_pos++] = getCharacter();
/* send it back to the original sender */
for (i = 0; i <= input_pos; i++)
{
lcd_print_b(input[i]);
}
}
}
char getCharacter(void)
{
char chr[INPUT_LENGTH]; /* variable to hold the new character */
while (RI != 1) {;}
chr[input_pos++] = SBUF;
RI = 0;
return (chr);
}
我試圖顯示我從rs232接收到的由rfreader讀取的no。 但我在顯示器上得到了錯誤的值,例如002100而不是0016221826.但是在超級終端上,我得到了準確的正確值,其中包括在$ sattying即$ 0016221826。顯示收到的號碼
固定縮進 – Eregrith
@Lundin我發送的地址,是這樣嗎?請你詳細解釋我 – pradeep
@Lundin我可以使用ms延遲來接收字符嗎? – pradeep