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

Problem caused by data type?

I am using Analog Device ADuC848, which has 4 kbyte on-chip nonvolatile data flash. Because each page of this data memory has 4 bytes, so I define

typedef struct
{
  UINT8 value;
  UCHAR unused[3];
} NVM_SingleByte_T;

I use quite a lot of NVM_SingleByte_T to define variables throughout my program.
Now I have a very strange problem. A subroutine as below:

void cmdhandler(void)
{NVM_SingleByte_T tmpByte;
tmpByte.value = 1; }


this routine will trigger my relay which is controlled by GPIO. And if I change tmpByte.value to other number not equal to 1, it will not trigger relay. This cmdhandler has nothing to do with relay control, so how come this local variable affecting other part of my program?
Thanks in advance

Parents
  • Who said the problem is in cmdhandler
    Arrays , passing arrays, passing structs all use pointers.
    un-initialized variables can also cause issues with changes of optimization levels.
    Otherwise insure the compiler is upto date.
    Look at the asm output by the compiler.
    Make a small project with the issue (Not a code snippet) and send it to support

Reply
  • Who said the problem is in cmdhandler
    Arrays , passing arrays, passing structs all use pointers.
    un-initialized variables can also cause issues with changes of optimization levels.
    Otherwise insure the compiler is upto date.
    Look at the asm output by the compiler.
    Make a small project with the issue (Not a code snippet) and send it to support

Children