Arkadaşlar Merhaba;
Daha önce calışan ds1307 kütüphanesi şimdi çalışmaz oldu. 2 gündür uğraşıyorum. Sizce nerde hata yapıyorum.
Yardım edermisiniz.
Herkese iyi çalışmalar
newmain18.c /*
* File: newmain18.c
* Author: CNC
*
* Created on 05 Ekim 2014 ÃarÅamba, 23:47
*/
#define _XTAL_FREQ 10000000
#include <xc.h>
#include <stdlib.h>
#include <stdio.h>
#include "ds1307.h"
#include "xsLCD.h"
// #pragma config statements should precede project file includes.
// Use project enums instead of #define for ON and OFF.
// CONFIG1H
#pragma config OSC = XT // Oscillator Selection bits (HS oscillator with PLL enabled/Clock frequency = (4 x FOSC))
#pragma config OSCS = OFF // Oscillator System Clock Switch Enable bit (Oscillator system clock switch option is enabled (oscillator switching is enabled))
// CONFIG2L
#pragma config PWRT = OFF // Power-up Timer Enable bit (PWRT disabled)
#pragma config BOR = OFF // Brown-out Reset Enable bit (Brown-out Reset disabled)
#pragma config BORV = 20 // Brown-out Reset Voltage bits (VBOR set to 2.0V)
// CONFIG2H
#pragma config WDT = OFF // Watchdog Timer Enable bit (WDT disabled (control is placed on the SWDTEN bit))
#pragma config WDTPS = 128 // Watchdog Timer Postscale Select bits (1:128)
// CONFIG3H
#pragma config CCP2MUX = OFF // CCP2 Mux bit (CCP2 input/output is multiplexed with RB3)
// CONFIG4L
#pragma config STVR = OFF // Stack Full/Underflow Reset Enable bit (Stack Full/Underflow will not cause RESET)
#pragma config LVP = OFF // Low Voltage ICSP Enable bit (Low Voltage ICSP disabled)
// CONFIG5L
#pragma config CP0 = OFF // Code Protection bit (Block 0 (000200-001FFFh) not code protected)
#pragma config CP1 = OFF // Code Protection bit (Block 1 (002000-003FFFh) not code protected)
#pragma config CP2 = OFF // Code Protection bit (Block 2 (004000-005FFFh) not code protected)
#pragma config CP3 = OFF // Code Protection bit (Block 3 (006000-007FFFh) not code protected)
// CONFIG5H
#pragma config CPB = OFF // Boot Block Code Protection bit (Boot Block (000000-0001FFh) not code protected)
#pragma config CPD = OFF // Data EEPROM Code Protection bit (Data EEPROM not code protected)
// CONFIG6L
#pragma config WRT0 = OFF // Write Protection bit (Block 0 (000200-001FFFh) not write protected)
#pragma config WRT1 = OFF // Write Protection bit (Block 1 (002000-003FFFh) not write protected)
#pragma config WRT2 = OFF // Write Protection bit (Block 2 (004000-005FFFh) not write protected)
#pragma config WRT3 = OFF // Write Protection bit (Block 3 (006000-007FFFh) not write protected)
// CONFIG6H
#pragma config WRTC = OFF // Configuration Register Write Protection bit (Configuration registers (300000-3000FFh) not write protected)
#pragma config WRTB = OFF // Boot Block Write Protection bit (Boot Block (000000-0001FFh) not write protected)
#pragma config WRTD = OFF // Data EEPROM Write Protection bit (Data EEPROM not write protected)
// CONFIG7L
#pragma config EBTR0 = OFF // Table Read Protection bit (Block 0 (000200-001FFFh) not protected from Table Reads executed in other blocks)
#pragma config EBTR1 = OFF // Table Read Protection bit (Block 1 (002000-003FFFh) not protected from Table Reads executed in other blocks)
#pragma config EBTR2 = OFF // Table Read Protection bit (Block 2 (004000-005FFFh) not protected from Table Reads executed in other blocks)
#pragma config EBTR3 = OFF // Table Read Protection bit (Block 3 (006000-007FFFh) not protected from Table Reads executed in other blocks)
// CONFIG7H
#pragma config EBTRB = OFF // Boot Block Table Read Protection bit (Boot Block (000000-0001FFh) not protected from Table Reads executed in other blocks)
signed char ekrandegiskeni[100]=0;
signed char ustekrandegiskeni[100]=0;
signed char altekrandegiskeni[100]=0;
unsigned char okunanSaat=0;
unsigned char okunanDakika=0;
unsigned char okunanSaniye=0;
unsigned char yaz1[]="";
unsigned char charToString(unsigned char _yaz1);
void ayarlar(void)
{
ADCON1=0x07;
TRISA=0b00000000;
TRISB=0b00000001;
TRISC=0b11100000;
TRISD=0b11110000;
TRISE=0b00000000;
PORTA=0x00;
PORTB=0x00;
PORTC=0x00;
PORTD=0x00;
PORTE=0x00;
lcd_baslat();
}
void main(void)
{
ayarlar();
while (1)
{
__delay_ms(50);
__delay_ms(50);
ds1307_saat_oku(&okunanSaniye,&okunanDakika,&okunanSaat);
charToString(okunanSaat);
lcd_mesajyaz(1,1,yaz1),lcd_mesajyaz_cp(":");
charToString(okunanDakika);
lcd_mesajyaz_cp(yaz1),lcd_mesajyaz_cp(":");
charToString(okunanSaniye);
lcd_mesajyaz_cp(yaz1);
}
}
char charToString(unsigned char _yaz1)
{
sprintf(yaz1,"%.2u",_yaz1);
return yaz1;
}
ds1307.c /*
* File: ds1307.c
* Author: Tolga
*
* Created on 08 Aral?k 2013 Pazar, 15:12
*/
#include <xc.h>
#include "plib/i2c.h"
#include "ds1307.h"
void yaz(unsigned char adr,unsigned char temp);
unsigned char oku(unsigned char adr2);
unsigned char Binary2BCD(unsigned char a);
char BCD2Binary(char a);
#define i2c
unsigned char ds1307_saat_yaz (unsigned char *seconds,unsigned char *minutes,unsigned char *hours)
{
unsigned char temp;
OpenI2C(MASTER, SLEW_OFF); // Initialize I2C module
SSPADD = 24; //100kHz Baud clock @8MHz = 19 //SSPADD = ((FOSC/ Bit Rate) /4 ) - 1
temp=Binary2BCD(seconds);
yaz(0,temp);
temp=Binary2BCD(minutes);
yaz(1,temp);
temp=Binary2BCD(hours);
yaz(2,temp);
}
unsigned char ds1307_tarih_yaz (unsigned char *day,unsigned char *date,unsigned char *month,unsigned char *year)
{
unsigned char temp;
OpenI2C(MASTER, SLEW_OFF); // Initialize I2C module
SSPADD = 24; //100kHz Baud clock @8MHz = 19 //SSPADD = ((FOSC/ Bit Rate) /4 ) - 1
temp=Binary2BCD(day);
yaz(3,temp);
temp=Binary2BCD(date);
yaz(4,temp);
temp=Binary2BCD(month);
yaz(5,temp);
temp=Binary2BCD(year);
yaz(6,temp);
}
unsigned char ds1307_saat_oku (unsigned char *seconds,unsigned char *minutes,unsigned char *hours)
{
unsigned char temp;
OpenI2C(MASTER, SLEW_OFF); // Initialize I2C module
SSPADD = 24; //100kHz Baud clock @8MHz = 19 //SSPADD = ((FOSC/ Bit Rate) /4 ) - 1
temp=oku(0);
*seconds=BCD2Binary(temp);
temp=oku(1);
*minutes=BCD2Binary(temp);
temp=oku(2);
*hours=BCD2Binary(temp);
}
unsigned char ds1307_tarih_oku (unsigned char *day,unsigned char *date,unsigned char *month,unsigned char *year)
{
unsigned char temp;
OpenI2C(MASTER, SLEW_OFF); // Initialize I2C module
SSPADD = 24;
temp=oku(3);
*day=BCD2Binary(temp);
temp=oku(4);
*date=BCD2Binary(temp);
temp=oku(5);
*month=BCD2Binary(temp);
temp=oku(6);
*year=BCD2Binary(temp);
}
void yaz(unsigned char adr1,unsigned char temp1)
{
StartI2C(); // begin I2C communications
IdleI2C();
WriteI2C( 0xD0 ); // addresses the chip
IdleI2C();
WriteI2C( adr1 ); // access register address for minutes check table 2 above.
IdleI2C();
WriteI2C( temp1 ); // write value into minutes register
IdleI2C();
StopI2C();
}
unsigned char oku(unsigned char adr2)
{
unsigned char resultI2C;
StartI2C(); // Start condition I2C on bus
IdleI2C();
WriteI2C( 0xD0 ); // addresses the chip
IdleI2C();
WriteI2C( adr2 ); // write register address 0x03 for the day of the week (Table 2 above)
IdleI2C();
StopI2C(); // Stop condition I2C on bus
StartI2C(); // Start condition I2C on bus
IdleI2C();
WriteI2C( 0xD1 ); // addresses the chip with a read bit: 7-bit address ?1101000? plus a 1 bit to read
//which gives 0xD1
IdleI2C();
resultI2C= ReadI2C(); // read the value from the RTC and store in resultI2C variable.
IdleI2C();
NotAckI2C(); // Not Acknowledge condition. The not-acknowledge will signal the RTC that
// reading data has completed.
IdleI2C();
StopI2C(); // Stop condition I2C on bus
return resultI2C;
}
unsigned char Binary2BCD(unsigned char a) //Convert Binary to BCD so we can write to the DS1307 Register in BCD
{
unsigned char r,t;
r = a/10;
t = a%10;
t = t & 0x0F;
r = r << 4;
r = r & 0xf0;
r = r|t;
return r;
}
unsigned char BCD2Binary(unsigned char a) //Convert BCD to Binary so we can do some basic calculations
{
unsigned char r,t;
t = a & 0x0F;
r = t;
a = 0xF0 & a;
t = a >> 4;
t = 0x0F & t;
r = t*10 + r;
return r;
}
xsLCD.c /*******************************************************************************
* Kütüphane : xsLCD *
* Yazar : sigmoid *
* Web : http://www.hayaldefteri.net *
* BaÅlangıç : 01 Mayıs 2014 *
* Son Düzenleme : 04 Mayıs 2014 *
* Versiyon : 0.1 *
* *
* HD44780 karakter LCD kütüphanesi (4bit ve 8 bit modlu) *
******************************************************************************/
#include <xc.h>
#include "xsLCD.h"
//DeÄiÅkenler
char display_kursor_blink; //display,kursor ve blink aç kapat komutları için.
/*******************************************************************************
* LCD ekranı çalıÅtırır. Ä°lk önce bu fonksiyon çalıÅtırılmalıdır. *
*******************************************************************************/
#ifdef LCDBIT8
void lcd_baslat(void)
{
char _i;
lcd_tris=0x00; //lcd'nin baÄlandıÄı pinler çıkıÅ
lcd_tris_rs=0;
lcd_tris_e=0;
#ifdef lcd_rw_aktif
lcd_tris_rw=0;
#endif
__delay_ms(20);
lcd_rs=0;
#ifdef lcd_rw_aktif
lcd_rw=0;
#endif
lcd_e=0;
lcd_data=0x38; //8 bit mod
lcd_e=1;
__delay_us(1);
lcd_e=0;
__delay_us(1);
__delay_ms(5);
__delay_us(40);
lcd_komut(0x0C); //display on
display_kursor_blink=0x0C;
__delay_us(40);
lcd_komut(0x06); //cursor ileri
__delay_ms(2);
}
#endif
#ifdef LCDBIT4
void lcd_baslat(void)
{
#ifdef LCDustpin
lcd_tris= lcd_tris & 0x0f;
#endif
#ifdef LCDaltpin
lcd_tris=lcd_tris & 0xf0;
#endif
lcd_tris_e=0;
lcd_tris_rs=0;
#ifdef lcd_rw_aktif
lcd_tris_rw=0;
lcd_rw=0;
#endif
__delay_ms(20);
lcd_rs=0;
lcd_e=0;
#ifdef LCDustpin
lcd_data=0x20 | (lcd_data & 0x0f); //4 bit mod
#endif
#ifdef LCDaltpin
lcd_data=0x02 | (lcd_data &0xf0); //4 bit mod
#endif
lcd_e=1;
__delay_us(1);
lcd_e=0;
__delay_ms(5);
lcd_komut(0x28);
__delay_us(40);
lcd_komut(0x0C); //display on
__delay_us(40);
lcd_komut(0x06); //cursor ileri
__delay_ms(2);
}
#endif
/*******************************************************************************
* Ä°stenilen pozisyona gider. *
* Ãrnek: lcd_git(2,5); *
*******************************************************************************/
void lcd_git(char satir, char sutun)
{
char temp;
switch(satir)
{
case 1:
temp=sutun-1+ 0x80;
break;
case 2:
temp= sutun-1+0xc0;
break;
case 3:
temp= (sutun-1+0x94);
break;
case 4:
temp= (sutun-1+0xd4);
break;
}
lcd_komut(temp);
__delay_us(100);
}
/*******************************************************************************
* İstenilen poziyonda ekrana yazı yazar. *
* Ãrnek : lcd_mesajyaz(1,4,"Deneme"); *
*******************************************************************************/
void lcd_mesajyaz(char satir, char sutun, const char *mesaj)
{
lcd_git(satir,sutun);
do
{
lcd_harfyaz(*mesaj++);
}while(*mesaj);
}
/*******************************************************************************
* Lcd ekrana en son kaldıÄı pozisyondan itibaren yazı yazar. *
* Ãrnek : lcd_mesajyaz_cp("deneme"); *
*******************************************************************************/
void lcd_mesajyaz_cp(const char *mesaj)
{
do
{
lcd_harfyaz(*mesaj++);
}while(*mesaj);
}
/*******************************************************************************
* Lcd meÅgul olduÄu sürece bu fonksiyon içinde bekler.. *
* Lcd_komut ve lcd_harfyaz fonksiyonları bu fonksiyonu kullanır. *
*******************************************************************************/
#ifdef lcd_rw_aktif
#ifdef LCDBIT8
void lcd_mesgulmu(void)
{
char temp;
lcd_rs=0;
lcd_rw=1;
lcd_tris=0xff;
do
{
__delay_us(1);
lcd_e=1;
__delay_us(1);
lcd_e=0;
temp=lcd_data & 0x80;
}while(temp);
lcd_tris=0x00;
}
#endif
#ifdef LCDBIT4
void lcd_mesgulmu(void)
{
char temp,temp2;
lcd_rs=0;
lcd_rw=1;
#ifdef LCDustpin
lcd_tris=0xf0 | lcd_tris;
#endif
#ifdef LCDaltpin
lcd_tris=0x0f | lcd_tris;
#endif
do
{
__delay_us(1);
lcd_e=1;
__delay_us(1);
lcd_e=0; //high byte oku
#ifdef LCDustpin
temp=lcd_data & 0x80;
#endif
#ifdef LCDaltpin
temp=lcd_data & 0x08;
#endif
__delay_us(1);
lcd_e=1;
__delay_us(1);
lcd_e=0; //low byte oku, ama herhangi bir deÄiÅkene kaydetmeye gerek yok.
}while(temp);
#ifdef LCDustpin
lcd_tris=lcd_tris & 0x0f;
#endif
#ifdef LCDaltpin
lcd_tris=lcd_tris & 0xf0;
#endif
}
#endif
#else
void lcd_mesgulmu(void)
{
__delay_us(100); //bekle.
}
#endif
/*******************************************************************************
* Lcd ekrana tek bir harf yazar. *
* Ãrnek : lcd_harfyaz('A'); *
*******************************************************************************/
#ifdef LCDBIT8
void lcd_harfyaz(char harf)
{
lcd_mesgulmu();
lcd_rs=1;
#ifdef lcd_rw_aktif
lcd_rw=0;
#endif
lcd_data=harf;
lcd_e=1;
__delay_us(1);
lcd_e=0;
__delay_us(200);
}
#endif
#ifdef LCDBIT4
void lcd_harfyaz(char harf)
{
lcd_mesgulmu();
lcd_rs=1;
#ifdef lcd_rw_aktif
lcd_rw=0;
#endif
#ifdef LCDustpin
lcd_data = (lcd_data & 0x0f) | (harf & 0xf0); //high verisini gönder.
#endif
#ifdef LCDaltpin
lcd_data = (lcd_data & 0xf0) | (harf >>4);
#endif
lcd_e=1;
__delay_us(1);
lcd_e=0;
__delay_us(200);
#ifdef LCDustpin
lcd_data = (lcd_data & 0x0f) | (harf << 4); //low verisini gönder.
#endif
#ifdef LCDaltpin
lcd_data = (lcd_data & 0xf0) | (harf & 0x0f);
#endif
lcd_e=1;
__delay_us(1);
lcd_e=0;
__delay_us(200);
}
#endif
/*******************************************************************************
* Lcd ekrandan tek bir harf okur *
*******************************************************************************/
#ifdef lcd_rw_aktif
#ifdef LCDBIT8
char lcd_harfoku(void)
{
char temp;
lcd_mesgulmu();
lcd_rs=1;
lcd_rw=1;
lcd_tris=0xff;
lcd_e=1;
__delay_us(1);
temp=lcd_data;
lcd_e=0;
__delay_us(1);
lcd_tris=0x00;
return temp;
}
#endif
#ifdef LCDBIT4
//task: yazılacak
char lcd_harfoku(void)
{
char temp,harf1,harf2;
lcd_mesgulmu();
#ifdef LCDustpin
lcd_tris=0xf0 | lcd_tris;
#endif
#ifdef LCDaltpin
lcd_tris=0x0f | lcd_tris;
#endif
lcd_rs=1;
lcd_rw=1;
lcd_e=1;
__delay_us(1);
#ifdef LCDustpin
harf1 = (lcd_data & 0xf0); //high verisini al.
#endif
#ifdef LCDaltpin
harf1 = (lcd_data & 0x0f)<<4 ;
#endif
lcd_e=0;
__delay_us(1);
lcd_e=1;
__delay_us(1);
#ifdef LCDustpin
harf2=(lcd_data & 0xf0)>>4 ; //low verisini al.
#endif
#ifdef LCDaltpin
harf2=(lcd_data & 0x0f);
#endif
lcd_e=0;
__delay_us(1);
temp= harf1 | harf2; //üst ve alt veriyi birleÅtir.
#ifdef LCDustpin
lcd_tris=lcd_tris & 0x0f;
#endif
#ifdef LCDaltpin
lcd_tris=lcd_tris & 0xf0;
#endif
return temp;
}
#endif
#endif
/*******************************************************************************
* Lcd komutlarını gönderir. *
*******************************************************************************/
#ifdef LCDBIT8
void lcd_komut(char komut)
{
lcd_mesgulmu();
lcd_rs=0;
#ifdef lcd_rw_aktif
lcd_rw=0;
#endif
lcd_data=komut;
lcd_e=1;
__delay_us(1);
lcd_e=0;
__delay_ms(5);
}
#endif
#ifdef LCDBIT4
void lcd_komut(char komut)
{
lcd_mesgulmu();
lcd_rs=0;
#ifdef lcd_rw_aktif
lcd_rw=0;
#endif
#ifdef LCDustpin
lcd_data = (lcd_data & 0x0f) | (komut & 0xf0); //high verisini gönder.
#endif
#ifdef LCDaltpin
lcd_data = (lcd_data & 0xf0) | (komut >>4);
#endif
lcd_e=1;
__delay_us(1);
lcd_e=0;
__delay_ms(5);
#ifdef LCDustpin
lcd_data = (lcd_data & 0x0f) | (komut << 4); //low verisini gönder.
#endif
#ifdef LCDaltpin
lcd_data = (lcd_data & 0xf0) | (komut & 0x0f);
#endif
lcd_e=1;
__delay_us(1);
lcd_e=0;
__delay_ms(5);
}
#endif
/*******************************************************************************
* Lcd ekranda özel karakter oluÅturur. *
*******************************************************************************/
void lcd_ozelkarakter(char karakterno,char patern[8])
{
char temp,i;
temp= 0x40 | (karakterno<<3);
lcd_komut(temp);
for(i=0;i<8;i++)
{
lcd_harfyaz(patern[i]);
}
lcd_satirbasi();
}
/*******************************************************************************
* Lcdyi siler. *
* Ãrnek : lcd_sil(); *
*******************************************************************************/
void lcd_sil(void)
{
lcd_komut(0x01);
}
/*******************************************************************************
* 1. sat?r 1. sutuna gider *
*******************************************************************************/
void lcd_satirbasi(void)
{
lcd_komut(0x02);
}
/*******************************************************************************
* Kursörü aktif yapar *
*******************************************************************************/
void lcd_kursor_ac(void)
{
display_kursor_blink=0x0E;
lcd_komut(display_kursor_blink);
}
/*******************************************************************************
* Kürsörü kapatır. *
*******************************************************************************/
void lcd_kursor_kapat(void)
{
display_kursor_blink=0xC;
lcd_komut(display_kursor_blink);
}
/*******************************************************************************
* LCD Displayi açar. *
*******************************************************************************/
void lcd_display_ac(void)
{
display_kursor_blink=0x0C;
lcd_komut(display_kursor_blink);
}
/*******************************************************************************
* LCD Displayi kapatır. *
*******************************************************************************/
void lcd_display_kapat(void)
{
display_kursor_blink=0x08;
lcd_komut(display_kursor_blink);
}
/*******************************************************************************
* Kürsör ekranda yanıp söner *
*******************************************************************************/
void lcd_blink_ac(void)
{
display_kursor_blink=0x0F;
lcd_komut(display_kursor_blink);
}
/*******************************************************************************
* Kürsörün ekranda yanıp sönme özelliÄini kapatır. *
*******************************************************************************/
void lcd_blink_kapat(void)
{
display_kursor_blink=0x0C;
lcd_komut(display_kursor_blink);
}
/*******************************************************************************
* LCD ekranı sola kaydırır. *
*******************************************************************************/
void lcd_sola_kaydir(void)
{
lcd_komut(0x18);
}
/*******************************************************************************
* LCD ekranı saÄa kaydırır. *
*******************************************************************************/
void lcd_saga_kaydir(void)
{
lcd_komut(0x1C);
}
/*******************************************************************************
* 1. satır 1. sutuna gider *
*******************************************************************************/
void lcd_satir1(void)
{
lcd_komut(0x80);
}
/*******************************************************************************
* 2. satır 1. sutuna gider *
*******************************************************************************/
void lcd_satir2(void)
{
lcd_komut(0xc0);
}
/*******************************************************************************
* 3. satır 1. sutuna gider *
*******************************************************************************/
void lcd_satir3(void)
{
lcd_komut(0x94);
}
/*******************************************************************************
* 4. satır 1. sutuna gider *
*******************************************************************************/
void lcd_satir4(void)
{
lcd_komut(0xd4);
}
/*******************************************************************************
* printf fonksiyonu için *
*******************************************************************************/
#ifdef lcdprintf_aktif
void putch(unsigned char byte)
{
lcd_harfyaz(byte);
}
#endif
ds1307.h /*
* File: ds1307.h
* Author: Tolga
*
* Created on 08 Aral?k 2013 Pazar, 17:16
*/
#ifndef ds1307_H
#define ds1307_H
extern unsigned char ds1307_saat_yaz (unsigned char *seconds,unsigned char *minutes,unsigned char *hours);
extern unsigned char ds1307_tarih_yaz (unsigned char *day,unsigned char *date,unsigned char *month,unsigned char *year);
extern unsigned char ds1307_saat_oku (unsigned char *seconds,unsigned char *minutes,unsigned char *hours);
extern unsigned char ds1307_tarih_oku (unsigned char *day,unsigned char *date,unsigned char *month,unsigned char *year);
#endif
xsLCD.h //#define LCDBIT8 //lcd ekrana 8bit mi eriÅilecek
#define LCDBIT4 //yoksa 4 bit mi?
#define LCDustpin //4bit eriÅilecekse hangi pinler kullanılacak
//#define LCDaltpin
//RW pini PIC'e mi yoksa TopraÄa mı baÄlı
//#define lcd_rw_aktif
//printf fonksiyonu lcd'ye yazacak mı?
#define lcdprintf_aktif
// kullanılacak lcd ayaklar?
#define lcd_data PORTB
#define lcd_tris TRISB
#define lcd_rs PORTBbits.RB2
#define lcd_tris_rs TRISBbits.TRISB2
#define lcd_rw PORTAbits.RA1
#define lcd_tris_rw TRISAbits.TRISA1
#define lcd_e PORTBbits.RB3
#define lcd_tris_e TRISBbits.TRISB3
//fonksiyon prototipleri
void lcd_baslat(void);
void lcd_git(char satir, char sutun);
void lcd_mesajyaz(char satir, char sutun, const char *mesaj);
void lcd_mesajyaz_cp(const char *mesaj);
#ifdef lcd_rw_aktif
void lcd_mesgulmu(void);
char lcd_harfoku(void);
#endif
void lcd_harfyaz(char harf);
void lcd_ozelkarakter(char karakterno,char patern[8]);
void lcd_komut(char komut);
void lcd_sil(void);
void lcd_satirbasi(void);
void lcd_kursor_ac(void);
void lcd_kursor_kapat(void);
void lcd_display_ac(void);
void lcd_display_kapat(void);
void lcd_blink_ac(void);
void lcd_blink_kapat(void);
void lcd_sola_kaydir(void);
void lcd_saga_kaydir(void);
void lcd_satir1(void);
void lcd_satir2(void);
void lcd_satir3(void);
void lcd_satir4(void);
#ifdef lcdprintf_aktif
void putch(unsigned char byte);
#endif
çalışmaz olan nedir, veri mi gelmiyor, geliyor da yanlış mı geliyor, senden okuma komutu gidiyor mu. Bunların cevapları olmadan sana yardım edebilmemiz zor. Logic analyzer ve ya osciloscope ile hattı dinlemeni öneririm. Verdiğin kodlarda I2C kütüphanesi yok, derleyiciden gelen bir kod mu o, sen mi yazdın. Software mi kullanıyorsun hardware mi? Pinleri nerede yapılandırıyorsun vs vs.
Bu kadar kodun içinde çalışmaya kısmı bulmak cok problem :| biraz daha detay verseniz devre nasıl ? kodda hata veriyor mu ? lcd de hiç bilgi var mı ? hatalı okumamı yapıyor ?
arkadaşım veri gelmiyor, ben ds1307_saat_oku(&okunanSaniye,&okunanDakika,&okunanSaat) yazdığımda saat,dakika ve saniye bilgisi gelmesi gerekiyor. Ama gelmiyor.I2C kütüphanesi derleyiciye ait.Lcd de 00:00:00 yazıyor.
(http://s29.postimg.cc/6plkwuhw3/Ekran_Al_nt_s.jpg) (http://postimg.cc/image/6plkwuhw3/)
Bana kalırsa ben proton kullanıyorum ama ilk açılışta bazı konfigrasyon ve başlat datası gönderilmesi gerekiyor.Bunun gibi bir komut icra ediyormu yazdığınız kodlarda yada kütüphanede.
DS1307'de kristal yok.
benim bildiğim simülasyonda kristal olmadanda çalışıyordu.Kristal Bagladığımda da bi değişme olmadı.
DS1307 kristalsiz alışmaz. Kristal 32768 Hz olması gerekir. Simulasyon kristali bağlı kabul ettiği için çalışır sizi yanıltmasın.
DS1307 nin Saniye registerinin 7. biti Clock Halt bitidir. Fabrikadan bu bit 1 olarak ayarlanır. Bu bit 1 olduğu müddetçe saat çalışmaz. Buradan saatin ayarlanmamış olduğunu anlar ve saate ayar verirsiniz. Ayar verdiğinizde SN değerine sıfır vererek DS1307 ye yazarsanız otomatikman CH biti silinmiş (sıfırlanmış) olur ve saat çalışmaya başlar.
Ete
Ete hocam haklısınız kristalsiz çalışmaz ama ben isis de deniyorum şuan kristeli de bağladım yine aynı. Benim anlayamadığım daha önce aynı ds1307 kütüphanesiyle zaman bilgisini alıyordum. Eski projeme bakarak dan ds1307 kısmını aynen kopyaladım yine zaman verileri gelmiyor.
arkadaşlar bu xc8 de i2c nasıl kullanılıyor. Yardımcı olurmusunuz.
iyi çalışmalar.
arkadaşlar sorun isisdeki sda scl ye bağladığım dirençleri dijitale çevirince düzeldi.Yardımlarınız için sağolun.
iyi çalışmalar
konu kapanbilir.