brutus
Joined: 14 Apr 2004 Posts: 12
|
18F252 and ds1307 |
Posted: Wed Apr 14, 2004 8:23 am |
|
|
Hi,
i'm working with a 18f252 and a ds 1307 rtc. It really doesn't seem to work. I've tried every kind of thing...
I'm using 4k7 pullups resistors and this code...but no reply..no ack!!!
#include <18F252.h>
#fuses HS,NOWDT,NOPROTECT,NOLVP
#device adc=10
#use delay(clock=20000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)
#use i2c(master, sda=RTC_SDA, scl=RTC_SCL, SLOW)
void initPort(){
set_tris_a(0B00111111);
set_tris_b(0B00000000);
// set_tris_c(0B10100111);
output_float(RTC_SCL);
output_float(RTC_SDA);
}
.....
void setRtcCR(){
disable_interrupts(GLOBAL);
i2c_start();
i2c_write(DS1307_I2C_WRITE_ADDR); // address=1101000 + write bit=0
i2c_write(0x07);
i2c_write(0B10010000); // control register
i2c_stop();
enable_interrupts(GLOBAL);
}
Am i doing an error in the initPort function?
Does anyone know anything, or has a working code (also for 18f452..)?
Cla |
|