This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Error in call by reference with ST10F269

Hello!

A function is called with three pointer parameters to assemble command messages for SPI-mode communication in SPI initialization function as follows.

Problem is that the addresses of parameters change when they go into the function.

This error occurs in working with debugging version and monitor program.

CMD_Message 0x00007DD0 -> 0x7FDD0
CMD_Argument 0x00007DCC -> 0x7FDCC
CMD_Index 0x00007DCA -> 0x7FDCA

So that the assembled CMD_Message shows wrong results. I am working with Memory model of HCompact:'huge' data, 'near'func.

unsigned integer i;
unsigned char CMD_Index;
unsigned char CMD_Argument[4];
unsigned CMD_Message[6];

Assemble_CMDMessage(&CMD_Index, CMD_Argument, CMD_Message);

void Assemble_CMDMessage(unsigned char *CMD_index, unsigned char *CMD_argument, unsigned char *CMD_Message) { // Command Index consists of star bit of 1 bit, transmission bit of 1 bit, and command index of 6 bits. unsigned char good_crc7; xmemcpy(CMD_Message, (unsigned char *)CMD_index, sizeof(unsigned char)*1); // CMD_Message[0] xmemcpy(CMD_Message+1, (unsigned char *)CMD_argument, sizeof(unsigned char)*4); // CMD_Message[1] - CMD_Message[4] //Generate_CRC7(CMD_message); //generate a valid CRC field; good_crc7 = Generate_CRC7(CMD_Message); good_crc7 = good_crc7 << 1; // shift to left by 1 CMD_Message[5] = good_crc7; CMD_Message[5] = CMD_Message[5] + 1; // add end bit }

I would be really happy if anybody inform me of what causes this eror. Thanks. Yoong-Goog Cho

Parents
  • Hello! Mike.

    The problem has been resolved temporarily by putting near data type before each argument of the called function.
    However, I am going to find out more fundamental solutions for this issue, which will take some time.

    Your suggestion and comments were very helpful.
    I really appreciate your help.

    Thanks.

    Regards,

    Yoong-Goog Cho

Reply
  • Hello! Mike.

    The problem has been resolved temporarily by putting near data type before each argument of the called function.
    However, I am going to find out more fundamental solutions for this issue, which will take some time.

    Your suggestion and comments were very helpful.
    I really appreciate your help.

    Thanks.

    Regards,

    Yoong-Goog Cho

Children
No data