FSST - Hardwarenahe Programmierung

PCF8563 Read Write

Table of Contents

    Inhalt

    I2C-Routinen

        i2c.frequency(40000);               // I2C Frequenz 40kHz
        char init1[2] = {0x6, 0x00};
        char init2[2] = {0x7, 0xff};
        i2c.write(0x40, init1, 2);
        i2c.write(0x40, init2, 2);
    

    I2C und PCF initiallisieren

        uint8_t value;
        i2c.start();
        i2c.write(PCF8563_ADR_WR);
        i2c.write(address);
        i2c.write(PCF8563_ADR_RD);
        value = i2c.read(0);
        i2c.stop();
    

    Read value von address

        i2c.start();
        i2c.write(PCF8563_ADR_WR);
        i2c.write(address);
        i2c.write(value);
        i2c.stop();
    

    Write value to address

    /***********************************
    name:   const.h    Version: 0.3
    author: PE HTL BULME
    email:  pe@bulme.at
    description:
      Named constants definitions for registers 
      PCF8563 RTC on HIMBED M0 - LPC11U24 
    ***********************************/
     
    #ifndef CONST_H
    #define CONST_H
     
    // Address of RTC
    const uint8_t PCF8563_ADR_WR = 0xA2;
    const uint8_t PCF8563_ADR_RD = 0xA3;
    // Control and status
    const uint8_t CONTROL1 = 0x00;
    const uint8_t CONTROL2 = 0x01;
    // Time and date
    const uint8_t SECONDS = 0x02;   
    const uint8_t MINUTES = 0x03;
    const uint8_t HOURS = 0x04;
    const uint8_t DAYS = 0x05;
    const uint8_t WEEKDAYS = 0x06;
    const uint8_t MONTHS = 0x07;
    const uint8_t YEARS = 0x08;
    // Alarm
    const uint8_t MINUTE_ALARM = 0x09;
    const uint8_t HOUR_ALARM = 0x0A;
    const uint8_t DAY_ALARM = 0x0B;
    const uint8_t WEEKDAY_ALARM = 0x0C;
    // Clock and timer
    const uint8_t CLOCKOUT_FREQ = 0x0D;
    const uint8_t TIMER_CINTROL = 0x0E;
    
    #endif
    

    const.h


    All wikipages