View previous topic :: View next topic |
Author |
Message |
hoangkhuong
Joined: 16 Mar 2012 Posts: 31
|
Low voltage detection in dspic30f4011 |
Posted: Mon May 28, 2012 7:29 am |
|
|
My application need to store some value to eeprom before reset. I need to have some interrupts like #INT_LVD or #INT_LOWVOLT but it seems they don't have those in dsPic30f4011. My compiler version is 4.114. Does anyone know how to solve this problem ? Thanks very much in advance. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19515
|
|
Posted: Mon May 28, 2012 8:55 am |
|
|
Realistically with an external power manager circuit.
A lot depends on the nature of your PSU. If you are running from a supply with a voltage regulator, then you can monitor the supply _feeding_ the regulator, and get a warning much earlier than trying to use the local supply. You can even do this with a simple voltage divider feeding a logic input have have this detect a falling edge, directly as your trigger.
Remember if you then switch off everything unnecessary that is drawing power, you can extend the time that the capacitors can maintain the rail, to give time for the write. Remember also to have the code then sit and wait, checking if the supply has gone 'good' again' and restart if so.
Best Wishes |
|
|
hoangkhuong
Joined: 16 Mar 2012 Posts: 31
|
|
Posted: Mon May 28, 2012 9:44 am |
|
|
Hi Ttelmah,
Could you please suggest me is there any way that I can code my program in such a way that if there is a sudden reset, the program can still continue with its previous work ?
For example, if it is doing something,some calculation etc... and suddenly, the reset button is pushed, then after that, the MCU can still continue to finish its work.
Thanks very much. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19515
|
|
Posted: Mon May 28, 2012 2:39 pm |
|
|
The standard ways are:
1) Write the code, so that variables are _not_ initialised. Then test 'restart_cause' (or your equivalent), and initialise variables if the machine is performing a 'normal power up' start. For other restart causes (watchdog etc.), you can then re-enter the code, with the variables still set.
2) Alternatively, if the trigger takes you into an interrupt, than make this have the highest priority, and stay in the interrupt, till the trigger is removed. Then just return.
Obviously things like timer events may well be missed, but handling this is just down to careful coding.
Best Wishes |
|
|
|