標(biāo)題: 單片機(jī)+pcf8563 LCD1602顯示源程序+Proteus仿真 [打印本頁]

作者: linaa    時(shí)間: 2020-4-14 12:49
標(biāo)題: 單片機(jī)+pcf8563 LCD1602顯示源程序+Proteus仿真
  最近學(xué)習(xí)涉及到icc的編程 由于無法在實(shí)驗(yàn)室實(shí)驗(yàn) 便用proteus做了簡(jiǎn)單仿真 沒有寫鬧鐘部分功能
  下面附上部分代碼和仿真截圖  


單片機(jī)源程序如下:

#include <reg51.h>
#include "PCF8563.h"
#include "LM016L.h"

uchar TimeBuff[7]={0,0,0,0,0,0,0};  //sec min hour day weekday month year

void DisplayFullTime(uchar *buff);  //顯示完整時(shí)間參數(shù)
void delay();

uchar line1[16] = "This is PCF8563!";
uchar line2[16] = "Ready for clock!";
//----------------------------------------------------------------------------
void main()
{
        PCF8563_INIT();  //初始化PCF8563狀態(tài),并將時(shí)間置2015-05-01 Fri 12:30:00
        LCD_Init();
        LCD_Display_Line(1, line1);
        LCD_Display_Line(2, line2);
        
        //test1: 設(shè)置時(shí)間
        TimeBuff[0] = 0x30;  //sec
        TimeBuff[1] = 0x59;  //min
        TimeBuff[2] = 0x23;  //hour
        TimeBuff[3] = 0x31;  //day
        TimeBuff[4] = 0x02;  //weekday
        TimeBuff[5] = 0x12;  //month
        TimeBuff[6] = 0x19;  //year
        Time_Write(TimeBuff); //寫入上述新的時(shí)間。另,若要寫入鬧鈴時(shí)間,方法雷同,差別在于,寄存器地址不同,寫入總字節(jié)數(shù)不同。請(qǐng)自行封裝函數(shù)。

        while(1)
        {
                //test2: 讀取時(shí)間,這是完整讀取
                Time_Read(TimeBuff);
                DisplayFullTime(TimeBuff);
                delay();
        };        
}
//----------------------------------------------------------------------------
void delay()
{
        uint i;
        for (i = 0; i < 0x3fff; i++)        {;}
}
//----------------------------------------------------------------------------
void DisplayFullTime(uchar *buff)
{
//uchar line1[16] = "This is PCF8563!";
//uchar line2[16] = "Ready for clock!";
//保留第一行歡迎信息不變,第二行顯示為:[MM-dd hh:mm:ss]
        line2[15] = ']';
        line2[14] = (TimeBuff[0]&0x0f) + 0x30;                //秒個(gè)位轉(zhuǎn)ascii
        line2[13] = (TimeBuff[0]>>4) + 0x30;                        //秒十位轉(zhuǎn)ascii
        line2[12] = ':';
        line2[11] = (TimeBuff[1]&0x0f) + 0x30;                //分鐘個(gè)位轉(zhuǎn)ascii
        line2[10] = (TimeBuff[1]>>4) + 0x30;                        //分鐘十位轉(zhuǎn)ascii
        line2[9]  = ':';
        line2[8] = (TimeBuff[2]&0x0f) + 0x30;                //小時(shí)個(gè)位轉(zhuǎn)ascii
        line2[7] = (TimeBuff[2]>>4) + 0x30;                        //小時(shí)十位轉(zhuǎn)ascii
        line2[6]  = ' ';
        line2[5] = (TimeBuff[3]&0x0f) + 0x30;                //日個(gè)位轉(zhuǎn)ascii
        line2[4] = (TimeBuff[3]>>4) + 0x30;                        //日十位轉(zhuǎn)ascii
        line2[3]  = '-';
        line2[2] = (TimeBuff[5]&0x0f) + 0x30;                //月個(gè)位轉(zhuǎn)ascii
        line2[1] = (TimeBuff[5]>>4) + 0x30;                        //月十位轉(zhuǎn)ascii
        line2[0]  = '[';
        LCD_Display_Line(2, line2);
}

全部資料51hei下載地址:
PCF8563.pdf (649.36 KB, 下載次數(shù): 45)
PCF8563+proteus+LCD1602.rar (74.95 KB, 下載次數(shù): 145)

作者: 1804889557    時(shí)間: 2020-12-23 23:09
為啥我仿真的全是亂碼




歡迎光臨 (http://www.torrancerestoration.com/bbs/) Powered by Discuz! X3.1