|
|
View previous topic :: View next topic |
Author |
Message |
EJAZMIRZAN
Joined: 02 Aug 2013 Posts: 3
|
interfacing pic16f877a with DS1307 |
Posted: Fri Jan 17, 2014 9:56 am |
|
|
I have written follwing code. but when I run this code "try 0" has displayed but "try 1" is not displayed & no square wave is obtained from RTC. so interfacing code gone wrong. plz help me . I read DS1307 interfacing with pic16f877a in this forum. so dont tell me to read previous posts. its urgent.
Code: |
#include "C:\Users\user\Desktop\miniproject\phase1\rtclcd.h"
#use i2c(Slave,Slow,sda=PIN_C4,scl=PIN_C3,address=0xD0)
#define LCD_ENABLE_PIN PIN_D0
#define LCD_RS_PIN PIN_D1
#define LCD_RW_PIN PIN_D2
#define LCD_DATA_PORT D4,D5,D6,D7
#define LCD_TYPE 2
#include <lcd.c>
void main()
{
setup_adc_ports(NO_ANALOGS);
setup_adc(ADC_OFF);
setup_psp(PSP_DISABLED);
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
setup_comparator(NC_NC_NC_NC);
setup_vref(FALSE);
// TODO: USER CODE!!
lcd_init();
lcd_putc("\f try 0");
i2c_start();
i2c_write(0xd0);
i2c_write(0x07);
i2c_write(0x12);
i2c_stop();
i2c_start();
i2c_write(0xd0);
i2c_write(0x00);
i2c_write(0x00);
i2c_write(0x00);
i2c_write(0x00);
i2c_stop();
lcd_putc(" try 1");
} | |
|
|
gpsmikey
Joined: 16 Nov 2010 Posts: 588 Location: Kirkland, WA
|
|
Posted: Fri Jan 17, 2014 10:04 am |
|
|
What does your hardware look like? Is this an existing board or one you wired up yourself? _________________ mikey
-- you can't have too many gadgets or too much disk space !
old engineering saying: 1+1 = 3 for sufficiently large values of 1 or small values of 3 |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Fri Jan 17, 2014 11:38 am |
|
|
Quote: | so dont tell me to read previous posts. its urgent. |
If you read them, you would see how to do it.
Quote: | #use i2c(Slave,Slow,sda=PIN_C4,scl=PIN_C3,address=0xD0) |
See the ds1307 ("Previous post") driver here:
http://www.ccsinfo.com/forum/viewtopic.php?t=23255
Does he use "Slave" in his #use i2c() statement ? No. The PIC is the
master. He also doesn't use "address".
Quote: | #define LCD_DATA_PORT D4,D5,D6,D7 |
The CCS lcd driver does not ever do this. This will not work.
c:\program files\picc\drivers\lcd.c
You have to read, so you can learn. If you do that you will be able
to write programs that work. |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9243 Location: Greensville,Ontario
|
|
Posted: Fri Jan 17, 2014 12:58 pm |
|
|
query,hardware: Do you have a coin cell battery connected to the DS1307?
comment,software: There is a DS1307 'driver' either in the 'code library' here, or maybe in this 'discussion' forum. A 'search' should find it.
commnet,software: PCM P has an 'I2C test program' posted here, probably a GREAT place to start to confirm PIC actually 'sees' the DS1307.
I do know both work as I have both 877 and 46k22 boards running as I type.
hth
jay |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|