我有点难以从中断 4 函数中获取字符串。但是当我尝试获取单个字符并在 LCD 2*16 中显示时效果很好。但是当我尝试从“dot[i]”变量中获取字符串以显示给 LCD 时,它不起作用。
这是我的代码:
void Init_SerialT2()
{
//timer 2 Osilator 12 MHz
SetTRCLK(1,1); /*using for send and receive function*/
SM0 = 0;
SM1 = 1; /* register serial control mode1 = 8 bit UART*/
TH2 = 0x5;
TL2 = 0x124;
//TH2=0x03;
//TL2=0x03;
RCAP2H = 0xff; /*RCAP2 0xffd9 baut rate 9600 at F osilator 12Mhz*/
RCAP2L = 0xd9;
C_T2 = 0; /* using As timer function*/
REN = 1; /* Receive enable*/
TR2 = 1; /* Timer 2 start*/
}
volatile unsigned char RX_IN_CHR_UART[16]; // global var
void Interrupt_TerimaChar() interrupt 4
{
volatile unsigned int i =0;
volatile unsigned char ch;
volatile unsigned char *dor;
TI=0;
if(RI)
{
ch = SBUF;
RI =0;
for(i=0;i<RX_IN_CHR_UART[i];i++)
{
RX_IN_CHR_UART[i] = ch; // save character int array
dor[i]= RX_IN_CHR_UART[i];
}
LCD_command(0x86);
//LCD_senddata(ch); // test to get char it's works
LCD_sendstring(dor);
ES =1;
}
}
对于我使用 Keil v4 的编译器