Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Software reset within isr

Status
Not open for further replies.
upon detection of a particular condition within isr dictates that a fresh start is favorable..

So it is OK that the microcontroller keeps on reseting until that condition is cleared? Are you doing anything to fix this "condition"?
 
You need to be FAR specific about exactly what you're trying to do, but ISR's should be short and fast, and it sounds a REALLY bad idea to want to reset from within one.

I suspect you're probably going about your requirements very poorly?.

Incidentally - to cover myself - the reason I'm familiar with the RESET command in the enhanced mid range series is because I use it to reset a GSM modem based alarm in response to a specific text message command, restoring the device to it's start-up point (which is running at 32KHz in sleep mode, checking every second for being turned ON).

here is what i got (attachment).
 

Attachments

  • inverter.txt
    1.7 KB · Views: 134
There doesn't seem anything particularly complicated about that at all?, and certainly no need for long ISR's or software resets.

Probably the only routine needed in the ISR would be to generate the inverter signals, triggered by a timer interrupt - the rest in a simple endless loop in the main program.

But again, if you choose your PIC correctly, I believe there are ones that have specific hardware for generating the required inverter signals.

So what are you actually trying to do in your ISR?, and why does it take a long time?.
 
There doesn't seem anything particularly complicated about that at all?, and certainly no need for long ISR's or software resets.

Probably the only routine needed in the ISR would be to generate the inverter signals, triggered by a timer interrupt - the rest in a simple endless loop in the main program.

But again, if you choose your PIC correctly, I believe there are ones that have specific hardware for generating the required inverter signals.

So what are you actually trying to do in your ISR?, and why does it take a long time?.

my main program is written to charge the battery only while ISR generates
the inverter signals but the thing that makes it particularly difficult
for me to think about is ISR also checks for Battery Low condition: suppose
a Battery Low is detected within ISR then the inverter signals must stop
meaning to disable interrupt . Under this circumstance until supply mains
resumes there is nothing to do but wait for it. Now using RETFIE would
take me some point in the main program which might misses a crucial check
because it goes to a line before the occurrence of Battery Low condition
after the condition actually occurred--that could be inappropriate to
address it. Again i could make the main loop run faster to make the
previous situation immaterial but doing so could switch on and off the
battery charging relay erratically near threshold voltage. so it seems
after the occurrence of Battery Low when mains resumes RESET could be more
deterministic in nature.

Thinking the other way i.e doing this checks in the main loop while
charging the battery as well could solve the whole problem but i
failed to see the program flow in that paradigm. Or that, could it be
possible to make RETFIE go to a particular line?

The ISR could be long in the sense that in my initial design after the
occurrence of Battery Low it will wait there till mains resumes and then
reset the program.
 
You don't want to be checking for battery low in the ISR, and it's ESSENTIAL that RETFIE returns to where it came from, it would cause all sorts of chaos if you started jumping back to all kinds of different places.

Checking for battery low in the main loop seems a pretty sensible place to be doing that, and as I said ISR's should be as short and fast as possible - you can send 'signals' to and from an ISR using flags - so the main program sets a flag to run the inverter or not, and the ISR checks the flag before it does anything else, and only runs the inverter outputs if it's told to run.
 
Checking for battery low in the main loop seems a pretty sensible place to be doing that, and as I said ISR's should be as short and fast as possible - you can send 'signals' to and from an ISR using flags - so the main program sets a flag to run the inverter or not, and the ISR checks the flag before it does anything else, and only runs the inverter outputs if it's told to run.

if i get you right i should run a Battery Low check once in every 10ms(design requirement) in the main loop and do the FLAG trick which upon the beginning of ISR tells it what to do. Now in the battery charging portion i want to implement delays of 1 to 2 mins once the relay is set on or off to be away from Charging Relay switching. but is that sensible ? if not then doing everything in the main loop within 10ms is suggestive. it means 100 times in a second the program should decide for the charging relay. my proposition is that battery voltage changes very slowly and 100 times in a second might result in switching. my another proposition is: implementing 2mins delay while checking a bit once in every 10ms is not possible in the main loop. are these correct? if correct then how to get around the problem?

i myself find the project easy at the first glance as you said in one of your earlier post.
am i making it too difficult? what am i missing?

-lipschutz
 
Why would you want to check the battery voltage every 10mS?, it seems incredibly pointless? - batteries don't work that fast.

But assuming you did, simply run the main loop at 10mS, and have a counter that counts up (or down) every 10mS and use that to initiate the battery charging part.

I'm also a little puzzled why you would be checking for low voltage during charging?, surely you would only check for low battery while it's NOT charging?.
 
Why would you want to check the battery voltage every 10mS?, it seems incredibly pointless? - batteries don't work that fast.

this is helpful. i dont need to stop the inverter signals within 10mS after battery voltage falls below threshold. a minute of two will just do the same.

I'm also a little puzzled why you would be checking for low voltage during charging?, surely you would only check for low battery while it's NOT charging?
probably i could not explain it well. i am not checking battery voltage within ISR. that will be done in the main loop which also contains the battery charging code. but if the voltage checking is done in every 2 minutes, solves the whole thing right away.

thanks again
-lipschutz
 
Status
Not open for further replies.

Latest threads

Back
Top