⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 78f0411_waterdemo.c.bak

📁 nec 78F0413的例子程序,里面有LCD
💻 BAK
字号:
#pragma SFR
#pragma DI
#pragma EI
#pragma NOP
#pragma asm
#pragma access
#pragma HALT
#pragma STOP


//#pragma interrupt INTTM000 time_sec
//#pragma interrupt INTAD adc_con_operate
//#pragma interrupt INTP2 ext_key_operate
//#pragma interrupt INTRTC rtc_operate


/*******************************lcd display value**********************/
#define   _a    0x10          
#define   _b    0x20 
#define   _c    0x40 
#define   _d    0x08 
#define   _e    0x04 
#define   _g    0x02
#define   _f    0x01 
const unsigned char distable[16]={  _a+_b+_c+_d+_e+_f+00, //0
	                                00+_b+_c+00+00+00+00,   //1
	                                _a+_b+00+_d+_e+00+_g,   //2
	                                _a+_b+_c+_d+00+00+_g,   //3
	                                00+_b+_c+00+00+_f+_g,   //4
	                                _a+00+_c+_d+00+_f+_g,   //5
	                                _a+00+_c+_d+_e+_f+_g,   //6
	                                _a+_b+_c+00+00+00+00,   //7
	                                _a+_b+_c+_d+_e+_f+_g,   //8
	                                _a+_b+_c+_d+00+_f+_g,   //9
	                                _a+_b+_c+00+_e+_f+_g,   //a
	                                00+00+_c+_d+_e+_f+_g,   //b
	                                00+00+00+_d+_e+00+_g,   //c
	                                00+_b+_c+_d+_e+00+_g,   //d
	                                _a+00+00+_d+_e+_f+_g,   //e
	                                _a+00+00+00+_e+_f+_g    //f
	                               }; //0~F table        

__directmap  unsigned char  SEG0 =0xFA40;    
__directmap  unsigned char  SEG1 =0xFA41;
__directmap  unsigned char  SEG2 =0xFA42;
__directmap  unsigned char  SEG3 =0xFA43;
__directmap  unsigned char  SEG4 =0xFA44;
__directmap  unsigned char  SEG5 =0xFA45;
__directmap  unsigned char  SEG6 =0xFA48;
__directmap  unsigned char  SEG7 =0xFA49;
__directmap  unsigned char  SEG8 =0xFA4A;
__directmap  unsigned char  SEG9 =0xFA4B;
__directmap  unsigned char  SEG10=0xFA4C;
__directmap  unsigned char  SEG11=0xFA4D;
__directmap  unsigned char  SEG12=0xFA4E;
__directmap  unsigned char  SEG13=0xFA4F;
__directmap  unsigned char  SEG14=0xFA51;
__directmap  unsigned char  SEG15=0xFA52;
__directmap  unsigned char  SEG16=0xFA53;

/***************************option byte************************/
#pragma  section  @@CNST OPT_SET AT 0080H
const char OPTION1 = 0x7E;
const char OPTION2 = 0x00;  //1.59V
const char OPTION3 = 0x00;                     
const char OPTION4 = 0x00;                     
const char OPTION5 = 0x03;  //enable debug

/**************************fuction list************************/
void init_sub_clock(void);
void init_port(void);
void init_rtc(void);
void init_lcd(void);
void init_total(void);
void display(void);
/**************************RAM define**************************/
unsigned char ms_cou,disbuff[10];
bit flag_sec;
sreg unsigned char light;
/*******************************initialization*****************/
void init_sub_clock(void)
{	
	OSCCTL=0x10;    //x1,x2 for port,32768 connect	
	
  WDTE=0XAC;
	CSS=1;				//F=fsub/2
	while(!CLS);
	RSTOP=1;				//STOP intrnal osc
}


void init_port(void)
{WDTE=0XAC;
	PM2.1=0;P2.1=0;	      //LED3
	PM2.0=0;P2.0=0;				//LED2
	PM3.1=0;P3.1=0;				//LED1
	PM3.4=0;P3.4=1;				//LED0 RTC1HZ
	PM3.2=0;P3.2=0;							//TOH0 output
	PM2.5=1;							//A/D  input
	PM3.3=1;							//INTP2
} 

void init_rtc(void)
{WDTE=0XAC;
	RTCE=0;						//stop count
	RTCCL=0x00;				//32768HZ
	RTCC0=0x2A;				//output 1HZ,1s interrupt
	RTCIF=0;
	RTCMK=0;
	RTCE=1;	
}

void init_lcd(void)
{WDTE=0XAC;
	LCDMD=0x00;							//External resistance division method 
	LCDM=0x40;							//4 times 1/3 bias
	LCDC0=0x03;							//Flcd=32768/2^7=256HZ
	PF2=0B00011100;					//0.0.PF25.PF24.PF23.PF22.PF21.PF20
	PFALL=0B01100100;				//0.PF15ALL.PF14ALL.0.PF11ALL.PF10ALL.0.0
	LCDON=1;
}

void init_total(void)
		{
			OSCCTL=0x10;    //x1,x2 for port,32768 connect	
			init_port();
			init_rtc();
			init_lcd();
			
			
			IMS=0xC8;
		}
/************************************administer*******************************/
void display(void)
		{
			unsigned char *s,i,m,n;
			
			s=&SEG0;
			for (m=0;m<16;m++)
					{	
						n=distable[m];
						
						disbuff[m]=n;
           
          }	


     
		   WDTE=0xAC;				
			for(i=0;i<4;i++)
	  			{
	  				n=disbuff[i]>>4;
	  			
	  				s[i<<1]=n;
	  				
	  				n=disbuff[i]&0xf;
	  				
	    			s[(i<<1)+1]=n;
	    			 
	  			}
     
		WDTE=0XAC;
		}
/***************************************main************************************/
void main ()
{	
	DI();
	init_total();
	EI();		
	display();
	init_sub_clock();
	while(1)
		{WDTE=0xAC;
//			display();
			NOP();NOP();NOP();NOP();NOP();NOP();
			NOP();NOP();NOP();NOP();NOP();NOP();NOP();
			NOP();NOP();NOP();NOP();NOP();NOP();
			WDTE=0xAC;
		}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -