⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 12c887.lst

📁 利用热释红外传感器、12C887和PIC单片机制作的智能电子时钟
💻 LST
字号:
     1: #include <pic.h>

     2: #include "12c887.h";

     3: 

     4: /////////////   SUNROUTINE DECLARE   /////////////

     5: void _12cc877_init(void);                                   // initialize RTC 12C887

     6: extern _12c887_read(unsigned char ADDRESS);                            // 12C887 data read routine

     7: extern _12c887_write(unsigned char ADDRESS,unsigned char DATA);        // 12C887 data write routine

     8: 

     9: /////////////////// SUBROUTINE ///////////////////

    10: _12c887_init()              // initialize RTC 12c887

    11: {

    12:     _12c887_write(SECOND,0x00);     // write current time

    13:     _12c887_write(MINUTE,0x54);

    14:     _12c887_write(HOUR,0x15);

    15:     _12c887_write(DayOfWeek,0x01);

    16:     _12c887_write(DayOfMonth,0x24);

    17:     _12c887_write(MONTH,0x09);

    18:     _12c887_write(YEAR,0x07);

    19:     _12c887_write(CENTURY,0x20);

    20:     _12c887_write(REGA,0b10101111); // configure the control register

    21:     _12c887_write(REGB,0b01111010);

    22:     _12c887_write(REGC,0b00000000);

    23: }

    24: 

    25: _12c887_read(unsigned char ADDRESS) // read 12c887 data

    26: {

    27:     unsigned char temp;

    28:     TRISD=0x00;

    29:     WR=1;

    30:     RD=1;

    31:     ALE=1;

    32:     CS=0;

    33:     PORTD=ADDRESS;

    34:     ALE=0;

    35:     TRISD=0xff;

    36:     RD=0;

    37:     temp=PORTD;

    38:     RD=1;

    39:     CS=1;

    40:     ALE=1;

    41:     return(temp);

    42: }

    43: 

    44: _12c887_write(unsigned char ADDRESS,unsigned char DATA) // write 12c887 data

    45: {

    46:     TRISD=0x00;

    47:     WR=1;

    48:     RD=1;

    49:     ALE=1;

    50:     CS=0;

    51:     PORTD=ADDRESS;

    52:     ALE=0;

    53:     PORTD=DATA;

    54:     WR=0;

    55:     WR=1;

    56:     ALE=1;

    57:     CS=1;

    58: }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -