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. 참고 자료
- https://embedds.com/programming-avr-i2c-interface/
- http://artoa.hanbat.ac.kr/lecture_data/microprocessor/2014/%EC%A0%9C11%EC%9E%A5%20%EC%8B%9C%EB%A6%AC%EC%96%BC%20%EC%9D%B8%ED%84%B0%ED%8E%98%EC%9D%B4%EC%8A%A4%20(HBE-MCU-Multi%20AVR).pdf
- http://electronicsdo.tistory.com/entry/I2C-The-I2C-of-ATmega128
- http://webnautes.tistory.com/671
- http://openctrl.tistory.com/entry/I2C-TWI
- http://read.pudn.com/downloads157/doc/comm/699258/Atmega128-TWI-2008.pdf
- http://ww1.microchip.com/downloads/en/DeviceDoc/doc2467.pdf
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. 결과
'ATMEGA128' 카테고리의 다른 글
ATMEGA128, CodeVisonAVR, ADC, rotation_sensor (0) | 2018.09.01 |
---|---|
ATMEGA128, SPI, AT45DBXX Data Flash (0) | 2018.09.01 |
ATMEGA128, CodeVisonAVR, TWI, I2C, LCD1602 (1) | 2018.08.31 |
ATMEGA128, CodeVisonAVR, TIMER, pwm_led (0) | 2018.08.30 |
ATMEGA128, CodeVisonAVR, TIMER, timer_compare_intr_1ms (0) | 2018.08.30 |