#include "ioS3C9488.h"//
#include "intrinsics.h"//包含内部函数
#include "math.h"
#pragma vector = __TIMERB_UNDERFLOW_vector
__root __interrupt void interrupt0();
#define uchar unsigned char
#define uint unsigned int
#define Set_Bit(byte,bit) (byte|=(1<<bit)
#define Clr_Bit(byte,bit) (byte&=~(1<<bit)
__code const volatile uchar SmartOption[4] @0x003c = {0xFF,0x00,0xBB,0xFB}; //定义P0.0-P0.2为次晶振,EESET
void delay(uint i); //单位为1ms
void Err1( );
void Err2( );
void Winter( );
void Summer( );
void Cotton( );
void Wool( uchar m2);
void Shoes( );
void Clothes(uchar m4 );
void Flea( );
void Temp( );
void Booking( uchar temp1);
//void Interrupt0( );
void initialize( ); //初始化程序
void scan( ); //
void heat_work(); //加热
void heat_stop();
void fan_work(); //风扇
void fan_stop();
void modify_time(); //修改时间
void buz();
uchar LCD0[11]={0x00,0x60,0x40,0x20,0x80,0x80,0x40,0x00,0x00,0x80,0xE0}; //显示0-9,E-
uchar LCD1[11]={0x10,0xB0,0X20,0XA0,0X20,0X00,0XB0,0X00,0X20,0x40,0XE0}; //显示0-9,E-
uchar KEY[6]={0XEF,0XDF,0XBF,0X7F,0XFE,0XFD}; //按钮1-6
uchar LED[]={0x01,0x02,0x04,0x08,0x80,0x10,0x20,0x40}; //数码管高电位
uchar time[6];
uchar ID=0;
uchar hour=0,min=0,sec=0;
uint flag=0;
uchar temp=0;
/*****************************************************************/
//主函数
/****************************************************************/
void main( )
{
//BTCON=0XFF;
SP=0XC0;
asm("DI");
//ADCON=0X8D; //1vs采样一次
BTCON=0XFB; //稳定晶振为62.5ms
OSCCON=0X04;
CLKCON=0X8F; //没有分频
LCDCON=0X94; //LCD的占空比,信号为FW/128
LCDVOL=0X89; // LCD的亮度设置
P0CONH=0XFF;P0CONL=0X80;P0PUR=0XFF; //p0.3为采样口
P1CONH=0XFF;P1CONL=0XA6; P1PUR=0XFF; //P1.0有待最后确定
P2CONH=0XFF;P2CONL=0XFF;
P3CONH=0XFA;P3CONL=0X00; //P3.0为输入,全是输入
P3INT=0X00; //不启用外部中断
P4CONH=0x16;//0X02;
P4CONL=0X7F;//0X3F;
//STPCON=0XA5; //允许STOP指令
TACON=0X00; //初始化
TBCON=0X00;
//TINTPND=0X00; //待定???
// VLDCON=0X1D;
//VLDCON=0XDD;
//WTCON=0X52; //待定
//SYM=0X08; //允许所有中断运行
//asm("DI");
asm("EI");
initialize( ); //初始化
while(1)
{
if (P3==KEY[3])
delay(10);
if(P3==KEY[3])
{
void buz();
Winter( );
Err2();
Err1();
/*if(P3==KEY[0])
delay(10);
if(P3==KEY[0])
{
void buz();
Booking( );
while(P3==KEY[0]);
}*/
if(P3==KEY[1])
delay(10);
if(P3==KEY[1] )
{
void buz();
void Flea();
while(P3==KEY[1]);
if(P3==KEY[5])