|
|
View previous topic :: View next topic |
Author |
Message |
francpa
Joined: 03 Jun 2013 Posts: 1
|
I2C Real-Time Clock MCP7940M library |
Posted: Mon Jun 03, 2013 4:16 pm |
|
|
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: 9245 Location: Greensville,Ontario
|
|
Posted: Tue Jun 04, 2013 5:58 am |
|
|
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: 9245 Location: Greensville,Ontario
|
|
Posted: Tue Jun 04, 2013 6:04 am |
|
|
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: 19549
|
|
Posted: Tue Jun 04, 2013 7:19 am |
|
|
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
|
|
Posted: Tue Jun 04, 2013 7:52 am |
|
|
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
|
|
|
|
|
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
|