ATMEGA128

ATMEGA128, TWI, I2C, PCF8563

CoyoteUgly 2018. 8. 31. 19:19

ATMEGA128, TWI, I2C, PCF8563



TWI ( I2C ) 포트를 통해 PCF8563 모듈을 제어합니다.

디버깅 메시지를 위해 UART0 포트를 사용하였습니다.



PORTE.0 : UART RXD0
PORTE.1 : UART TXD0
PORTD.0 : TWI Serial Clock
PORTD.1 : TWI Serial Data


0. 참고 자료


1. 모듈

2. HW 구성


3. SW 구성

  • main.c


  • pcf8563.c
  • pcf8563.h
    • void setI2C(unsigned char rtc_addr, unsigned char reg, unsigned char data);
    • unsigned char getI2C(unsigned char rtc_addr, unsigned char reg);
    • void RTC_Init(unsigned char rtc_addr);
    • void PCF8563_setDate(unsigned char rtc_addr, unsigned short year,
      unsigned char mon, unsigned char day);
    • void PCF8563_getDate(unsigned char rtc_addr);
    • void PCF8563_setTime(unsigned char rtc_addr, unsigned char hour,
      unsigned char min, unsigned char sec);
    • void PCF8563_getTime(unsigned char rtc_addr);
  • myI2C.c
  • myI2C.h
    • void TWIInit(void);
    • unsigned char WriteData(unsigned char u8addr, unsigned char *u8data, unsigned char len);
    • unsigned char ReadData(unsigned char u8addr, unsigned char u8reg, unsigned char *u8data);
  • pcf8563_i2c.prj


4. 소스


5. 결과