绝对是在Keil C编译连接时产生的。
这个main()程序是基于uC/OS II的,有点长,其他的源代码不好贴上。
#include "includes.h"
#include "os_kcdef.h"
#include "lcd.h"
#define TASK_STK_SIZE 64 /* Size of each task's stacks
(# of WORDs) */
OS_STK TaskStartStk[TASK_STK_SIZE];
OS_STK LcdWrStk[TASK_STK_SIZE];
OS_EVENT *Semaphore;
void LcdInit(void) KCREENTRANT;
void lcd_wr_count(void) KCREENTRANT;
void TaskStart(void *vdata) KCREENTRANT; /* Function prototypes of
Startup task */
void LcdWr(void *lcdwr) KCREENTRANT;
void lcd_wr(uchar *p) KCREENTRANT;
/*******************************************************************************
* MAIN
******************************************************************************/
void main (void)
{
OSInit(); /* Initialize uC/OS-
II */
LcdInit();
Semaphore = OSSemCreate(0);
OSTaskCreate(TaskStart, (void *)0, (void *)&TaskStartStk
[TASK_STK_SIZE - 1], 1);
OSTaskCreate(LcdWr, (void *)0, (void *)&LcdWrStk[TASK_STK_SIZE - 1], 0);
OSStart(); /* Start
multitasking */
}
/*$PAGE*/
/*
*******************************************************************************
* STARTUP TASK
******************************************************************************/
extern unsigned char data OSTickRate;
void TaskStart(void *vdata) KCREENTRANT
{
INT8U count = 0,i;
vdata = vdata; /* Prevent
compiler warning */
/* Modification for KC51, set up timer 0 and start it*/
TMOD=(TMOD & 0XF0) | 0X02;
/* Timer 0 working in MODE 1 */
TL0=0x00;
/*
11059200/12/256=3600, timer 1's overflow frequency */
TH0=0x00;
TR0=1;
ET0=1;
EA =1;
OSTickRate=144;
/* 3600/144=25,
system intr switch freq */
/* End kc51 modification*/
OSStatInit();
for(i=0;i<4;i++)
{
count++;
OSTimeDlyHMSM(0,0,1,0);
P17 = 0;
OSTimeDlyHMSM(0,0,1,0);
P17 = 1;
if (count == 4)
{
OSSemPost(Semaphore);
}
}
}
/*$PAGE*/
/*******************************************************************************
*
* TASKS
******************************************************************************/
void LcdWr(void *lcdwr) KCREENTRANT
{
BYTE err;
lcdwr = lcdwr;
OSSemPend(Semaphore,0,&err);
P16 = 0;
for(;;) lcd_wr(d);
}
/*连续写程序*/
void lcd_wr(uchar *p) KCREENTRANT
{
uchar counti,t;
cs=0;
flags=0xa0; /*10100000*/
countk=4;
lcd_wr_count();
flags=0x00; /*00000000*/
countk=5;
lcd_wr_count(); /*连续写数据,开始地址(000000) 101,000000*/
for(counti=0;counti<8;counti++)
{
t=*(p+7-counti); /*取要显示的内容,找到对应的地址写入至液晶*/
t=t*2;
flags=display_data[t];
countk=4;
lcd_wr_count();
flags=display_data[t+1];
countk=8;
lcd_wr_count();
}
cs=1;
}
/* lcd初始化 */
void LcdInit(void) KCREENTRANT
{
cs=0;
flags=0x80; /*10000000*/
countk=4;
lcd_wr_count();
flags=0x60; /*01100000*/
countk=8;
lcd_wr_count(); /*送COOM命令 1000,0011,0000*/
cs=1;
cs=0;
flags=0x80; /*10000000*/
countk=4;
lcd_wr_count();
flags=0x30; /*00110000*/
countk=8;
lcd_wr_count(); /*送RC命令 1000,0011,0000*/
cs=1;
cs=0;
flags=0x80; /*10000000*/
countk=4;
lcd_wr_count();
flags=0x02; /*00000010*/
countk=8;
lcd_wr_count(); /*送SYS EN命令 1000,0000,0010*/
cs=1;
cs=0;
flags=0x80; /*10000000*/
countk=4;
lcd_wr_count();
flags=0x06; /*00000110*/
countk=8;
lcd_wr_count(); /*送LED ON命令 1000,0000,0110*/
cs=1;
}
/*写程序*/
void lcd_wr_count(void) KCREENTRANT
{
for(countj=0; countj<countk; countj++)
{
da=0;
wr=0;
if(flags7==1)
{da=1;}
wr=1;
flags<<=1;
}
}
发表时间:2002年5月31日11:43:00