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

Low voltage detection in dspic30f4011

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



Joined: 16 Mar 2012
Posts: 31

View user's profile Send private message

Low voltage detection in dspic30f4011
PostPosted: Mon May 28, 2012 7:29 am     Reply with quote

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: 19543

View user's profile Send private message

PostPosted: Mon May 28, 2012 8:55 am     Reply with quote

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

View user's profile Send private message

PostPosted: Mon May 28, 2012 9:44 am     Reply with quote

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: 19543

View user's profile Send private message

PostPosted: Mon May 28, 2012 2:39 pm     Reply with quote

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
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