Kit OpenM128 com RTC PCF8563

Olá,

Mais um relógio, desta vez temos o chip PCF8563, neste caso este funciona com TWI ( Two Wire Interface ) o conhecido I2C, sendo que apenas usa SCA e SCL do Atmega128, disponibilizo aqui as bibliotecas.

 

 

 

Clock PCF8563
/*
 * LCD22_PCF8563.c
 * http://www.microelectronic.pt
 * Created: 05-03-2017
 *  Author: Norlinux
 */ 

#include <avr/io.h>
#include <stdio.h>
#define F_CPU 16000000UL
#include <util/delay.h>
#include <avr/interrupt.h>

#include "LCD/LTM022A69B.h"
#include "LCD/LCD_lib.h"
#include "rtc/ws_iic_port.h"
#include "rtc/ws_pcf8563_port.h"


int main(void)
{
	DDRA=0xFF;
	PORTA=0x00;

	uint8_t time[3];
	uint8_t Flag,Flag1;
	char Buf[20]={};
lcd_init();
lcd_display_string( "CPU:ATMEGA128A-AU      ", BLACK, GREEN, 3, 3 );
lcd_display_string( "WWW.MICROELECTRONIC.PT ", BLACK, GRAYBLUE, 3, 5 );
twi_init();
PCF8563_init();
PCF8563_setTime(20,46,0);

	while(1)
	{
		while(1)
		{
			PCF8563_getTime(time);

			if(Flag1 != Flag)
			{
				PORTA = time[0];
				sprintf(Buf,"CLOCK = %d:%d:%d",time[2],time[1],time[0]);
				lcd_display_string( Buf, WHITE, RED, 3, 8); 
				Flag1=Flag;
			}
			Flag = time[0];
		}

	}
}

2 comentários

    • Majerle on 28 Dezembro, 2017 at 21:23
    • Responder

    Hi,
    Great Job!
    I can’t download the source code, please can you send for my e-mail??

    1. Fixed the link & send by e-mail 🙂

Deixe uma resposta

Your email address will not be published.

www.000webhost.com