PCF8563 clock program

Publisher:云淡雅致Latest update time:2018-01-09 Source: eefocusKeywords:PCF8563 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

PCF8563 clock program

#include 
#include 
#define byte unsigned char 

sbit scl=0x81; //define serial I/O port

sbit sda=0x80; 
idata byte rom_sed[9]; 
idata byte rom_rec[7]; 
idata byte j,k; 
bit flag,flag1; 

void delay(void) //delay subroutine 

data byte i; 
for(i=0;i<6;i++); 


void I_start(void) //Send I2C bus start condition subroutine 

sda=1; 

scl=1; 
delay(); 
sda=0; 
delay(); 
scl=0; 



void I_stop(void) //I2C bus stop condition subroutine 

sda=0; 

scl=1; 
delay(); 
sda=1; 
delay(); 


bit I_send(byte I_data) //Byte data transmission subroutine 

data byte i; 
for(i=0;i<8;i++) 

sda=(bit)(I_data&0x80);  ; 
scl  =0;  delay();  scl  =  1;  ;  ;  //Prepare to receive ACK bit  scl=1  ; ;  ;  //Start receiving ack bit  flag=0;  if(sda==0)flag=0;  else flag=1; //Return(~I_c LOC k());  scl=0;  return(flag);  }  byte I_receive(void) //Byte data receiving subroutine  {  data byte i;  byte I_data=0;  sda=1;  for(i=0;i<8;i++)  {  I_data*=2;  ;  scl=0;  delay();  scl=1;   ;  ;  if(sda==1)I_data++;  ;  ;  }  scl=0;   ;  ;  ;  sda=0;  if(flag1==0) //Not the last ACK  {  ;  ;  scl=1;  delay  ();  scl  =  0;  }  else  //This is the last ACK  {  sda  =1;   ;  sed[3]=0x55; rom_sed[4]=0x23; rom_sed[5]=0x31; rom_sed  [  6  ]  =  0x06  ;  rom_sed  [7]=0x92;  rom_sed[  8]=0x99;  for(i=0;i<255;i++)delay();  I_start();  if(~I_send(0xa2)) //pcf_ write address  {  if(~I_send(0x02)) //pcf_status register address  {  for(i=0;i<9;i++)  { 
















































































if(~I_send(rom_sed[i])); 
else; 

I_stop(); 

else; 

else; 

start: I_start(); 
if(~I_send(0xa2))                 // pcf_write地址 

if(~I_send(0x02))             // pcf_status寄存器地址 

I_start(); 
if(~I_send(0xa3))             //写状态寄存器 

for(i=0;i<7;i++) 

if(i==6) 
flag1=1; 
else 
flag1=0; 
rom_rec[i]=I_receive(); 
switch(i) 

case 1:rom_rec[i]=rom_rec[i]&0x7f;break; 
case 2: 
case 3:rom_rec[i]=rom_rec[i]&0x3f;break; 
case 4:rom_rec[i]=rom_rec[i]&0x07;break; 
case 5:rom_rec[i]=rom_rec[i]&0x9f;break; 
default:break; 


I_stop(); 



goto start; 


Keywords:PCF8563 Reference address:PCF8563 clock program

Previous article:LCD Thermometer Program
Next article:12864 LCD graphic display program without font library

Recommended ReadingLatest update time:2024-11-16 13:58

PCF8563 I2C Real-time Clock Calendar Chip
Overview PCF8563 is a low-power CMOS real-time clock/calendar chip, which provides a programmable clock output, an interrupt output and a power-off detector. All addresses and data are transmitted serially through the I2C bus interface. The maximum bus speed is 400Kbits/s. After each read and write of data, the embedd
[Microcontroller]
PCF8563 I2C Real-time Clock Calendar Chip
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号