切换到宽版
  • 192阅读
  • 4回复

[C51]求助LCD5110做时钟选择光标反色闪烁怎样做 [复制链接]

上一主题 下一主题
在线wosiyabo
 

发帖
15
M币
121
专家
1
粉丝
0
单片机:STC15W204S-DIP16@6MHz
LCD : nokia5110LCD
时钟芯片:DS3231
我想用电池电供电做电子钟,在隔离论坛上发过,无奈没有人解答。。。来这里发一次。
用STC的单片机掉电模式运行时钟,利用DS3231的1Hz来换醒读秒。
现在能跑起来了,消耗电流在0.5mA+-1mA上下。
不知道这样18650电池能跑多久。
但是程序上还欠调整时钟未做,不知道怎样做光标。
以前1602的话可以直接写光标反色的,这个5110lcd有人会做光标吗?求助




#include "reg51.h"#include "intrins.h"
#define uchar unsigned char#define uint unsigned int
#define ulong unsigned long

sfr P4          =   0xC0;   //1111,1111 端口4sfr P5          =   0xC8;   //xxxx,1111 端口5
sfr P6          =   0xE8;   //0000,0000 端口6sfr P7          =   0xF8;   //0000,0000 端口7
sfr P0M0        =   0x94;   //0000,0000 端口0模式寄存器0sfr P0M1        =   0x93;   //0000,0000 端口0模式寄存器1
sfr P1M0        =   0x92;   //0000,0000 端口1模式寄存器0sfr P1M1        =   0x91;   //0000,0000 端口1模式寄存器1
sfr P2M0        =   0x96;   //0000,0000 端口2模式寄存器0sfr P2M1        =   0x95;   //0000,0000 端口2模式寄存器1
sfr P3M0        =   0xB2;   //0000,0000 端口3模式寄存器0sfr P3M1        =   0xB1;   //0000,0000 端口3模式寄存器1
sfr P4M0        =   0xB4;   //0000,0000 端口4模式寄存器0sfr P4M1        =   0xB3;   //0000,0000 端口4模式寄存器1
sfr P5M0        =   0xCA;   //0000,0000 端口5模式寄存器0sfr P5M1        =   0xC9;   //0000,0000 端口5模式寄存器1
sfr P6M0        =   0xCC;   //0000,0000 端口6模式寄存器0sfr P6M1        =   0xCB;   //0000,0000 端口6模式寄存器1
sfr P7M0        =   0xE2;   //0000,0000 端口7模式寄存器0sfr P7M1        =   0xE1;   //0000,0000 端口7模式寄存器1
sfr   IE2       =   0xaf;               //中断使能寄存器2sfr   AUXR      =   0x8e;               //辅助寄存器
sfr   T2H       =   0xD6;               //定时器2高8位sfr   T2L       =   0xD7;               //定时器2低8位
sfr CLK_DIV     =   0x97;         //时钟分频寄存器//sbit    P10     =   P1^0;
//sbit    P11     =   P1^1;//sbit    P12     =   P1^2;
sbit    LED     =   P1^2;sbit    P13     =   P1^3;// SEL
sbit    P14     =   P1^4;// UPsbit    P15     =   P1^5;// DN
sbit    P30     =   P3^0;sbit    P31     =   P3^1;
//sbit    P32     =   P3^2;//sbit    P33     =   P3^3;
//sbit    P36     =   P3^6;//sbit    P37     =   P3^7;
//sbit    P54     =   P5^4;//sbit    P55     =   P5^5;
sbit   IIC_SDA = P5^5;  //  SDA-DS3231sbit   IIC_SCL = P5^4;  //  SCL-DS3231

