標(biāo)題: 關(guān)于Atmega16在proteus下仿真這個lmo16l顯示的怎么不是電腦的時間呀? [打印本頁]

作者: guo1529721864    時間: 2022-11-5 00:20
標(biāo)題: 關(guān)于Atmega16在proteus下仿真這個lmo16l顯示的怎么不是電腦的時間呀?
我已經(jīng)把ds1302中“顯示電腦時間”勾選上了,為什么顯示的還是之前的時間?
#include <iom16v.h>
#include <macros.h>
#include "ds1302.h"
#include "LCD1602.h"

void main(void)
{
        unsigned char temp;

        delay_ms(200); //延時,使用上電穩(wěn)定
        Port_init();   //端口初始化
        LCD_init();    //LCD初始化
        LCD_clear();
        ds1302_init(); //DS1302初始化
        delay_ms(10);
        ds1302_write_time(); //寫入初始值

        while (1)
        {
                delay_ms(200);       //每200ms更新一次時間
                ds1302_read_time();  //讀取時間
                LCD_clear();         //清屏
                               
                temp = (time_buf[0] >> 4) + '0';
                LCD_write_char(0, 0, temp);/*年*/
                temp = (time_buf[0] & 0x0F) + '0';
                LCD_write_char(1, 0, temp);
                temp = (time_buf[1] >> 4) + '0';
                LCD_write_char(2, 0, temp);
                temp = (time_buf[1] & 0x0F) + '0';
                LCD_write_char(3, 0, temp);
                LCD_write_char(4, 0, '-');
               
                temp = (time_buf[2] >> 4) + '0';
                LCD_write_char(5, 0, temp);/*月*/
                temp = (time_buf[2] & 0x0F) + '0';
                LCD_write_char(6, 0, temp);
                LCD_write_char(7, 0, '-');
               
                temp = (time_buf[3] >> 4) + '0';
                LCD_write_char(8, 0, temp);/*日*/
                temp = (time_buf[3] & 0x0F) + '0';
                LCD_write_char(9, 0, temp);
               
                LCD_write_str(0,1,"week:");
                temp = (time_buf[7]) + '0';
                LCD_write_char(5, 1, temp);  //周
               
                temp = (time_buf[4] >> 4) + '0';
                LCD_write_char(8, 1, temp);  //時
                temp = (time_buf[4] & 0x0F) + '0';
                LCD_write_char(9, 1, temp);
                LCD_write_char(10, 1, ':');
               
                temp = (time_buf[5] >> 4) + '0';
                LCD_write_char(11, 1, temp);/*分*/
                temp = (time_buf[5] & 0x0F) + '0';
                LCD_write_char(12, 1, temp);
                LCD_write_char(13, 1, ':');
               
                temp = (time_buf[6] >> 4) + '0';
                LCD_write_char(14, 1, temp);/*秒*/
                temp = (time_buf[6] & 0x0F) + '0';
                LCD_write_char(15, 1, temp);
        }
}


111111111111.png (85.71 KB, 下載次數(shù): 82)

111111111111.png

作者: hhdsdy    時間: 2022-11-5 02:14
這個只是示例程序,不是實用的程序,你是使用仿真進(jìn)行學(xué)習(xí),那么在意時間是不是實時的干什么?難道你就看不出程序每次運行都是從一個固定的時間開始的嗎?想要程序正常使用,就不能每次都給1302寫入初始值
作者: guo1529721864    時間: 2022-11-5 16:25
hhdsdy 發(fā)表于 2022-11-5 02:14
這個只是示例程序,不是實用的程序,你是使用仿真進(jìn)行學(xué)習(xí),那么在意時間是不是實時的干什么?難道你就看不 ...

非常感謝指點。
作者: 13205495918    時間: 2022-11-5 19:10
不用太在意這個,你懂這個通信協(xié)議就好,實物的話我建議你用示波器去抓捕一下,直觀的感受協(xié)議這也是我今年秋招被一個大佬點出來的問題
作者: guo1529721864    時間: 2022-11-5 20:56
13205495918 發(fā)表于 2022-11-5 19:10
不用太在意這個,你懂這個通信協(xié)議就好,實物的話我建議你用示波器去抓捕一下,直觀的感受協(xié)議這也是 ...

好的,感謝




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