Hi, I want to write to EEPROM in S12G128.
But my CW(Code Warrior) show me the error message (Label 'Send_Command Undefined).
This is my code.
byte EEPROM_Program(word address, word *ptr, byte number_of_words)
{
word i;
if((number_of_words < 1) || (number_of_words > 4))
return LENGTH_OUT_OF_RANGE;
// check if address is aligned (global address [0] != 0)
if((address & 0x0001) != 0)
return MISALIGEND_ADDRESS;
// check if the word(s) is/are erased
if((EEPROM_Erase_Verify_Section(address, number_of_words)) == NON_ERASED)
return NON_ERASED;
while(FSTAT_CCIF == 0);
FSTAT = 0x30;
FCCOBIX = 0x00;
FCCOB = 0x1100;
FCCOBIX = 0x01;
FCCOB = address;
for(i=1; i<=number_of_words; i++)
{
FCCOBIX = i+1;
FCCOB = *ptr;
ptr++;
}
asm JSR Send_Command;
if((FSTAT & (FSTAT_ACCERR_MASK | FSTAT_FPVIOL_MASK)) != 0) return ACCESS_ERROR;
if(FSTAT_MGSTAT != 0) return VERIFICATION_FAILED;
return OK;
}
What am I forgot something?
解決済! 解決策の投稿を見る。
Hi,
I think your code is missing the routine you are trying to call by command. The code looks like code taken from some example provided by us (NXP technical support).
asm JSR Send_Command
The routine is an array of ASM commands (placed in the RAM) which must be executed out of the memory which is currently E/W. In order to avoid accidental access if the routine is place either in EEPROM or Flash EEPROM it is placed inside the RAM.
It, of course, must be defined somewhere:
//******************************************************************************
//EEPROM Send_Command
//******************************************************************************
//this function is stored in RAM memory
//in C language:
// {
// FSTAT_CCIF = 1; //launch command
// while(FSTAT_CCIF == 0); //wait for done
// }
static byte Send_Command[]=
{
0x1C, 0x01, 0x06, 0x80, 0x1F, 0x01, 0x06, 0x80, 0xFB, 0x3D
};
//******************************************************************************
Best regards,
Ladislav
Hi,
I think your code is missing the routine you are trying to call by command. The code looks like code taken from some example provided by us (NXP technical support).
asm JSR Send_Command
The routine is an array of ASM commands (placed in the RAM) which must be executed out of the memory which is currently E/W. In order to avoid accidental access if the routine is place either in EEPROM or Flash EEPROM it is placed inside the RAM.
It, of course, must be defined somewhere:
//******************************************************************************
//EEPROM Send_Command
//******************************************************************************
//this function is stored in RAM memory
//in C language:
// {
// FSTAT_CCIF = 1; //launch command
// while(FSTAT_CCIF == 0); //wait for done
// }
static byte Send_Command[]=
{
0x1C, 0x01, 0x06, 0x80, 0x1F, 0x01, 0x06, 0x80, 0xFB, 0x3D
};
//******************************************************************************
Best regards,
Ladislav
Thanks. I solved this problem to your answer.