Clock chip DS12C887 driver

Publisher:LeishanLatest update time:2016-11-18 Source: eefocus Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

/************************************************************
    Experiment name: Clock chip DS12C887 driver program
    
          Crystal oscillator: internal 8M
 Wiring method:
     1. PD port connects to DS12C887 data I/O port
     2. PA port connects to DS12C887 control port
  
 Instructions for use:
  This program can read and write DS12C887
  
**************************************************************/ 
#include
#include
#define uchar unsigned char
#define CS_H PORTA|=BIT(PA5)  
#define CS_L PORTA&=~BIT(PA5)
#define AS_H PORTA|=BIT(PA4)
#define AS_L PORTA&=~BIT(PA4)
#define R_H PORTA|=BIT(PA3)
#define W_L PORTA&=~BIT(PA3)
#define DS_H PORTA|=BIT(PA2)
#define DS_L PORTA&=~BIT(PA2)
void delay(int k) //delay
{
   int i;           
  for(i=0;i  ;
}
void init_ds12887() //initialize DS12C887

    DDRA=0xff; //control port
  DDRD=0xff; //data port
  delay(10);
  R_H ;
  delay(10);
  DS_H;
  delay(10);
  DS_L;
  delay(10);
  AS_L;
  delay(10);
  AS_H;

}
void write_ds12887(uchar addr,uchar data)//向DS12C887写入数据
{
   init_ds12887();
  PORTD=addr;
  CS_L; 
  delay(10);
  AS_L;
  delay(10);
  W_L ;
  delay(10);
  DS_H;
  PORTD=data;
  delay(10);
  DS_L;
  delay(10);
  AS_H;
  delay(10);
  CS_H;
}
uchar read_ds12887(uchar addr)//从DS12C887读出数据 
{
    uchar data;
   init_ds12887();
   CS_L;
   delay(10);
   PORTD=addr;
   AS_L;
   delay(10);
   R_H ;
   PORTD=0x00;
   DDRD=0x00;
   delay(10);
   DS_H;
   delay(10);
   data=PIND;
   return data;
   DS_L;
   delay(10);
   AS_H;
   delay(10);
   CS_H;
}


Reference address:Clock chip DS12C887 driver

Previous article:DS1302 driver (automatic adjustment of days in common and leap years)
Next article:ISD2560 recording and playback control program

Recommended ReadingLatest update time:2024-11-15 14:53

This year, the domestic Continental Group released the third-generation electric drive system
Recently, German auto parts manufacturer Continental AG demonstrated the third-generation all-electric drive system developed by the company. It is reported that the drive system weighs less than 80kg and can provide two rated power outputs of 120kW (163Ps) or 150kW (204Ps). The new drive system will also be put into
[Automotive Electronics]
This year, the domestic Continental Group released the third-generation electric drive system
Driving High-Performance ASICs and Microprocessors with Multiphase DC-DC Converters
        Multi-phase DC-DC converter leads   Today's high-performance ASICs and microprocessors have been widely used in various fields such as industrial control, communications, and aerospace. However, due to its high power consumption, sometimes up to 150W or even more, for a power supply voltage of 1V to 1.5V, th
[Power Management]
FII implements the dual-drive strategy of "intelligent manufacturing + industrial Internet"
Recently, Foxconn Industrial Internet has signed the "Share Purchase and Sale Agreement on Dingzhi Software Co., Ltd." (hereinafter referred to as the "Share Purchase and Sale Agreement") with DC Software and Talent Gain Developments Limited. Foxconn Industrial Internet will acquire 39,971,265 shares of Dingzhi Softwa
[Embedded]
FII implements the dual-drive strategy of
NSK successfully develops the world's first "non-contact torque sensor" for automotive drive shafts
NSK Ltd. (NSK) announced on July 7, 2020 that it has successfully developed the world's first torque sensor for real-time measurement of automotive drive shaft torque. This newly developed product measures torque by measuring the magnetic changes caused by the torsional deformation of the drive shaft. By simplifying t
[Automotive Electronics]
NSK successfully develops the world's first
Design and test of high-speed laser driving circuit
Since the invention of the laser by Theodore H Maiman 50 years ago, lasers have been widely used in various technical fields, such as communications, industrial production , as well as sensors, measuring equipment, etc. While the communications industry focuses on high-speed transmission frequencies reaching the GHz ra
[Test Measurement]
Design and test of high-speed laser driving circuit
max532 driver
/* DA MAX532 debug */ //Note: Vref and Vout should be connected together when debugging #include "reg51.h" sbit MAX532_CS=P1^0; sbit MAX532_DIN=P1^1; sbit MAX532_SCLK=P1^2; void MAX532_OUT(unsigned char daout1,unsigned char daout2,unsigned char daout3); void delay() {  unsigned int i,j;  for(i=0;i 1000;i++)
[Microcontroller]
AMD releases new P-State EPP driver to improve CPU power efficiency in Linux environments
AMD recently updated its P-state EPP driver for Linux-based computers, providing a good boost in CPU power efficiency. The company is using ACPI CPPC energy preference performance information to control the power of the CPU, making the processor more efficient and improving performance. AMD's EPP driver works by tak
[Embedded]
Seoul Semiconductor files lawsuit against SATCO for infringing its LED driver patents
Seoul Semiconductor (“Seoul”), an internationally renowned LED specialist, announced that it has filed another lawsuit alleging infringement of its LED driver patents, this time against SATCO Products, Inc. (“SATCO”).       In its complaint, Seoul claims that various LED lighting products being sold by SATCO infring
[Mobile phone portable]
Latest Microcontroller Articles
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号