您好,欢迎访问三七文档
当前位置:首页 > 电子/通信 > 综合/其它 > 农历转阳历代码单片机万年历
#ifndef_EEPROM52_H_#define_EEPROM52_H_uchara_a;#includeintrins.h#defineRdCommand0x01//定义ISP的操作命令#definePrgCommand0x02#defineEraseCommand0x03#defineError1#defineOk0#defineWaitTime0x01//定义CPU的等待时间sfrISP_DATA=0xe2;//寄存器申明sfrISP_ADDRH=0xe3;sfrISP_ADDRL=0xe4;sfrISP_CMD=0xe5;sfrISP_TRIG=0xe6;sfrISP_CONTR=0xe7;/*================打开ISP,IAP功能=================*/voidISP_IAP_enable(void){EA=0;/*关中断*/ISP_CONTR=ISP_CONTR&0x18;/*0001,1000*/ISP_CONTR=ISP_CONTR|WaitTime;/*写入硬件延时*/ISP_CONTR=ISP_CONTR|0x80;/*ISPEN=1*/}/*===============关闭ISP,IAP功能==================*/voidISP_IAP_disable(void){ISP_CONTR=ISP_CONTR&0x7f;/*ISPEN=0*/ISP_TRIG=0x00;EA=1;/*开中断*/}/*================公用的触发代码====================*/voidISPgoon(void){ISP_IAP_enable();/*打开ISP,IAP功能*/ISP_TRIG=0x46;/*触发ISP_IAP命令字节1*/ISP_TRIG=0xb9;/*触发ISP_IAP命令字节2*/_nop_();}/*====================字节读========================*/unsignedcharbyte_read(unsignedintbyte_addr){EA=0;ISP_ADDRH=(unsignedchar)(byte_addr8);/*地址赋值*/ISP_ADDRL=(unsignedchar)(byte_addr&0x00ff);ISP_CMD=ISP_CMD&0xf8;/*清除低3位*/ISP_CMD=ISP_CMD|RdCommand;/*写入读命令*/ISPgoon();/*触发执行*/ISP_IAP_disable();/*关闭ISP,IAP功能*/EA=1;return(ISP_DATA);/*返回读到的数据*/}/*==================扇区擦除========================*/voidSectorErase(unsignedintsector_addr){unsignedintiSectorAddr;iSectorAddr=(sector_addr&0xfe00);/*取扇区地址*/ISP_ADDRH=(unsignedchar)(iSectorAddr8);ISP_ADDRL=0x00;ISP_CMD=ISP_CMD&0xf8;/*清空低3位*/ISP_CMD=ISP_CMD|EraseCommand;/*擦除命令3*/ISPgoon();/*触发执行*/ISP_IAP_disable();/*关闭ISP,IAP功能*/}/*====================字节写========================*/voidbyte_write(unsignedintbyte_addr,unsignedcharoriginal_data){EA=0;//SectorErase(byte_addr);ISP_ADDRH=(unsignedchar)(byte_addr8);/*取地址*/ISP_ADDRL=(unsignedchar)(byte_addr&0x00ff);ISP_CMD=ISP_CMD&0xf8;/*清低3位*/ISP_CMD=ISP_CMD|PrgCommand;/*写命令2*/ISP_DATA=original_data;/*写入数据准备*/ISPgoon();/*触发执行*/ISP_IAP_disable();/*关闭IAP功能*/EA=1;}#endif//采用查表的方法实现农历与公历的转换,可以坚持50年。#ifndef_NONGLI_H_#define_NONGLI_H_//#defineucharunsignedchar//#defineuintunsignedint#includeintrins.h/*公历年对应的农历数据,每年三字节,格式第一字节BIT7-4位表示闰月月份,值为0为无闰月,BIT3-0对应农历第1-4月的大小第二字节BIT7-0对应农历第5-12月大小,第三字节BIT7表示农历第13个月大小月份对应的位为1表示本农历月大(30天),为0表示小(29天)第三字节BIT6-5表示春节的公历月份,BIT4-0表示春节的公历日期*/codeucharyear_code[597]={0x04,0xAe,0x53,//190100x0A,0x57,0x48,//190230x55,0x26,0xBd,//190360x0d,0x26,0x50,//190490x0d,0x95,0x44,//1905120x46,0xAA,0xB9,//1906150x05,0x6A,0x4d,//1907180x09,0xAd,0x42,//1908210x24,0xAe,0xB6,//19090x04,0xAe,0x4A,//19100x6A,0x4d,0xBe,//19110x0A,0x4d,0x52,//19120x0d,0x25,0x46,//19130x5d,0x52,0xBA,//19140x0B,0x54,0x4e,//19150x0d,0x6A,0x43,//19160x29,0x6d,0x37,//19170x09,0x5B,0x4B,//19180x74,0x9B,0xC1,//19190x04,0x97,0x54,//19200x0A,0x4B,0x48,//19210x5B,0x25,0xBC,//19220x06,0xA5,0x50,//19230x06,0xd4,0x45,//19240x4A,0xdA,0xB8,//19250x02,0xB6,0x4d,//19260x09,0x57,0x42,//19270x24,0x97,0xB7,//19280x04,0x97,0x4A,//19290x66,0x4B,0x3e,//19300x0d,0x4A,0x51,//19310x0e,0xA5,0x46,//19320x56,0xd4,0xBA,//19330x05,0xAd,0x4e,//19340x02,0xB6,0x44,//19350x39,0x37,0x38,//19360x09,0x2e,0x4B,//19370x7C,0x96,0xBf,//19380x0C,0x95,0x53,//19390x0d,0x4A,0x48,//19400x6d,0xA5,0x3B,//19410x0B,0x55,0x4f,//19420x05,0x6A,0x45,//19430x4A,0xAd,0xB9,//19440x02,0x5d,0x4d,//19450x09,0x2d,0x42,//19460x2C,0x95,0xB6,//19470x0A,0x95,0x4A,//19480x7B,0x4A,0xBd,//19490x06,0xCA,0x51,//1***0x0B,0x55,0x46,//19510x55,0x5A,0xBB,//19520x04,0xdA,0x4e,//19530x0A,0x5B,0x43,//19540x35,0x2B,0xB8,//19550x05,0x2B,0x4C,//19560x8A,0x95,0x3f,//19570x0e,0x95,0x52,//19580x06,0xAA,0x48,//19590x7A,0xd5,0x3C,//19600x0A,0xB5,0x4f,//19610x04,0xB6,0x45,//19620x4A,0x57,0x39,//19630x0A,0x57,0x4d,//19640x05,0x26,0x42,//19650x3e,0x93,0x35,//19660x0d,0x95,0x49,//19670x75,0xAA,0xBe,//19680x05,0x6A,0x51,//19690x09,0x6d,0x46,//19700x54,0xAe,0xBB,//19710x04,0xAd,0x4f,//19720x0A,0x4d,0x43,//19730x4d,0x26,0xB7,//19740x0d,0x25,0x4B,//19750x8d,0x52,0xBf,//19760x0B,0x54,0x52,//19770x0B,0x6A,0x47,//19780x69,0x6d,0x3C,//19790x09,0x5B,0x50,//19800x04,0x9B,0x45,//19810x4A,0x4B,0xB9,//19820x0A,0x4B,0x4d,//19830xAB,0x25,0xC2,//19840x06,0xA5,0x54,//19850x06,0xd4,0x49,//19860x6A,0xdA,0x3d,//19870x0A,0xB6,0x51,//19880x09,0x37,0x46,//19890x54,0x97,0xBB,//19900x04,0x97,0x4f,//19910x06,0x4B,0x44,//19920x36,0xA5,0x37,//19930x0e,0xA5,0x4A,//19940x86,0xB2,0xBf,//19950x05,0xAC,0x53,//19960x0A,0xB6,0x47,//19970x59,0x36,0xBC,//19980x09,0x2e,0x50,//19992940x0C,0x96,0x45,//20002970x4d,0x4A,0xB8,//20010x0d,0x4A,0x4C,//20020x0d,0xA5,0x41,//20030x25,0xAA,0xB6,//20040x05,0x6A,0x49,//20050x7A,0xAd,0xBd,//20060x02,0x5d,0x52,//20070x09,0x2d,0x47,//20080x5C,0x95,0xBA,//20090x0A,0x95,0x4e,//20100x0B,0x4A,0x43,//20110x4B,0x55,0x37,//20120x0A,0xd5,0x4A,//20130x95,0x5A,0xBf,//20140x04,0xBA,0x53,//20150x0A,0x5B,0x48,//20160x65,0x2B,0xBC,//20170x05,0x2B,0x50,//20180x0A,0x93,0x45,//20190x47,0x4A,0xB9,//20200x06,0xAA,0x4C,//20210x0A,0xd5,0x41,//20220x24,0xdA,0xB6,//20230x04,0xB6,0x4A,//20240x69,0x57,0x3d,//20250x0A,0x4e,0x51,//20260x0d,0x26,0x46,//20270x5e,0x93,0x3A,//20280x0d,0x53,0x4d,//20290x05,0xAA,0x43,//20300x36,0xB5,0x37,//20310x09,0x6d,0x4B,//20320xB4,0
本文标题:农历转阳历代码单片机万年历
链接地址:https://www.777doc.com/doc-2634576 .html