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

Problem in function pointer variable

Hello,
I have faced a problem with a function pointer variable. I have separated the uart module in two parts: HAL, which abstracts the hardware, and Service, which provides the uart service to the application. The interrupt routine is in HAL module, which has a function pointer variable that is called into the interrupt routine as interrupt handler. The actual interrupt handler function is in Service module. This function is assigned to the function pointer variable through a install function in the init routine.
It works in debug simulation, but when I load the hex file to the microcontroller the application does not work. Anyone can help me?

Parents
  • All functions called within an interrupt must be reentrant. (it's a keil keyword).

    I have some code that calls queue functions from within a serial interrupt. It will make a disaster of the stack and data if you don't mark such functions reentrant, and of course I forgot this. So each time I attempted communication the system would have a seizure.

    The ISR has a seperate variable and data allocation from your main program. This is why you must set such functions you call from an ISR reentrant.

    In addition I concur with the prior suggestion. Keep interupts extremely simple with the C51. Remember your uC stack is < 256 bytes at best. Worst case is 128 bytes or less. Stack only uses data/idata space. You may be getting stack corruption by the way.

    Stephen

Reply
  • All functions called within an interrupt must be reentrant. (it's a keil keyword).

    I have some code that calls queue functions from within a serial interrupt. It will make a disaster of the stack and data if you don't mark such functions reentrant, and of course I forgot this. So each time I attempted communication the system would have a seizure.

    The ISR has a seperate variable and data allocation from your main program. This is why you must set such functions you call from an ISR reentrant.

    In addition I concur with the prior suggestion. Keep interupts extremely simple with the C51. Remember your uC stack is < 256 bytes at best. Worst case is 128 bytes or less. Stack only uses data/idata space. You may be getting stack corruption by the way.

    Stephen

Children