main.c.bak

来自「该程序是NECupd78F9479的开发的代LCD的空调方案」· BAK 代码 · 共 559 行 · 第 1/2 页

BAK
559
字号
/*
========================================================================================================
Project: Gree appliance,Mobile Aircon.
Chip: uPD78F9479 NECEL
Agent: Easytouch,Shenzhen office 
Specification of Schematic diagram:
Author:Easytouch
========================================================================================================			
																	________________________________________________
																 |																								|
						NC								 --|1																			P50			80|--				SCL
						NC								 --|2																			P51			79|--				SDA
						VLC2							 --|3																			P52			78|--				NC
						VLC1							 --|4																			P53			77|--				NC
						VLC0							 --|5																			P54			76|--				RST
						COM0							 --|6									NEC													75|--				X2
						COM1							 --|7							uPD78F9479											74|--				X1
						COM2							 --|8																							73|--				Vss
						COM3							 --|9																							72|--				Vdd
						S0-O							 --|10																						71|--				XT2
						S1-O							 --|11																						70|--				XT1
						S2-O							 --|12																		IC0			69|--				Vpp
						S3-O							 --|13																		P00			68|--				HI FAN
						S4-O							 --|14																		P01			67|--				MID FAN
						S5-O							 --|15																		P02			66|--				LOW FAN
						S6-O							 --|16																		P03			65|--				SUP FAN
						S7-O							 --|17																		P04			64|--				PUMP-I
						S8-O							 --|18																		P05			63|--				PUMP-O
						S9-O							 --|19																		P06			62|--				PTC
						S10-O							 --|20																		P07			61|--				ASC SWING
						S11-O							 --|21																		P10			60|--				4V
						S12-O							 --|22																		P11			59|--				outfan
						S13-O							 --|23																		P20			58|--				compctrl
						S14-O							 --|24																		P21			57|--				Backlight2
						S15-O							 --|25																		P22			56|--				Backlight1
					Cool/Hot_sel				 --|26		P70															P23			55|--				Key outC
					Moblie/split_sel		 --|27		P71															P24			54|--				Key outB
					Dome/Oversea_sel		 --|28		P72															P25			53|--				Key outA
						1.5P/1P_sel				 --|29		P73								P30/INTP0/TO50/TMI60	52|--				remoter
						quicktest					 --|30		P80								P31/INTP1/TO60				51|--				Buzzer
						Swing_1						 --|31		P81								P32/INTP2/TMI61/TO61	50|--				Key inC
						Swing_2						 --|32		P82								P33/INTP3/CPT20/TO20	49|--				Key inB
						Swing_3						 --|33		P83													P34					48|--				Key inA
						Swing_4						 --|34		P84																			47|--				AVss
						Hi_wot_pos				 --|35		P85														P60/ANI0	46|--				NC
						Low_wot_pos				 --|36		P86														P61/ANI1	45|--				currentvalue
						NC								 --|37		P87														P62/ANI2	44|--				outcoiltemp
						VDD								 --|38																	P63/ANI3	43|--				outtemp
							NC							 --|39		P67/ANI7											P64/ANI4	42|--				incoiltemp
							NC							 --|40		P66/ANI6											P65/ANI5	41|--				roomtemp
															 	 |________________________________________________|
			
			
========================================================================================================
*/

#pragma DI
#pragma EI
#pragma NOP
#pragma asm
#include "define.h"

