取得當前系統時間的方法是直接訪問rtc晶元。
rtc晶元可以通過0x70和0x71埠直接訪問。0x70是選址暫存器,0x71是資料暫存器。
addr function
==== ****************************************=
** clock/calendar
00 current second for real-time clock
01 alarm second
02 current minute
03 alarm minute
04 current hour
05 alarm hour
06 current day of week (1=sunday)
07 current date of month
08 current month
09 current year (final two digits; eg, 93)
rtc.h源**如下所示
#ifndef _rtc_h_
#define _rtc_h_
#define rtc_reg_addr 0x70 //定址暫存器
#define rtc_reg_value 0x71 //內容暫存器
#define second_reg 0x0
#define minute_reg 0x2
#define hour_reg 0x4
#define day_week_reg 0x6
#define day_month_reg 0x7
#define month_reg 0x8
#define year_reg 0x9
void localtime();
#endif
rtc.c源**如下所示
#include "io.h"
#include "rtc.h"
#include "video.h"
unsigned char get_second()
unsigned char get_minute()
unsigned char get_hour()
unsigned char get_week_day()
unsigned char get_month_day()
unsigned char get_month()
unsigned char get_year()
void localtime()
第22章 演算法
1 fizzbuzz 編寫乙個程式 列印1 100的數字。碰到3的倍數時,列印 fizz 碰到5的倍數時,列印 buzz 如果是3和5的倍數,列印 fizzbuzz 其餘則列印數字。class fizzbuzz def init self for i in range 1,101 if i 3 0 ...
《心智社會》第22章 表達
1 代原體和多憶體 2 獨原體 3 去專門化 4 學習與教學 5 推理 6 表達 7 原因與從句 預期 是什麼意思?在對話的每個階段中,對話雙方都已經捲入了各種關注和慾望。在這些東西構成的背景中,每個新詞 新描述或者新表達,無論意義有多模糊,都會融入與它最匹配的短時記憶中。我們為什麼能這麼快進行分配...
第3章 第2 2節 預編譯
2.1 函式宣告整體提公升 2.2 變數宣告提公升 2.3 預編譯前奏 1.imply global 暗示全域性變數 即任何變數,如果變數未經宣告就賦值,此變數就為全域性物件所有。eg a 123 eg var a b 123 2.一切宣告的全域性變數,全是window的屬性。eg var a 12...