Hi guys
I am not sure this is the right place to put HCS12 issues, but as it is related to code porting from HCS08 to HCS12 u may help me out.
I was able to port the above code successfully HCS12 microcontroller MC9s12NE64, just one small issue. In the function CopyInRAM , I had to assign explicitely RAM staring value to make the code work, otherwise code crashes,
HCS08 CODE:
void CopyInRAM(void)
{
char *srcPtr;
char *dstPtr;
int count;
srcPtr = (char *)Start_Copy_In_RAM;
dstPtr = (char *)&Flash_Cmd;
for (count = 0; count < (int) Size_Copy_In_RAM; count++, dstPtr++, srcPtr++)
{
*dstPtr = *srcPtr;
}
}
HCS12 Code
void CopyInRAM(void)
{
char *srcPtr;
char *dstPtr;
int count;
srcPtr = (char *)Start_Copy_In_RAM;
dstPtr = (char *)0x2000;
for (count = 0; count < (int) Size_Copy_In_RAM; count++, dstPtr++, srcPtr++)
{
*dstPtr = *srcPtr;
}
}
the question is why the code is not taking the starting addrtess of RAM from Flash_Cmd and why it has to be explicitely defined.
#define EEPROM_BASE 0x1400 // Base address for EEPROM memory in a DZ60#define DYNAMIC_GROUP_OFFSET 0x40 // Offset for storage of dynamic group#define READ_EEPROM_BYTE(x) *(uint8_t *)(x + EEPROM_BASE) // Macro to retrieve a byte from an absoulte address in EEPROM memory...unsigned char Read_Data;Read_Data = READ_EEPROM_BYTE(DYNAMIC_GROUP_OFFSET); // Read from an offset value in EEPROM memory...
1) The linking initially failed because the reset vector was defined in two places (with the use of
MCUInit() function).
2) I received a C1805 warning at the line -
dstPtr = (char *)&Flash_Cmd;
However, the pointer value was actually correct (0x0100). The warning is "Non standard conversion
used".
3) The following description seems a little confusing to me -
/*
Start_Copy_In_RAM refers to the begining of the segment ToCopyToRAM.
This segment contains the functions after they have been copied to RAM.
*/
#define Start_Copy_In_RAM __SEG_START_FLASH_ROUTINES
#define Size_Copy_In_RAM __SEG_SIZE_FLASH_ROUTINES
The macro actually refers to the source address of the code block. The segment contains the functions
as they exist in flash.