sbit    LCD5110_RES = P3^3;  //LCD5110 复位,0复位
sbit     LCD5110_CE = P3^6;  //LCD5110 片选sbit    LCD5110_DC  = P3^7;  //LCD5110 1写数据,0写指令
sbit   LCD5110_SDIN = P1^0;  //LCD5110 数据sbit   LCD5110_SCLK = P1^1;  //LCD5110 时钟
bit FLAG;                    //1:上升沿中断 0:下降沿中断uchar  sec, min, hour, day, date, month, year,Dtemp1,Dtemp2;
const unsigned char code F8x8[][8] ={
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},//0    {0x00,0x10,0x10,0x10,0x10,0x10,0x10,0x00},//一
{0x00,0x24,0x24,0x24,0x24,0x24,0x24,0x00},//二{0x00,0x49,0x49,0x49,0x49,0x49,0x49,0x00},//三
{0x00,0x7F,0x49,0x47,0x41,0x4F,0x49,0x7F},//四{0x00,0x41,0x49,0x49,0x7F,0x49,0x79,0x40},//五
{0x00,0x44,0x74,0x05,0x06,0x14,0x64,0x40},//六{0x00,0x7F,0x49,0x49,0x49,0x49,0x7F,0x00},//日
};const unsigned char code F16x32[][64] =
{{0x00,0x00,0x00,0x80,0xC0,0xE0,0x60,0x20,0x20,0x60,0xE0,0xC0,0x80,0x00,0x00,0x00,
0xE0,0xFC,0xFF,0xFF,0x0F,0x01,0x00,0x00,0x00,0x00,0x00,0x0F,0xFF,0xFF,0xFC,0xE0,0x7F,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0x7F,
0x00,0x03,0x0F,0x1F,0x3F,0x78,0x60,0x40,0x40,0x60,0x70,0x3F,0x1F,0x0F,0x03,0x00},//0{0x00,0x00,0x80,0x80,0x80,0x80,0x80,0xC0,0xE0,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x40,0x40,0x40,0x60,0x7F,0x7F,0x7F,0x7F,0x60,0x40,0x40,0x40,0x00,0x00},//1{0x00,0x80,0x80,0xC0,0x60,0x20,0x20,0x20,0x20,0x60,0xE0,0xC0,0xC0,0x80,0x00,0x00,
0x3E,0x3F,0x3F,0x38,0x00,0x00,0x00,0x00,0x00,0x00,0xC1,0xFF,0xFF,0xFF,0x3E,0x00,0x00,0x00,0x00,0x00,0x80,0xC0,0xE0,0x70,0x3C,0x1E,0x0F,0x07,0x03,0x00,0x00,0x00,
0x70,0x78,0x7C,0x6F,0x67,0x61,0x60,0x60,0x60,0x60,0x60,0x60,0x78,0x7E,0x1E,0x00},//2{0x00,0x80,0xC0,0xC0,0x60,0x20,0x20,0x20,0x60,0xE0,0xC0,0xC0,0x80,0x00,0x00,0x00,
0x0F,0x0F,0x0F,0x0E,0x00,0x00,0x00,0x00,0x00,0xC1,0xFF,0xFF,0x7F,0x3E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x02,0x02,0x07,0x07,0x1D,0xFC,0xF8,0xF0,0xC0,0x00,
0x0E,0x1F,0x3F,0x37,0x60,0x40,0x40,0x40,0x60,0x60,0x38,0x3F,0x1F,0x0F,0x07,0x00},//3{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0xE0,0xE0,0xE0,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0xC0,0xE0,0x78,0x1E,0x07,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x60,0xF8,0x9C,0x8F,0x83,0x80,0x80,0x80,0x80,0xFF,0xFF,0xFF,0xFF,0x80,0x80,0x80,
0x00,0x00,0x00,0x00,0x00,0x40,0x40,0x40,0x40,0x7F,0x7F,0x7F,0x7F,0x40,0x40,0x40},//4{0x00,0x00,0xE0,0xE0,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x00,
0x00,0xF0,0xFF,0x8F,0x80,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0x80,0x80,0x00,0x00,0x00,0x00,0x87,0x87,0x83,0x01,0x00,0x00,0x00,0x00,0x01,0x07,0xFF,0xFF,0xFE,0xF8,0x00,
0x0F,0x1F,0x3F,0x23,0x60,0x40,0x40,0x40,0x60,0x60,0x78,0x3F,0x1F,0x0F,0x03,0x00},//5{0x00,0x00,0x00,0x80,0x80,0xC0,0xE0,0x60,0x20,0x20,0x20,0xE0,0xE0,0xC0,0x80,0x00,
0xC0,0xFC,0xFE,0xFF,0x0F,0x01,0x80,0x80,0x80,0x80,0x80,0x83,0x03,0x03,0x03,0x00,0xFF,0xFF,0xFF,0xFF,0x0E,0x07,0x03,0x01,0x01,0x01,0x03,0x0F,0xFF,0xFF,0xFE,0xF8,
0x00,0x07,0x1F,0x3F,0x3E,0x70,0x60,0x40,0x40,0x40,0x60,0x78,0x3F,0x1F,0x0F,0x03},//6{0x00,0xE0,0xE0,0xE0,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0xE0,0xE0,0x60,0x00,
0x07,0x07,0x01,0x00,0x00,0x00,0x00,0x00,0xC0,0xF0,0x3C,0x0F,0x03,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xE0,0xFC,0xFF,0x0F,0x01,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x7F,0x7F,0x7F,0x7F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},//7{0x00,0x00,0x80,0xC0,0xC0,0xE0,0x60,0x20,0x20,0x20,0x60,0xE0,0xC0,0xC0,0x80,0x00,
0x00,0x3E,0x7F,0xFF,0xFF,0xE0,0xC0,0x80,0x00,0x00,0x00,0xC0,0xFF,0xFF,0x7F,0x1E,0xC0,0xF0,0xF8,0xFC,0x1F,0x07,0x03,0x07,0x07,0x0F,0x1F,0x7F,0xFD,0xF8,0xF0,0xC0,
0x07,0x0F,0x1F,0x3F,0x38,0x60,0x60,0x40,0x40,0x40,0x60,0x70,0x3F,0x1F,0x0F,0x07},//8{0x00,0x00,0x80,0xC0,0xE0,0x60,0x20,0x20,0x20,0x20,0x60,0xC0,0xC0,0x80,0x00,0x00,
0xFC,0xFF,0xFF,0xFF,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x81,0xFF,0xFF,0xFE,0xF0,0x01,0x07,0x0F,0x0F,0x1F,0x1C,0x18,0x18,0x18,0x1C,0x0E,0xC7,0xFF,0xFF,0xFF,0x3F,
0x00,0x1C,0x3C,0x7C,0x7C,0x40,0x40,0x40,0x60,0x70,0x3C,0x1F,0x0F,0x07,0x01,0x00},//9};
const unsigned char code F6x8[][6] ={
    { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },   // sp 0    { 0x00, 0x00, 0x00, 0x2f, 0x00, 0x00 },   // ! 1
    { 0x00, 0x00, 0x07, 0x00, 0x07, 0x00 },   // " 2    { 0x00, 0x14, 0x7f, 0x14, 0x7f, 0x14 },   // # 3
    { 0x00, 0x24, 0x2a, 0x7f, 0x2a, 0x12 },   // $ 4    { 0x00, 0x62, 0x64, 0x08, 0x13, 0x23 },   // % 5
    { 0x00, 0x36, 0x49, 0x55, 0x22, 0x50 },   // & 6    { 0x00, 0x00, 0x05, 0x03, 0x00, 0x00 },   // ' 7
    { 0x00, 0x00, 0x1c, 0x22, 0x41, 0x00 },   // ( 8    { 0x00, 0x00, 0x41, 0x22, 0x1c, 0x00 },   // ) 9
    { 0x00, 0x14, 0x08, 0x3E, 0x08, 0x14 },   // * 10    { 0x00, 0x08, 0x08, 0x3E, 0x08, 0x08 },   // + 11
    { 0x00, 0x00, 0x00, 0xA0, 0x60, 0x00 },   // , 12    { 0x00, 0x08, 0x08, 0x08, 0x08, 0x08 },   // - 13
    { 0x00, 0x00, 0x60, 0x60, 0x00, 0x00 },   // . 14    { 0x00, 0x20, 0x10, 0x08, 0x04, 0x02 },   // / 15
    { 0x00, 0x3E, 0x51, 0x49, 0x45, 0x3E },   // 0 16    { 0x00, 0x00, 0x42, 0x7F, 0x40, 0x00 },   // 1 17
    { 0x00, 0x42, 0x61, 0x51, 0x49, 0x46 },   // 2 18    { 0x00, 0x21, 0x41, 0x45, 0x4B, 0x31 },   // 3 19
    { 0x00, 0x18, 0x14, 0x12, 0x7F, 0x10 },   // 4 20    { 0x00, 0x27, 0x45, 0x45, 0x45, 0x39 },   // 5 21
    { 0x00, 0x3C, 0x4A, 0x49, 0x49, 0x30 },   // 6 22    { 0x00, 0x01, 0x71, 0x09, 0x05, 0x03 },   // 7 23
    { 0x00, 0x36, 0x49, 0x49, 0x49, 0x36 },   // 8 24    { 0x00, 0x06, 0x49, 0x49, 0x29, 0x1E },   // 9 25
        { 0x00, 0x3C, 0x42, 0x42, 0x24, 0x01 },   // C"};

void Delayms(uchar ms)        //@6.000MHz
{    unsigned char i, j;
  while(ms--){    i = 6;
    j = 211;    do
    {        while (--j);
    } while (--i);}}
//-----------------------------------------------------------------------------------void IIC_start(void)
{//IIC总线产生起始信号函数    
     IIC_SDA=1;//拉高数据线     IIC_SCL=1;//拉高时钟线
       _nop_();_nop_();_nop_();_nop_();_nop_();_nop_();     IIC_SDA=0;//在时钟线为高电平时,拉低数据线,产生起始信号。
     IIC_SCL=0;//拉低时钟线}
//-------------------------------------------------------------------void IIC_stop(void)
{//IIC总线产生停止信号函数    IIC_SDA=0;//拉低数据线
    IIC_SCL=1;//拉高时钟线。      _nop_();_nop_();_nop_();_nop_();_nop_();_nop_();
    IIC_SDA=1;//时钟时线为高电平时,拉高数据线,产生停止信号。}
//-------------------------------------------------------------------bit IIC_Tack(void)
{//接收应答信号函数    bit ack;//定义一个位变量,来暂存应答状态。
    IIC_SDA=1;//释放数据总线,准备接收应答信号。    _nop_();_nop_();_nop_();_nop_();_nop_();_nop_();
    IIC_SCL=1;//拉高时钟线。    _nop_();_nop_();_nop_();_nop_();_nop_();_nop_();
    ack=IIC_SDA;//读取应答信号的状态。    _nop_();_nop_();_nop_();_nop_();_nop_();_nop_();
    IIC_SCL=0;//拉低时钟线。    _nop_();_nop_();_nop_();_nop_();_nop_();_nop_();
    return ack;//返回应答信号的状态,0表示应答,1表示非应答。}
//-------------------------------------------------------------------void IIC_write_byte(unsigned char Data)
{//向IIC总线写入一个字节的数据函数    unsigned char i;
     for(i=0;i<8;i++)//有8位数据    {
        IIC_SDA=Data&0x80;//写最高位的数据        IIC_SCL=1; //拉高时钟线,将数写入到设备中。
        _nop_();_nop_();_nop_();_nop_();_nop_();_nop_();        IIC_SCL=0;//拉低时钟线,允许改变数据线的状态
        _nop_();_nop_();_nop_();_nop_();_nop_();_nop_();        Data=Data<<1;//数据左移一位,把次高位放在最高位,为写入次高位做准备
    }}
//-------------------------------------------------------------------unsigned char IIC_read_byte()
{//从IIC总线读取一个字节的数据函数    unsigned char i;
    unsigned char Data;       //定义一个缓冲寄存器。    for(i=0;i<8;i++)//有8位数据
    {        IIC_SCL=1;//拉高时钟线,为读取下一位数据做准备。
        Data=Data<<1;//将缓冲字节的数据左移一位,准备读取数据。        _nop_();_nop_();_nop_();_nop_();_nop_();_nop_();
        if(IIC_SDA)//如果数据线为高平电平。        Data=Data|0x01;//则给缓冲字节的最低位写1。
        IIC_SCL=0;//拉低时钟线,为读取下一位数据做准备。        _nop_();_nop_();_nop_();_nop_();_nop_();_nop_();
    }    return Data;//返回读取的一个字节数据。
}



本文内容包含图片或附件,获取更多资讯,请 登录 后查看;或者 注册 成为会员获得更多权限
在线wosiyabo

发帖
15
M币
121
专家
1
粉丝
0
只看该作者 1楼 发表于: 03-20
//-------------------------------------------------------------------
void IIC_single_byte_write(unsigned char Waddr,unsigned char Data)
{//向任意地址写入一个字节数据函数
    IIC_start();//产生起始信号
    IIC_write_byte(0xd0);//写入设备地址(写)
    IIC_Tack();//等待设备的应答
    IIC_write_byte(Waddr);//写入要操作的单元地址。
    IIC_Tack();//等待设备的应答。
    IIC_write_byte(Data);//写入数据。
    IIC_Tack();//等待设备的应答。
    IIC_stop();//产生停止符号。
}
//-------------------------------------------------------------------
unsigned char IIC_single_byte_read(unsigned char Waddr)
{//从任意地址读取一个字节数据函数
    unsigned char Data;//定义一个缓冲寄存器。
    IIC_start();//产生起始信号
    IIC_write_byte(0xd0);//写入设备地址(写)
    IIC_Tack();//等待设备的应答
    IIC_write_byte(Waddr);//写入要操作的单元地址。
    IIC_Tack();//等待设备的应答。
    IIC_stop();//产生停止符号。
    IIC_start();//产生起始信号
    IIC_write_byte(0xd1);//写入设备地址(写)
    IIC_Tack();//等待设备的应答
    Data=IIC_read_byte();//写入数据。
    _nop_();_nop_();_nop_();_nop_();_nop_();_nop_();
    IIC_stop();//产生停止符号。
    //-------------------返回读取的数据--------------------
    return Data;//返回读取的一个字节数据。
}
//--------------------------------------------------------------------------
uchar BCD2HEX(uchar val)   //BCD转换为Byte
{
    return    ((val>>4)*10)+(val&0x0f);
}
//--------------------------------------------------------------------------
uchar B_BCD(uchar val)//Byte码转换为BCD码
{
     return    (((val%100)/10)<<4)|(val%10);
}
//--------------------------------------------------------------------------
void Readtime()
{
  uchar temp;
  temp=IIC_single_byte_read(0x00);//秒
  sec=(int)BCD2HEX(temp);
  temp=IIC_single_byte_read(0x01);//分
  min=BCD2HEX(temp);
  temp=IIC_single_byte_read(0x02);  //时
  hour=BCD2HEX(temp);
  day=IIC_single_byte_read(0x03);//星期
  temp=IIC_single_byte_read(0x04);  //日
  date=BCD2HEX(temp);
  temp=IIC_single_byte_read(0x05); //月
  month=BCD2HEX(temp);
  temp=IIC_single_byte_read(0x06);  //年
  year=BCD2HEX(temp);
}
//void Ttemp_read()
//{
  //IIC_single_byte_write(0x0E,0x20);    
// Dtemp1=IIC_single_byte_read(0x11);//温度高位
    //Dtemp2=IIC_single_byte_read(0x12);//温度低位+-0.25度变化
    //Dtemp2=(Dtemp2>>6)*25;
//}
void DS3231_Init(void)
{
IIC_single_byte_write(0x0E,0x60);
IIC_single_byte_write(0x0F,0x80);    
//IIC_single_byte_write(0x01,B_BCD(46));//28
//IIC_single_byte_write(0x02,B_BCD(0));//22
//IIC_single_byte_write(0x03,B_BCD(1));//日
//IIC_single_byte_write(0x04,B_BCD(20));//19
//IIC_single_byte_write(0x05,B_BCD(3));//03
//IIC_single_byte_write(0x06,B_BCD(17));//17    
}
//-----------------------------------------------------------------------------------
void LCD_write_byte(unsigned char dt, unsigned char command)//LCD5110写入数据
{
     unsigned char i;
     LCD5110_CE=0;               // 关闭LCD
     LCD5110_DC=command;     // 0是写命令,1是写数据
     for(i=0;i<8;i++)
     {
          if(dt&0x80)
             LCD5110_SDIN=1;
            else
             LCD5110_SDIN=0;
          dt=dt<<1;      //dt为暂存数据  
          LCD5110_SCLK=0;              
          LCD5110_SCLK=1;
     }    
     LCD5110_DC=1;    
     LCD5110_CE=1;    
     LCD5110_SDIN=1;
}
void LCD_write_byteone()//LCD5110写入数据
{
     LCD5110_CE=0;               // 关闭LCD
     LCD5110_DC=1;     // 0是写命令,1是写数据
     LCD5110_SDIN=1;
     LCD5110_SCLK=0;              
     LCD5110_SCLK=1;  
     LCD5110_DC=1;    
     LCD5110_CE=1;    
     LCD5110_SDIN=1;
}
void LCD_clear(void) //5110LCD清屏
{
    unsigned int i;
    LCD_write_byte(0x0c, 0);            
    LCD_write_byte(0x80, 0);            
    for (i=0; i<504; i++)
    LCD_write_byte(0, 1);            
}
void LCD_set_XY(unsigned char X, unsigned char Y)  //x 左右共0~83列可移,Y由上至下共0~5行可移
{
        LCD_write_byte(0x40 | Y, 0);    // column     Y+=64
        LCD_write_byte(0x80 | X, 0);  // row         X+=128
}
void LCD_init(void)    //5110LCD初始化LCD_init
{            
        LCD5110_RES=0;    // 产生一个让LCD复位的低电平脉冲
        Delayms(10);    
        LCD5110_RES=1;        
        LCD5110_CE = 0;     // 关闭LCD
        Delayms(10);    
        LCD5110_CE = 1;// 使能LCD
        Delayms(10);    
        LCD_write_byte(0x21, 0);    // 使用扩展命令设置LCD模式
        LCD_write_byte(0xBC, 0);    // 设置偏置电压//不同的屏须要微调此参数B9~C9
        LCD_write_byte(0x06, 0);    // 温度校正
        LCD_write_byte(0x13, 0);    // 1:48
        LCD_write_byte(0x20, 0);    // 使用基本命令
        LCD_clear();                // 清屏
        LCD_write_byte(0x0C, 0);    // 设定显示模式,正常显示      
        LCD5110_CE = 0;  // 关闭LCD
}

void LCD_P6x8Str(unsigned char x,unsigned char y,unsigned char ch)
{
    unsigned char i;      
    LCD_set_XY(x,y);    
    for(i=0;i<6;i++){    LCD_write_byte(F6x8[ch],1);  }
}
void LCD_P16x32Str(unsigned char x,unsigned char y,unsigned char ch)
{
    unsigned char i;      
    LCD_set_XY(x,y);    
    for(i=0;i<16;i++){    LCD_write_byte( F16x32[ch],1);  }
    LCD_set_XY(x,y+1);    
    for(i=16;i<32;i++){    LCD_write_byte( F16x32[ch],1);  }
    LCD_set_XY(x,y+2);    
    for(i=32;i<48;i++){    LCD_write_byte( F16x32[ch],1);  }
    LCD_set_XY(x,y+3);    
    for(i=48;i<64;i++){    LCD_write_byte( F16x32[ch],1);  }
}
void LCD_P8x8Str(unsigned char x,unsigned char y,unsigned char ch)
{
    unsigned char i;      
    LCD_set_XY(x,y);    
    for(i=0;i<8;i++){    LCD_write_byte(F8x8[ch],1);  }
}
void main()
{
      bit seet=0;
      uchar a1,a2,a3;
      uchar key1,tt,tt2,tt3,
    P1M0 =P1M1 = 0x00;
    P3M0 =P3M1 = 0x00;
    P5M0 =P5M1 = 0x00;
    DS3231_Init();    
      LCD_init();
      IT0 = 1;                    //设置INT0的中断类型为下降沿唤醒
    EX0 = 1;                    //使能INT0中断
    EA = 1;
      Readtime();
        LCD_P6x8Str(6,0,16+2);      //2
        LCD_P6x8Str(12,0,16+0);      //0
        LCD_P6x8Str(18,0,16+year/10);//1
        LCD_P6x8Str(24,0,16+year%10);//7
        LCD_P6x8Str(30,0,13);         //-
        LCD_P6x8Str(36,0,16+month/10);//0
        LCD_P6x8Str(42,0,16+month%10);//3
        LCD_P6x8Str(48,0,13);         //-
        LCD_P6x8Str(54,0,16+date/10); //1
        LCD_P6x8Str(60,0,16+date%10); //9
        
        LCD_P8x8Str(72,0,day);

        LCD_P16x32Str(2,1,hour/10);//时十位
        LCD_P16x32Str(20,1,hour%10);//时个位
        
        LCD_set_XY(40,2),LCD_write_byte(0x20,1);
        LCD_set_XY(41,2),LCD_write_byte(0x70,1);
        LCD_set_XY(42,2),LCD_write_byte(0x70,1);
        LCD_set_XY(43,2),LCD_write_byte(0x20,1);
        
        LCD_set_XY(40,4),LCD_write_byte(0x02,1);
        LCD_set_XY(41,4),LCD_write_byte(0x07,1);
        LCD_set_XY(42,4),LCD_write_byte(0x07,1);
        LCD_set_XY(43,4),LCD_write_byte(0x02,1);
        
        LCD_P16x32Str(48,1,min/10);//分十位
        LCD_P16x32Str(66,1,min%10);//分个位
        
            while(1)
            {
                  if(!P13){   while(!P13);
                                  a1=a2=a3=0;
                      LED = 0;                        
                      goto MEN;
                   }
        time:    Readtime();
                    LCD_set_XY(sec,5);
                    LCD_write_byte(0x00,1);
                    LCD_write_byte(0x40,1);
                    if(sec==00)//一分钟刷新一次分显示
                    {
                        LCD_P16x32Str(48,1,min/10);//分十位
                        LCD_P16x32Str(66,1,min%10);//分个位
                        //Ttemp_read();
                        //LCD_P6x8Str(48,5,16+Dtemp1/10);
                        //LCD_P6x8Str(54,5,16+Dtemp1%10);
                        //LCD_P6x8Str(60,5,14);         //.
                        //LCD_P6x8Str(66,5,16+Dtemp2/10);
                        //LCD_P6x8Str(72,5,16+Dtemp2%10);
                        //LCD_P6x8Str(78,5,26);
                        if(min==0)//一小时刷新一次时显示
                        {
                            LCD_P16x32Str(2,1,hour/10);//时十位
                            LCD_P16x32Str(20,1,hour%10);//时个位
                            if(hour==0)//24小时刷新一次年、月、日显示
                            {
                                LCD_P6x8Str(18,0,16+year/10);//1
                                LCD_P6x8Str(24,0,16+year%10);//7
                                LCD_P6x8Str(36,0,16+month/10);//0
                                LCD_P6x8Str(42,0,16+month%10);//3
                                LCD_P6x8Str(54,0,16+date/10); //1
                                LCD_P6x8Str(60,0,16+date%10); //9
                                LCD_P8x8Str(72,0,day);                        
                            }
                        }
                    }
                PCON |= 0x02;    
      }
while(1)
{
      
MEN :
    
        if(!P13)//SEL
            {    
                Delayms(10);
                if(!P13)
                {
                    key1++;
                    a1=a2=a3=0;
                    if(key1==7){key1=0;}
                    while(!P13);
                }
            }
switch(key1)
{
     case 1: {LCD_set_XY(48,5);     //分指针
            for(tt=0;tt<33;tt++){LCD_write_byteone();}



}
            
            
            
}
         a1++;
      if(a1>250)
        {
          a1=0;
                    a2++;
                    if(a2>250)
                    {
                        Readtime();
                        LCD_set_XY(sec,5);
                        LCD_write_byte(0x00,1);
                        LCD_write_byte(0x40,1);
                        LCD_P6x8Str(6,0,16+2);      //2
                        LCD_P6x8Str(12,0,16+0);      //0
                        LCD_P6x8Str(18,0,16+year/10);//1
                        LCD_P6x8Str(24,0,16+year%10);//7
                        LCD_P6x8Str(30,0,13);         //-
                        LCD_P6x8Str(36,0,16+month/10);//0
                        LCD_P6x8Str(42,0,16+month%10);//3
                        LCD_P6x8Str(48,0,13);         //-
                        LCD_P6x8Str(54,0,16+date/10); //1
                        LCD_P6x8Str(60,0,16+date%10); //9
                        LCD_P8x8Str(72,0,day);       //星期几
                        LCD_P16x32Str(2,1,hour/10);//时十位
                        LCD_P16x32Str(20,1,hour%10);//时个位
                        LCD_set_XY(40,2),LCD_write_byte(0x20,1);//
                        LCD_set_XY(41,2),LCD_write_byte(0x70,1);//
                        LCD_set_XY(42,2),LCD_write_byte(0x70,1);//
                        LCD_set_XY(43,2),LCD_write_byte(0x20,1);//
                        LCD_set_XY(40,4),LCD_write_byte(0x02,1);//
                        LCD_set_XY(41,4),LCD_write_byte(0x07,1);//
                        LCD_set_XY(42,4),LCD_write_byte(0x07,1);//
                        LCD_set_XY(43,4),LCD_write_byte(0x02,1);//
                        a2=0;
                        a3++;
                         if(a3>250)
                         {
                a3=0;
                LED =1;
                            goto time;
             }

          }
        }
}
}
void exint0() interrupt 0       //INT0中断入口
{
    FLAG = INT0;                //保存INT0口的状态, INT0=0(下降沿); INT0=1(上升沿)
}
本帖最近打赏记录:共1条打赏M币+30
梦幻数码 M币 +30 实验板非常有特色 03-21
离线sdf15937

发帖
1514
M币
172
专家
8
粉丝
52
只看该作者 2楼 发表于: 03-21
给你个提示:正显示是这样LCD_write_byte(F6x8[ch],1);
那么反显示就是这样:LCD_write_byte(~F6x8[ch],1);
在线wosiyabo

发帖
15
M币
121
专家
1
粉丝
0
只看该作者 3楼 发表于: 03-21
万分感谢。。。果然数码之家牛人多。。
离线lsqmdg

发帖
1931
M币
3533
专家
4
粉丝
17
只看该作者 4楼 发表于: 03-22
呵呵,玩家很多啊
快速回复
限80 字节
温馨提示:所有技术区严禁灌水,“沙发”“顶”字样;禁止广告贴;以免被删除
 
上一个 下一个