![]() |
Forum Index : Microcontroller and PC projects : an alternative to VAR SAVE
Page 1 of 2 ![]() ![]() |
|||||
Author | Message | ||||
TassyJim![]() Guru ![]() Joined: 07/08/2011 Location: AustraliaPosts: 6283 |
This started before the current VAR RESTORE problems mentioned elsewhere. Lew247 asked me to help him with a small project. He wants to know what time power failed (or program stopped for any reason). He told me about some interesting Microchip offerings. The 47L04/47C04/47L16/47C16 (47XXX) is a 4/16 Kbit SRAM with EEPROM backup. The device is organized as 512 x 8 bits or 2,048 x 8 bits of memory, and utilizes the I2C serial interface. ![]() The advantage over 'VAR SAVE' is The SRAM won't wear out and the backup is fully automatic. Once the control register is set, it saves the SRAM to EEPROM whenever power fails and restores when power returns. It also retains data over program reload and even firmware updates. It uses a ~6.8uF capacitor to give it time to act when power fails. Cost is about $1 The disadvantage is, you need an extra chip and capacitors. You may also be tying up the I2C buss a bit depending on how often you update the data. I went with the 47L16 because it was available in DIP packages. All the program does is read the data when the program first starts and the last saved data is there. With a normal stop and restart of the program, the data stays in SRAM but with a power failure, it saves to EEPROM and restores again ready for retrieval. If you force a save or retrieval, you have to allow time for the operation to complete. The time required depends on the chip used. Output: Last shutdown occured at 00:00:12 15:53:00 15:53:01 15:53:02 15:53:03 15:53:04 15:53:05 15:53:06 15:53:07 15:53:08 > RUN Last shutdown occurred at 15:53:08 15:53:28 15:53:29 15:53:30 15:53:31 15:53:32 15:53:33 15:53:34 > > DATE$="12/01/2019" > TIME$="15:54:22" > RUN Last shutdown occurred at 15:53:34 15:54:26 15:54:27 15:54:28 15:54:29 15:54:30 > The first save was before the clock was set. With a battery backed RTC, you can record the downtime etc. I used an arm-L4 for the test without battery backed RTC but any mite will do. I chose to open and close the I2C on each call but, in real life, it might be easier to open once and leave it open. Jim VK7JH MMedit |
||||
Grogster![]() Admin Group ![]() Joined: 31/12/2012 Location: New ZealandPosts: 9610 |
This is a very interesting chip and arrangement. Thanks very much for posting. ![]() EDIT: This link shows the part, but also has a wee video showing how the chip works. Very clever. Smoke makes things work. When the smoke gets out, it stops! |
||||
lew247![]() Guru ![]() Joined: 23/12/2015 Location: United KingdomPosts: 1702 |
Jim you're a star Thanks |
||||
TassyJim![]() Guru ![]() Joined: 07/08/2011 Location: AustraliaPosts: 6283 |
Thank you Lewis for bringing the chip to my attention. It will be a handy one to have. Jim VK7JH MMedit |
||||
Grogster![]() Admin Group ![]() Joined: 31/12/2012 Location: New ZealandPosts: 9610 |
Perhaps, but you could always use the I2C Cfunction to create a new dedicated I2C port just for the memory chip I suppose. That would free up the normal I2C channel(s). I've just downloaded the datasheet for this device. Very interesting chip indeed. ![]() Smoke makes things work. When the smoke gets out, it stops! |
||||
CaptainBoing![]() Guru ![]() Joined: 07/09/2016 Location: United KingdomPosts: 2170 |
I would like to see these devices with much larger capacities, at least 16KBytes. They all seem to be stuck at 2K (like the UNIO chips too). I use the winbond W25Qxx multi-megabyte devices with 4 & 8 MB capacities - my latest small controller board has provision for one on the copper which you can use or not depending on application. For one project I emulated the address/data buses of a conventional CPU then used a CY7C1512 64k x 8 static ram. It was a faff with a couple of '574s to latch the address and quite a few pins but it was a joy to have simple byte access just like trad CPUs - I must say this started out PIC16F877 based (with PORTD as an 8-bit port) and got a "brain transplant" later on. |
||||
HankR Senior Member ![]() Joined: 02/01/2015 Location: United StatesPosts: 209 |
According to the video, there is an 8K device in I2C, and up to 128K in SPI, but I gave up trying to find the part numbers and data sheets using Microchip's website search and a distributor's website search. |
||||
djuqa![]() Guru ![]() Joined: 23/11/2011 Location: AustraliaPosts: 447 |
Only the 4K and 16k I2C devices listed and no SPI interfaced EERAM listed on microchips site at all VK4MU MicroController Units |
||||
viscomjim Guru ![]() Joined: 08/01/2014 Location: United StatesPosts: 925 |
This is a great little device, especially for the L4 to do some low power logging. Thanks for the efforts and info!!! |
||||
lew247![]() Guru ![]() Joined: 23/12/2015 Location: United KingdomPosts: 1702 |
Try THIS one |
||||
TassyJim![]() Guru ![]() Joined: 07/08/2011 Location: AustraliaPosts: 6283 |
One other point to remember is the time it takes to store and recall. The 16k bit chip takes 25mS to store and 5mS to recall. Storing shouldn't matter as it would happen after power fail but if you had autorun set, you should pause 5mS at the start of your program to give the chip time to get the SRAM back with it's saved data. The 4k chip has shorter times. You can also set a portion of the memory as protected so semi permanent settings are safe from overwrites. Jim VK7JH MMedit |
||||
HankR Senior Member ![]() Joined: 02/01/2015 Location: United StatesPosts: 209 |
Okay, should have labelled my figures as being in kbytes, as referenced by Andrew . The kbits and the kbytes numbers overlap so it can be a little confusing. For the I2C listed by Microchip as really available (LARA) devices, 16kbits (2 kbytes) is biggest. The 8 kbyte I2C device in video looks like vapor(hard)ware or vapor silicon (VS). In SPI all devices mentioned in video, with the biggest being 128 kbytes, ALL look like they're VS. Very unfortunate. This looks like a good thing to ask a Microchip rep or FAE, but I always dread the part of the conversation that addresses how many thousands of ICs your company will (or already is) be buying a month. That actually might not even come up these days. There might be something about this on the MC forum, too, or a new inquiry made there about whether these much bigger devices might be available "real soon now." TM JP who will be the first in the gang to identify JP? |
||||
Turbo46![]() Guru ![]() Joined: 24/12/2017 Location: AustraliaPosts: 1642 |
Jerry Pournelle. Keep safe. Live long and prosper. |
||||
CaptainBoing![]() Guru ![]() Joined: 07/09/2016 Location: United KingdomPosts: 2170 |
Try THIS one Much better - 128KB is a very useful lump. Cheers |
||||
HankR Senior Member ![]() Joined: 02/01/2015 Location: United StatesPosts: 209 |
Much better - 128KB is a very useful lump. Cheers You can do even better. 256 kbytes is available now in I2C. Microchip/Atmel AT24CM02 family. Prices have been falling too. |
||||
Grogster![]() Admin Group ![]() Joined: 31/12/2012 Location: New ZealandPosts: 9610 |
23LC1024 and AT24CM02 are just EEPROM's. They do not have the attractive autosave feature. What I like about the first chip as linked to in the OP, is that it will autosave the data in the SRAM for you when the power fails, and restore it again to the SRAM when the power comes back up. Because the device uses a charged cap to supply the juice to be able to write the SRAM to the EEPROM when the power fails, that limits the size of the memory if you need that cap to be small. C'est La Vie... ![]() Smoke makes things work. When the smoke gets out, it stops! |
||||
HankR Senior Member ![]() Joined: 02/01/2015 Location: United StatesPosts: 209 |
There has been a distinct fork in the thread. One is for the special backup devices, the other is for just roomy EEPROMs. |
||||
HankR Senior Member ![]() Joined: 02/01/2015 Location: United StatesPosts: 209 |
Not even an hour elapsed and bingo, we have a winner. Your prize is a much desired family sized package of ultra-premium, certified organic croc sausages all ready to cook up on the barbie this summer. All the crocs are free range farmed and raised on a proprietary, fully vegetarian diet. As a result, the crocs growth is quite stunted, but the taste and tenderness of the resulting meat is truly amazing. Jerry among many other things was a columnist for Byte magazine (starting in 1980). |
||||
Turbo46![]() Guru ![]() Joined: 24/12/2017 Location: AustraliaPosts: 1642 |
Vale Jerry Pournelle. His column was the first one I read when I got my copy of Byte. I have read most of his SciFi books as well. He was not a fan of C as I remember. Bill Keep safe. Live long and prosper. |
||||
lew247![]() Guru ![]() Joined: 23/12/2015 Location: United KingdomPosts: 1702 |
Jim Can you or anyone else tell me how to do this I'm counting from 0 to 43199 and storing the value in the sram However its storing with trailing zeros 10000 20000 30000 . . . 219000 220000 How can I get it to store with leading zeros instead of trailing zeros? |
||||
Page 1 of 2 ![]() ![]() |
![]() |
![]() |
The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |