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 CCS Technical Support

I2C Real-Time Clock MCP7940M library

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



Joined: 03 Jun 2013
Posts: 1

View user's profile Send private message

I2C Real-Time Clock MCP7940M library
PostPosted: Mon Jun 03, 2013 4:16 pm     Reply with quote

Hi everybody

My question is if there is any library in ccs for MCP7940M real time clock, as the DS1307, but this does not help because it is more expensive than the MCP7940M.
Any help, thank you very much.

regards
temtronic



Joined: 01 Jul 2010
Posts: 9229
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Tue Jun 04, 2013 5:58 am     Reply with quote

WOW, it's like 1/5th the cost ! BUT doesn't have battery backup so you need to add a couple of diodes for that,still cheaper.Too bad they weren't internal...sigh

Had a quick look at the datasheet,it seems to be very similar, so I'd copy the DS1307 driver(renaming it of course !) ,then compare register layouts,bit names,etc. to both devices.Change YOUR driver as required.

It should be easy...just start with simple time setting,reading when happy, proceed to alarms,sqw out,RAM if needed. I use the 1Hz output to trigger an ISR for my projects.

hth
jay
temtronic



Joined: 01 Jul 2010
Posts: 9229
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Tue Jun 04, 2013 6:04 am     Reply with quote

Just checked with Digikey(faster search than mchp) and the 'N' version,MCP7940N DOES have the battery back version !! It's only 20c more($1 instead of .80 ) so buy that one.
pin to pin same as DS1307...now I need to order some...and jump ship !
when i get them, I'll do the driver though I think it's almost the same. no time to check..got 5 acres to plow, sun's up, ground's dry.

cheers

jay
Ttelmah



Joined: 11 Mar 2010
Posts: 19520

View user's profile Send private message

PostPosted: Tue Jun 04, 2013 7:19 am     Reply with quote

The 7940, uses address 0xDE, and 0xDF, rather than the 1307 using 0xD0/D1.
The clock registers themselves are the same (existing driver with the register changed should work), except for three bits in the 'DAY' register, and a 'leap year' bit in the year register. The extra bits, control the battery switching, detection of the battery state, and the oscillator. Then the config register changes significantly, with three bits to select the oscillator output, and the square wave output enable moving up to make room for two alarm controls. The next register is 'new', and allows digital tuning of the output frequency. Then you have two groups of seven registers allowing programmable alarms.
I've used these on a different processor.
The existing driver with the address patched, should basically work, provided you don't want the alarms or the square wave out/calibration, except you have to enable bit3. on the day register, or the chip won't use the battery.

Best Wishes
Mike Walne



Joined: 19 Feb 2004
Posts: 1785
Location: Boston Spa UK

View user's profile Send private message

PostPosted: Tue Jun 04, 2013 7:52 am     Reply with quote

Microchip has done a 10 page document on migrating from DS1307 to MCP7490.

Download that, it should help.

Mike
dyeatman



Joined: 06 Sep 2003
Posts: 1934
Location: Norman, OK

View user's profile Send private message

PostPosted: Tue Jun 04, 2013 8:09 am     Reply with quote

Just FYI,
The migration document is found here:

http://ww1.microchip.com/downloads/en/DeviceDoc/20002337B.pdf
_________________
Google and Forum Search are some of your best tools!!!!
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