下面是代码:望大神指点,谢谢了
void USART1_IRQHandler(void) //´®¿Ú1ÖжϷþÎñ³ÌÐò
{
u16 i,Res;
#ifdef OS_
tiCKS_PER_SEC //Èç¹ûʱÖÓ½ÚÅÄÊý¶¨ÒåÁË,˵Ã÷ҪʹÓÃucosIIÁË.
OSIntEnter();
#endif
if(USART_GetITStatus(USART1, USART_IT_RXNE) != RESET) //½ÓÊÕÖжÏ(½ÓÊÕµ½µÄÊý¾Ý±ØÐëÊÇ0x0d 0x0a½áβ)
{
USART_ClearITPendingBit(USART1, USART_IT_RXNE);
USART_RX_BUF[i]=USART_ReceiveData(USART1);//(USART1->DR); //¶ÁÈ¡½ÓÊÕµ½µÄÊý¾Ý
USART_SendData(USART1,USART_RX_BUF[i]);
// write_pos(3,i);
//write_data(USART_ReceiveData(USART1));
//i++
/* if((USART_RX_STA&0x8000)==0)//½ÓÊÕδÍê³É
{
if(USART_RX_STA&0x4000)//½ÓÊÕµ½ÁË0x0d
{
if(Res!=0x0a)USART_RX_STA=0;//½ÓÊÕ´íÎó,ÖØпªÊ¼
else USART_RX_STA|=0x8000; //½ÓÊÕÍê³ÉÁË
}
else //»¹Ã»ÊÕµ½0X0D
{
if(Res==0x0d)USART_RX_STA|=0x4000;
else
{
USART_RX_BUF[USART_RX_STA&0X3FFF]=Res ;
USART_RX_STA++;
if(USART_RX_STA>(USART_REC_LEN-1))USART_RX_STA=0;//½ÓÊÕÊý¾Ý´íÎó,ÖØпªÊ¼½ÓÊÕ
}
}
} */
}
#ifdef OS_TICKS_PER_SEC //Èç¹ûʱÖÓ½ÚÅÄÊý¶¨ÒåÁË,˵Ã÷ҪʹÓÃucosIIÁË.
OSIntExit();
#endif
}
#endif
void busy_search(void)//
{
GPIO_InitTypeDef GPIO_InitStructure;
GPIO_InitStructure.GPIO_Pin=GPIO_Pin_All;
GPIO_InitStructure.GPIO_Mode=GPIO_Mode_IN_FLOATING;
GPIO_Init(GPIOF,&GPIO_InitStructure);
reset_rs;
set_rw;
reset_en;
//Delay(5);
set_en;
// Delay(25);
while(GPIO_ReadInputDataBit(GPIOF,GPIO_Pin_15)==1);
reset_en;
GPIO_InitStructure.GPIO_Pin=GPIO_Pin_All;
GPIO_InitStructure.GPIO_Mode=GPIO_Mode_Out_PP;
GPIO_InitStructure.GPIO_Speed=GPIO_Speed_50MHz;
GPIO_Init(GPIOF,&GPIO_InitStructure);
}
void write_cmd(uchar cmd)//????? cmd??????
{
busy_search();
reset_rs;
reset_rw;
reset_en;
GPIO_Write(GPIOF,(0xff00&(cmd<<8)));
delay_us(5);
set_en;
delay_us(5);
reset_en;
}
void write_data(u16 dat)//?????, dat??????
{
busy_search();
set_rs;
reset_rw;
reset_en;
GPIO_Write(GPIOF,(0xff00&(dat<<8)));
delay_us(5);
set_en;
delay_us(5);
reset_en;
}
void lcd12864_Config()//?????
{
write_cmd(0x30);
write_cmd(0x0c);
write_cmd(0x01);
}
void write_pos(uchar x,uchar y)
{
uchar pos;
if(x==0)
{
x=0x80;
}
if(x==1)
{
x=0x90;
}
if(x==2)
{
x=0x88;
}
if(x==3)
{
x=0x98;
}
pos=x+y;
write_cmd(pos);
}
#include "usart.h"
#include "gpio.h"
#include "lcd12864.h"
#include "sys.h"
char str1[]={"µ±Ç°É豸:"};
char str2[]={"¹¤×÷״̬: Òì³£"};
char str3[]={"Ä¿±êÊý¾Ý: 99 99"};
char *str4;
int a=0x05;
int num,i,j,len,t;
int main(void )
{
gpio_init();//IO¿Ú³õʼ»¯
uart_init(9600);//´®¿Ú³õʼ»¯º¯Êý
delay_init();//ÑÓʱº¯Êý³õʼ»¯
lcd12864_Config();//Òº¾§³õʼ»¯º¯Êý
write_pos(0,0);//д×ø±ê£¬µÚÒ»ÐУ¬µÚÒ»¸ö
num=0;
while(str1[num]!='