Nick van den Bosch

C-Function larger as a page

Discussion created by Nick van den Bosch on Sep 27, 2010
Latest reply on Sep 30, 2010 by Nick van den Bosch

Hello all,

 

I'm new to the S12X and I'm currently generating code from Matlab Simulink for use on an S12X microcontroller. The problem is it generates a function which is larger than a flash-page. Initially I got an error the code could not be located as a result that the function did not fit a page. Then I adapted the prm file to use global addressing on the entire flash:

 

SEGMENTS

    ....

    S12X_FLASH    = READ_ONLY   0x788000'G TO 0x7F3FFF'G;

    ....

END

 

PLACEMENT

    ....

    DEFAULT_ROM             INTO  S12X_FLASH;

    ....

END

 

Well, this compiles, links and runs... However it still does not run the large (the one larger as a page) function correctly. The function is called at the correct address but it fails while executing the function. When I manually adapt the function and decrease the size to a smaller one (so it fits within a page), other assembly is generated and it runs all fine.You can see the difference in the attachments.

 

Not adapted it executes (Dissasembly_Normal.JPG):

JSR         0x0231

GLDAB   0xEC52

GLDAA   0xEA16

...

When it executes the JSR-command it hangs up.

 

Adapted (small size function, see Dissasembly_Adapted.JPG):

LDAB    #15

STAB    0x10

GLDAB   0xEC52

GLDAA   0xEA16

...

Here it loads the correct page normally as I would expect and this runs fine

 

The thing is, it concers generated code so I'm not able to adapt the file/function. Does anyone knows what's going on and how to fix it?

 

Thanks,

Nick

Outcomes