s12zvl micro-controller Endianness

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

s12zvl micro-controller Endianness

跳至解决方案
1,655 次查看
charudattaingal
Contributor IV

Hi,

 

I observed that s12zvl micro-controller is Big Endian i am not getting any option to convert it into Little Endian format.

let me know if any option is available to convert endianness of s12zvl micro-controlle Big Endian to Little Endian.

Is there any code warrior IDE  option available ?

 

 

Thanks & Regards,

Charudatta

标签 (1)
0 项奖励
1 解答
970 次查看
GordonD
Contributor IV

Charudatta,

The CPU in all S12 MCUs (S12, S12S, S12X & S12Z) are Big Endian CPUs. That is they store the most significant byte of multi-byte types at the lowest address. Some advanced architectures allow the 'endianness' of a CPU to be configured 'on the fly' (I believe some Power Architecture devices allowed this). Some architectures, like ARM, allow the Endianness to be chosen when the device is implemented, but then it is fixed.

The Endianness of all S12Z devices is fixed as Big Endian.

Regards,

Gordon

在原帖中查看解决方案

0 项奖励
4 回复数
970 次查看
RadekS
NXP Employee
NXP Employee

HI Charudatta,

CW offers some tools which could be configured to Big or Little endian, but these tools was created for operations like dump from or load to memory and display data in memory window.

So, you can just display/export/import content of Flash/EEPROM/RAM in appropriate orde, but S12Z core works also with data in Big Endian order. For more details about memory window, please look at chapter “7.5.15 Can I change the endianness that is displayed in the Memory view?” in document:

"c:\Freescale\CW MCU v10.6\MCU\Help\PDF\Microcontrollers_FAQ_Guide.pdf"

If you will need swap between endian orders for some IO functions, probably you will have to use some conversion functions. As example you could look at standard POSIX htonl(), htons(), ntohl(), ntohs() functions.

/* Macros for converting values between big-/little-endian byte order */

#define _SWAP2BYTE_CONST(n) ((((n) & 0x00FF) << 8) | (((n) & 0xFF00) >> 8))

#define _SWAP4BYTE_CONST(n) ((((n) & 0x000000FF) << 24) | (((n) & 0x0000FF00) << 8) | (((n) & 0x00FF0000) >> 8) | (((n) & 0xFF000000) >> 24))


I hope it helps you.

Have a great day,
RadekS

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 项奖励
970 次查看
charudattaingal
Contributor IV

Hi Radeks,

Thanks for your response.It may help me.

Have a great day,

Regards,

Charudatta

0 项奖励
971 次查看
GordonD
Contributor IV

Charudatta,

The CPU in all S12 MCUs (S12, S12S, S12X & S12Z) are Big Endian CPUs. That is they store the most significant byte of multi-byte types at the lowest address. Some advanced architectures allow the 'endianness' of a CPU to be configured 'on the fly' (I believe some Power Architecture devices allowed this). Some architectures, like ARM, allow the Endianness to be chosen when the device is implemented, but then it is fixed.

The Endianness of all S12Z devices is fixed as Big Endian.

Regards,

Gordon

0 项奖励
970 次查看
charudattaingal
Contributor IV

Hi Gordon,

Thanks for your response.It may help me.

Regards,

Charudatta

0 项奖励