??? 09/16/04 12:23 Read: times |
#77486 - RE: Avoid USING ! Responding to: ???'s previous message |
Because it can causes crashes, if subroutines called with a different register bank usage.
And some times it can occur, that hidden subroutines are called. If subroutines are called both from main() and interrupts you will have a disaster on hand whether you use 'using' or not. Of course, there is the 'reentrant' keyword, but 'forgetting' that will lead to a category 10 bug. I would much rather have the whole thing blow up immediately beacause of different banks that get the cat 10 bug from a missing 'reentrant' Writing handlers for unused interrupts make absolutely no sense, because all these are disabled after every reset. unless 'accidentially' enabled So triggering of unused interrupts can only point out two things: - the reset was done wrong - the chip was damaged or buggy you forgot the third: faulty software. While your statement "it can not happen" is true in an ideal world, the addition of crash(); to the unused interrupts create a means of catching that pesky SW bug that otherwise takes days to find. Also, in this case, it was suggested as a debugging measure. I put crash() in all unused ISRs every time and rarely do I find it useful BUT when it is useful it saves DAYS of debugging. When a mystery comes up, set a breakpoint in crash() and in no time I know whether the mystery is due to a false interrupt or not. I have had the following C code result in a call to crash() because of an interrupt interaction and had I not had crash() in the unused ISRs I would have been lost for a long while; saveIE = IE; EA = FALSE; ... .... IE = saveIE; Better safe than sorry Erik |