Hi All, We are using DP256(HC12) target environment for our project and facing problems when we try to use function pointers. We are using an array of function pointers for implementing callback functions. The problem is, when we try to call the function using the array we get an "illigal breakpoint" error and program stops. We made sure that all our code is placed in NON_BANKED memory and also the .lst file shows that function call is replaced by assembly instruction CALL. We would like to know whether there is any restriction for using function pointers in this target environment or is there any special care needs to be taken. Any help in this regard is highly appreciated. Warm Regards mdn |
|

Problem using function pointers in HC12 (DP256)...
Hello, I would check the memory content you have in your array (is it really pointing to the code area you want)? Examine the memory area of your array in the debugger. Then check the addressing mode of the CALL instruction (or the C code for it): maybe you do one indirection too much? But I'm wondering: if your code is in non banked, why are you using a CALL and not a JSR? Make sure what you call with a CALL is returning with a RTC, and what you call with a JMP/JSR is returning with a RTS. Below some examples which may help you: using far/banked function pointers (banked memory model): 1: void foo(void); 2: void bar(void); 3: void (*fctPtrArr[])(void) = {foo, bar}; 4: 5: void main(void) { 6: fctPtrArr[1](); 0000 4bfb0000 CALL [fctPtrArr:3,PCR] 7: for(;;); 0004 20fe BRA *+0 ;abs = 0004 Using non-banked memory model: 1: void foo(void); 2: void bar(void); 3: void (*fctPtrArr[])(void) = {foo, bar}; 4: 5: void main(void) { 6: fctPtrArr[1](); 0000 15fb0000 JSR [fctPtrArr:2,PCR] 7: for(;;); 0004 20fe BRA *+0 ;abs = 0004 8: } Additionally, you need to know that data pointers and function pointers may have different layout in memory. Check your compiler documentation on this. Erich > -----Original Message----- > From: mdn4u [mailto:] > Sent: Dienstag, 16. September 2003 11:25 > To: > Subject: [68HC12] Problem using function pointers in HC12 (DP256)... > Hi All, > > We are using DP256(HC12) target environment for our project and > facing problems when we try to use function pointers. We are using > an array of function pointers for implementing callback functions. > > The problem is, when we try to call the function using the array we > get an "illigal breakpoint" error and program stops. We made sure > that all our code is placed in NON_BANKED memory and also the .lst > file shows that function call is replaced by assembly instruction > CALL. > > We would like to know whether there is any restriction for using > function pointers in this target environment or is there any special > care needs to be taken. > > Any help in this regard is highly appreciated. > > Warm Regards > mdn > > -------------------- > > ">http://docs.yahoo.com/info/terms/ |
mdn, A full-Emulator with a trace can be a big help in this case, to show you what is actually executed by the CPU, and where the program is going instead of going to the correct call-back function. Assuming you don't have a full-emulator, why don't you post the actual assembly code that you use to call the Call-back functions (including the content of the relevant memory and registers for the function call), and somebody on the list can possibly spot where your code is failing. Hope this helps, Doron Nohau Corporation HC12 In-Circuit Emulators www.nohau.com/emul12pc.html At 09:24 AM 9/16/2003 +0000, you wrote: >Hi All, > >We are using DP256(HC12) target environment for our project and >facing problems when we try to use function pointers. We are using >an array of function pointers for implementing callback functions. > >The problem is, when we try to call the function using the array we >get an "illigal breakpoint" error and program stops. We made sure >that all our code is placed in NON_BANKED memory and also the .lst >file shows that function call is replaced by assembly instruction >CALL. > >We would like to know whether there is any restriction for using >function pointers in this target environment or is there any special >care needs to be taken. > >Any help in this regard is highly appreciated. > >Warm Regards >mdn |