void ADintit0(void);
void TYPEsel(void);
void BEEP1tms(void);
void Buzz(void);   
void ADcvrt(void); 
void Keyctrl(void);
void modctrl(void);
void Slp(void);    
void Stm(void);    
void Fanctrl(void);
void swing(void);
void Rmtdec(void);
void Dspctrl(void);
void I2C_Get(void);
void I2C_Sent(void);
void Tmctrl(void);
void DATAIni(void);
void Watchdog(void);
/*
===========================================================================
*/
sreg unsigned char V_flag;
#define f_temp				V_flag.0
#define f_quick       V_flag.1
#define f_mode        V_flag.2
#define f_COOLonly    V_flag.3
#define f_capa        V_flag.4
#define f_SLPIN				V_flag.5
extern unsigned char M_FANset,M_MODset;
/*
===========================================================================
*/
void hdwinit()
{
	
/*wait for OSC Stable						*/
/*====================================================================*/
	unsigned char C_OSCstab=0;
	while(C_OSCstab<=200)
				C_OSCstab++;
/*====================================================================*/


 
 /*Clock Generator*/
 /*===================================================================*/
 	PCC=0b00000000;
 /*		  ||||||||________________NU
 			  |||||||_________________Cpu clock selection	Fcpu=Fx/y ,y--->divider
 			  ||||||__________________NU
 			  |_______________________main clock operation enable control				0------>enable
 */
 	SCKM=0b00000000;
 /*			 ||||||||_____________________SCC Subclock operation enable control					0------>enalbe
 				 |||||||______________________FRC On chip feedback use selection control   0---->use
 */
 	CSS=0b00000000;
 /*			||||||||______________________NU	
 				||||__________________________output to device from main / sub clock selection    0------->main clock 1------->subclock
 				|||___________________________CLS	cup opration status			0------>cpu opration based on mainclock  1------>based on subclock
 */	
 
 	SSCK=0b00000000;
 /*			 ||||||||________________________Clock multiplication X 4 selection 0----->disable 
 				 |||||||_________________________NU
 */	
 /*===================================================================*/
 
 /*
 =================================================================================
 16 bit counter initiation
 =================================================================================
 */

 CR20=0xFF;	//		
 TMC20=0b00000000;
 /*			||||||||____________________________TOE20 output TO PORT control 0------>disable
 				|||||||_____________________________Selection of count clock for 16-bit timer counter 20
 				|||||_______________________________Timer output data inversion control	0------->inversion disable
 				||||________________________________Selection of capture edge 00--->capture disable 01--->rise 10--->fall 11---->both
 				||__________________________________Set overflow flag 0---->Reset and clear by software 1----->Set by overflow of 16-bit timer
 				|___________________________________Timer output data 0 or 1
 				
 ===============================================================================
 */
 
 
 /*
 ==========================================================================
 TIMER 60 Initiation 
 TM60 is used for remote singnal capture 
 ==========================================================================
 */
PM3.1=0;
TCE60=0;
TMC60=0b00001000;
 /*		  ||||||||_______________________Control of timer output		0--->Disable
 				|||||||
 				|||||||________________________Selection of operation mode for timer 60   00--->alone mode
 				|||||
 				|||||
 				|||||_________________________Selection of timer 60 count clock
 				||____________________________NU
 				|_____________________________Control of TM60 count operation 1---->START
 				
 */
//TOE600=1;
CR60=250;			// 4k for buzzer
TCE60=1;

TCA60=0x00;  /*NO USE
 
 /*
 =================================================================================
 
 
 ==========================================================================
 TIMER 61 Initiation 
 TM61 is used for remote singnal capture 
 ==========================================================================
 */
 CR61=0xff;			// for INTERRUPT 1 MS
 TMC61=0b10001000;
 /*		  ||||||||_______________________Control of timer output		0--->Disable
 				|||||||
 				|||||||________________________Selection of operation mode for timer 61   00--->alone mode
 				|||||
 				|||||
 				|||||_________________________Selection of timer 61 count clock
 				||____________________________NU
 				|_____________________________Control of TM61 count operation 1---->START
 				
 */
 //TCA61=0x00;  /*NO USE
 
 /*
 =================================================================================
 TM50 is used for buzz ,in PWM mode
 =================================================================================
 */
 CR50=255;			//
 TMC50=0b00010000;
 /*		  ||||||||_______________________Control of timer output		0--->Disable
 				|||||||
 				|||||||________________________Selection of operation mode for timer 50   00--->alone mode
 				|||||
 				|||||
 				|||||_________________________Selection of timer 50 count clock		USE Fx/128
 				||____________________________Selection of valid edge of TM50 count clock 0-->rise 1-->both
 				|_____________________________Control of TM50 count operation 1---->START
 				
 */
 
 
 TCE50=1;			//TM50 START COUNTE


 
 
 
 
 /*
 =========================================================================================
 AD Convert initiation		use access style
 =========================================================================================
 */
 
ADML0=0b00001001;
 /*			||||||||_______________________________________Control of band-gap circuit (ADCE0)
 				|||||||
 				|||||||________________________________________00 no use
 				||||||
 				||||||
 				||||||_________________________________________A/D conversion time selection 120/Fx
 				||_____________________________________________no use
 				|______________________________________________A/D conversion control 1---->start conversion(ADCS0)
 */
 ADML1=0;
 
 ADS0=0b00000001;//Analog input channel specification
 
 
 /*
 ==============================================================================================
 */
 
 
 

/*
================================================================================================
LCD Controller/Driver Configuration
================================================================================================
*/
LCDC0=0b00000100;
 //			||||||||
 //			||||||||___________________________________________//LCD source clock (fLCD) selectionNote Flcd=  00---Fxt 01---Fx/32  10---Fx/64  11---Fx/128
 //			||||||_____________________________________________//LCD clock (LCDCL) selection 00--- Flcd/64 01---Flcd/128 10--->Flcd/256 11--->Flcd/512
 
LCDM0=0b00000000;
 //			||||||||________________________________________________LCD controller/driver display mode selection
 //			|||||||
 //			|||||||
 //			|||||||_________________________________________________no use
 //			||||||__________________________________________________Segment pin/common pin output control
 //
 //																																0-----Output ground level to segment/common pin
 //																																1-----Output select level to segment pin and LCD waveform to common pin
 //			|_______________________________________________________LCD display enable/disable	1---display on
 LIPS0 =1;
 LCDON0=1;
/*
===============================================================================================
Port mode initiation BY user define
===============================================================================================
*/
PM0=0b00000000;
//		||||||||____________high fan control

⌨️ 快捷键说明

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