我很难从中断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的编译器