Float calculations in microchip

Papabravo

Joined Feb 24, 2006
22,082
I am getting default interrupt and i have put a while(1) there. I did not trace which interrupt it is.
There is NO SUCH THING as a DEFAULT INTERRUPT. In any processor with multiple interrupt sources, you always want to do your initial debugging with interrupts disabled. In your initialization code you include whatever you need to disable all interrupt sources. When you have the code that does not depend on interrupts debugged, you then enable the ones you need, one at a time. That way you can debug in a controlled environment. That's Embedded Code 101.
 

Ian Rogers

Joined Dec 12, 2012
1,136
If your interrupts are enabled make sure only the one you need is on... I have an ISR in my code.. IF!! I don't use it, the pin is floating... Bad news... It took a while to realise it was a false trigger!
 

Thread Starter

electronicsLearner77

Joined May 26, 2012
127
i am sorry the issue is not because of floating calculations. By mistake i am writing in an out of bound array got confused with index number and dtc code which is 3 byte value and the array size is only 200. Probably i should put some array bound checks.
 

WBahn

Joined Mar 31, 2012
32,825
i am sorry the issue is not because of floating calculations. By mistake i am writing in an out of bound array got confused with index number and dtc code which is 3 byte value and the array size is only 200. Probably i should put some array bound checks.
Oh, yeah! Things like that should ALWAYS be done.

On the list of things that should always be considered is, "what happens if I try to access an element outside the array bounds?" If the answer is that it doesn't matter (almost never the case) or that I can live with it whatever happens (rare, but can sometimes be the case), then I don't need to modify my code. The more usual case is that it does matter and I'm not will to just live with the consequences, so now I need to determine the best place in the code to perform the appropriate checks so as to minimize the performance impact and what the best course of action to take is if the checks fail (which can be he hardest part because identifying the appropriate action is often times anything but obvious).
 
Top