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

Callback function

I am developing an application based on 8051 core. I am using uVersion2 and C51. The application is based on UNIX OS concept and it involved the RTOS features. Here i am facin problem with call back function implementation. I have implemented call back functions but it is not excuting the code properly..it sees to be crashed. What can be the reason for this. There is no warning from compiler as well as linker as i set the overlay option for linker to remove all warnings.

With Regards,
Shail.

  • "There is no warning from compiler as well as linker as i set the overlay option for linker to remove all warnings."

    So, you're saying that there are warnings - but you're just ignoring them?!
    Have you checked carefully that really are unimportant warnings? If you haven't, it should come as no surprise whatever that your code crashes!

    BTW: do remember that C51 functions are not reentrant!

  • 8051... based on UNIX

    Countdown to a post about programming 8051s as though they were PCs: 5... 4... 3...

    involved the RTOS features

    UNIX is not traditionally an RTOS. SVR4 introduced some absolute process priorities. And there's pthreads. But it's still generally a very heavy-weight design. And most implementations have pretty huge footprint and also interrupt latency in the kernel.

    problem with call back function

    You need to carefully study the section on overlay management and stack handling in the manual. Also, there's an app note or two on function pointers that you need to read. Keil C51 by default does some interesting compile-time analysis to avoid the need for run-time stack when calling functions. But, this optimization does have some limitations, particular when function pointers are used.

    There are a few cases where you can use function pointers and have the compiler sort it all out. In the general case, the compiler cannot tell which functions are called by which, and will have trouble building its overlay tree. You might have to resort to some manual specification of the actual call tree to get correct results. Alternatively, you need to declare everything reentrant and use the software stack, which is notably less efficient.

    After studying the manual and app notes, you might want to consider just how badly you want those callback functions. Perhaps you can implement the feature in a different way that will cause fewer problems with the chosen environment.

  • Here i am facin problem with call back function implementation

    Time to re-think your design from the ground up, I'm afraid. Call-back functions mean function pointers, and that's not something you want to do a lot with C51.

    Yes, trying to treat an 8051 like a Unix-based desktop computer will create problems. Lots of them. Quite probably more than it helps you solve.