Other Parts Discussed in Thread: C2000WARE
Recently, I discovered that executing the same code online with an emulator is different from executing it offline without an emulator. Here is my code.
Figure 1
Figure 2
As figure 1 shows, the function pointer is defined at the initial position of the structure. Figure 2 shows how the structure is initialized in a function where LINE_STRTUCT_DEFALUTS is the macro definition and corresponds to (void (*)(void *))LineCalc. After initializing the function pointer this way, I see that the value in the actual function pointer is still 0x00000000 rather than 0x3EA0A6. So after executing aiLine.calc(), the program jumps to an illegal ISR.
Later, the program runs normally after I modified the initialization of function pointers as shown in figure 3. So it can be said that the cause of entering an illegal interrupt at online runtime is bad initialization.
Figure 3
Here's my puzzle! With the original function pointer initialization method, running online will enter illegal interrupt, but will run fine when running offline. Why?