CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Questions about DS1305.c with PIC 18F4520

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Flippy
Guest







Questions about DS1305.c with PIC 18F4520
PostPosted: Fri Jul 06, 2007 6:24 am     Reply with quote

Hello everyone!

I am using PCWH Compiler 4.042.

I got a DS1305 connected to my PIC 18F4520 :
PIN C1: RTC_CS
PIN C3: SPI_SCK
PIN C4: SPI_MISO
PIN C5: SPI_MOSI

RTC:
Sermode is on Vcc (--> SPI).

I tried to included ds1305.c and trieg to get the RTC working, but untill now without success.
I just don't get data from the RTC.

What made me quite unsure is that the ds1305.c uses only 3 pins instead of 4.


ccsinfo.com/forum/viewtopic.php?t=29848&highlight=ds1305
Here it is said that Software-SPI is used, but I really can't figure out why (I thought it was 3-Wire because of the RTC_IO) and how it is working.

I checked the signals from the PIC, and they seem to be alright.

I am also using an AT25256 on the same Pins (C3-C5) and everything seems to works fine (I just had to redefine the Pins in the AT25256.c! But there are four pins used.).

I am trying to get the RTC working for 1,5 days now and I kinda looked through half of the internet Wink but I just don't get it.
I hope you can help me, thank you!
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Jul 06, 2007 11:17 am     Reply with quote

Quote:
What made me quite unsure is that the ds1305.c uses only 3 pins instead of 4.

The CCS driver expects the SDI and SDO pins on the DS1305 to be
connected together. You must add this connection to your hardware.
These two pins together are then connected to a single pin on the PIC,
which the CCS driver calls "RTC_IO".
Flippy
Guest







PostPosted: Mon Jul 09, 2007 12:03 am     Reply with quote

thanks a lot!

I also have to connect the SERMODE-Pin on the ds1305 to GND to activate the 3-Wire Interface, right ?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Jul 09, 2007 12:47 am     Reply with quote

That's correct. That's what the data sheet says.
andrewg



Joined: 17 Aug 2005
Posts: 316
Location: Perth, Western Australia

View user's profile Send private message Visit poster's website

PostPosted: Mon Jul 09, 2007 2:07 am     Reply with quote

I've just finished getting my DS1305 to work with the CCS driver. I'm using 4-wire mode (SERMODE tied high) since I have several other 4-wire devices on the same bus. I modified the CCS code to split the RTC_IO into RTC_IN and RTC_OUT (while I was doing that I renamed the misleading RTC_RST to RTC_CE) *and* modified it to use hardware instead of software I/O.

The only problem I had was forgetting to use SPI mode 1 (or 3):
Code:
setup_spi(SPI_MASTER|SPI_L_TO_H|SPI_CLK_DIV_16);
(my system clock is 25MHz, hence DIV_16 to get it below the 2MHz specd in the DS1305 datasheet)

It's really nice of CCS to include all the code they do with their compiler, but IMO much of their "driver" code should be in the "examples" folder - it's just not well-written or flexible enough to be a proper reusable library.
_________________
Andrew
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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