Porting

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Porting

458 Views
Aswin_5232
Contributor II

I am trying to port code from cosmic compiler to code warrior 5.2 for HCS12 controller, when I am calling a function which is inside another function , the value passed to the first function is not updated correctly,

 

eg. void Update_Display(uint8_t update)
{

LCD_srWriteToDisplay(string1,SCREEN_LINE_WIDTH,20,0);

}

inside  LCD_srWriteToDisplay function, the arguments are not having the same value which I have passed. 

0 Kudos
Reply
1 Reply

421 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Hi @Aswin_5232,

TN234, https://www.nxp.com/docs/en/application-note/TN234.pdf

explains this issue in the section “Porting non‑ANSI‑C Keywords”, where it shows that Cosmic’s @near/@far must be replaced with CodeWarrior’s __near/__far, including for functions, because CW uses different calling conventions for near vs. far calls.
If a function ends up in banked code but is not declared __far, CW will generate a near call, causing the function to read wrong parameters.

 

Regards,

Daniel

 

0 Kudos
Reply
%3CLINGO-SUB%20id%3D%22lingo-sub-2314588%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3EPorting%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2314588%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EI%20am%20trying%20to%20port%20code%20from%20cosmic%20compiler%20to%20code%20warrior%205.2%20for%20HCS12%20controller%2C%20when%20I%20am%20calling%20a%20function%20which%20is%20inside%20another%20function%20%2C%20the%20value%20passed%20to%20the%20first%20function%20is%20not%20updated%20correctly%2C%3C%2FP%3E%3CBR%20%2F%3E%3CP%3Eeg.%26nbsp%3Bvoid%20Update_Display(uint8_t%20update)%3CBR%20%2F%3E%7B%3C%2FP%3E%3CP%3E%3CSPAN%3ELCD_srWriteToDisplay(string1%2CSCREEN_LINE_WIDTH%2C20%2C0)%3B%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3E%7D%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3Einside%26nbsp%3B%20LCD_srWriteToDisplay%20function%2C%20the%20arguments%20are%20not%20having%20the%20same%20value%20which%20I%20have%20passed.%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2316144%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20Porting%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2316144%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHi%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F259706%22%20target%3D%22_blank%22%3E%40Aswin_5232%3C%2FA%3E%2C%3C%2FP%3E%0A%3CP%3ETN234%2C%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fwww.nxp.com%2Fdocs%2Fen%2Fapplication-note%2FTN234.pdf%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fwww.nxp.com%2Fdocs%2Fen%2Fapplication-note%2FTN234.pdf%3C%2FA%3E%3C%2FP%3E%0A%3CP%3Eexplains%20this%20issue%20in%20the%20section%20%E2%80%9CPorting%20non%E2%80%91ANSI%E2%80%91C%20Keywords%E2%80%9D%2C%20where%20it%20shows%20that%20Cosmic%E2%80%99s%20%40near%2F%40far%20must%20be%20replaced%20with%20CodeWarrior%E2%80%99s%20__near%2F__far%2C%20including%20for%20functions%2C%20because%20CW%20uses%20different%20calling%20conventions%20for%20near%20vs.%20far%20calls.%20%3CBR%20%2F%3EIf%20a%20function%20ends%20up%20in%20banked%20code%20but%20is%20not%20declared%20__far%2C%20CW%20will%20generate%20a%20near%20call%2C%20causing%20the%20function%20to%20read%20wrong%20parameters.%3C%2FP%3E%0A%3CBR%20%2F%3E%0A%3CP%3ERegards%2C%3C%2FP%3E%0A%3CP%3EDaniel%3C%2FP%3E%0A%3CBR%20%2F%3E%3C%2FLINGO-BODY%3E