Hi everybody,
Currently I am using HCS12 controllers.
Now I am thinking of using Kinetis controllers but I have tons of code written for big endian controllers.
Does anyone know if Kinetis controllers & CW 10.2/10.3 are able to work with big endian?
Thanks
Nikos
I'm not going to ask why you need it - IMHO you don't need to justify your question.
Search this forum for 'endian' and you'll find that it depends on which Kinetis. Also check out:
http://mcuoneclipse.com/2012/02/19/a-little-or-big-indian-a-plea-for-peace/
good luck.
Hi
ARM cores have a bit that controls whether it operates in little or big endian mode. But this bit is often (or usually) fixed to little-endian in specific chips. The Kinetis sets to it little-endian, which is true for all Kinetis derivatives (as far as I know).
There are some peripherals that can work with either little-endian or big-endian storage (eg. Ethernet and USB controllers: see ETHER_DBSWP bit in ECR in 'some' version of the EMAC).
Since almost nothing from HCS12 peripheral driver code can be used on the Kinetis there shouldn't be any real issues. When writing protocol code (such as Ethernet/TCP/IP where all is in big-endian order) it is to be hoped that the code is written in a manner that is not endian-dependent since that would have been a "portability-mistake". If this is the case it will be necessary to convert all half- and long-words used each time they occur in the original code. Using a macro to do this is a common strategy - when the endianness doesn't require a conversion it can be a dummy macro that doesn't do anything and in the other case it swaps the byte content around. I think that there is an instruction in the Cortex that can do this very efficiently if the macro can be optimised to use the appropriate assembler command.
Regards
Mark
if you:
#include <types.h>
you can use macros in there such as ieee_htons() which adjust depending on whether the processor is big or little, then your code will be portable.
M
Hi
I was not able to find this header file. I am using Kinetis k60 uc . I want to convert little endian float values to big endian float. Did you get some solution for this?
Kind Regards
Amit Kumar
Please explain exactly how the endian-ness will affect your code.