Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

How to make ATmega8 restart from the state it hanged when power goes off?

Status
Not open for further replies.

arnab.bhaumik

Member level 5
Joined
Sep 20, 2006
Messages
81
Helped
6
Reputation
12
Reaction score
3
Trophy points
1,288
Location
Kolkata, India
Activity points
1,835
hi all,

i am going to use atmega8 for my next project(timer plus other things) which has a requirement that even if power goes and micro hangs, after reset it should start from the state where it hanged.

my question is that at atmega8 datasheet it told that atmega8 has SRAM. static ram should hold data even if power goes. is it possible with atmega8 sram??

otherwise i have to use eeprom of avr for store every minutes state.

if any of you have experience about this matter then please reply

arnab
vu2bpw
 

limited sram in avr

No it will not hold data after power off.

There is also Dynamic RAM - this type of RAM needs to be read periodically to hold data. It must be making every few milliseconds.

SRAM - static RAM. This type of RAM does not need periodical reading to hold data. But it will lose data after power off.

You need to use flash memory to hold data, it will be tricky too, as you need to be sure that all parts of data are valid and there is integrity in array. So, you need to use checksume and two banks to be safe of wrong writting during power problems.

73!
 

specify location of data in sram avr

I think that you should use a backup power supply for this kind of application (a battery, accumulator or special capacitor).When the main power supply goes low, the AVR should detect this event and switch into sleep mode. When main power will be OK, the AVR will detect the event and switch back to run mode.
 

use serial ram avr

be carefull with eeprom or flash erase - write cycles. Obviously is limited. SRAM can use anyway. Read carefully the difference between ld and lds instructions.

good luck
 

avr sram read/write

hi all,

i can connect a battery for power up during mains falure. but the requirement is then also that if the controller hangs somehow, after reset(via watchdog) the system should remember the last state.


in my current design i am putting a battery backup. but for REMEMBERING THE previous state i may desine a external ram chip (ram not hangs and i can give it a battery backup). in that case please suggest is ther any serial ram availeable(read/write via serial interface) ??????



thank you for reply


arnab/vu2bpw

Added after 2 minutes:

Read carefully the difference between ld and lds instructions.



i will write the code with gcc(winavr) c compiler.
so no problem with assembly language. for me assembly language is only for reference and debugging

arnab/vu2bpw
 

use sram in avr

Put some kind of battery to avr supply through diode to main supply , configure AVR to detect main supply failure via INT external interrupt pin. When interrupt happens - save all needed content (if choice (b)) into eeprom and make power off either to
a. one of the low consumption sleep mode or
b. complete power off.

The latter imply that all needed data must be accured into eeprom - can include variable, port configuration registers .

The former approach is better but requires that your battery will suffice till next power ON . But it does not require to store anything into eeprom. Check appropriate sleep modes and their details from micro data sheet . Pay also attention to IO port pins states - connected to some load they can draw current which exceeds sleep mode current for avr. Power ON detection could also be done through same INT pin (if not wrong it works in asynch mode).
 

avr port pins during sleep mode

hi all,

thanks for replys and suggestions.

i am considering both approches. currently i already designed exactly as artem suggested. but the main problem of this type of approach is that if the avr hangs all data will lost. so a good grounding and good shilding of the circuit board is required.
(it will be installed at unmanned bts of bsnl telecomm tower controls ).


but the FRAM approach has its own advantage. if avr hangs, the after restart it will search data at fram and do work accordingly.


let me try the battery backup approach of avr at first, after that if it fails i will try the FRAM approach


arnab/vu2bpw
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top