This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

A bug in C51?

Hi,
I encountered the following phenomena during my work:
I dont know if its supposed to be this way but I'm sure it made me a lot of trouble.
I had a working program and I built a bootloader for it.The interrupts were inside the bootloader (never mind the details..) but what's important is that it was made out of one C file. The interrupt handlers were written before the interrupt function themselves since there was no prototype function.
What happened is that everything went crazy and the interrupts didn't work right...THE PROBLEM was that the compiler didn't add the save\restore PSW assembly code in the interrupt function for some reason.
Any explanations or a is it a bug?

Parents
  • but what's important is that it was made out of one C file.
    That's almost certainly not important.

    The interrupt handlers were written before the interrupt function themselves since there was no prototype function.

    No idea what you mean by interrupt "handler" versus interrupt "function", but I suspect you got this backwards. And that's before we start to consider that this an 8051, so there should not usually be any such distinction. Keep interrupt service routines short. Typically they should not have a need to call any other functions.

    That set aside, you should never go without prototypes. You won't have to worry about function ordering in the source file, nor about a lot of other nasty things.

    What happened is that everything went crazy and the interrupts didn't work right
    Sorry, but you'll have to do better at describing the problem. What exactly happened? And what exactly did that source code look like?

Reply
  • but what's important is that it was made out of one C file.
    That's almost certainly not important.

    The interrupt handlers were written before the interrupt function themselves since there was no prototype function.

    No idea what you mean by interrupt "handler" versus interrupt "function", but I suspect you got this backwards. And that's before we start to consider that this an 8051, so there should not usually be any such distinction. Keep interrupt service routines short. Typically they should not have a need to call any other functions.

    That set aside, you should never go without prototypes. You won't have to worry about function ordering in the source file, nor about a lot of other nasty things.

    What happened is that everything went crazy and the interrupts didn't work right
    Sorry, but you'll have to do better at describing the problem. What exactly happened? And what exactly did that source code look like?

Children