I got the following issue. When I copy one int my main code it works fine. only when the data is a struct then result is zero
struct CLA_Estdata_
{
MOSPROF_State state;
int speed_hz;
motorpos_t position_cnt;
float Torque;
int counter;
};
typedef struct CLA_RESdata_ volatile CLA_RESdata_t;
Cla:
#pragma DATA_SECTION(CLA_estdata,"Cla1ToCpuMsgRAM")
volatile CLA_Estdata_t CLA_estdata;
#pragma DATA_SECTION(CLA_test,"Cla1ToCpuMsgRAM")
volatile int CLA_test;
__interrupt void Cla1Task4 ( void )
{ CLA_estdata.counter++;
CLA_test++;
}
Main code:
static inline CLA_Update_clafreq (void)
{
extern volatile CLA_Estdata_t CLA_estdata;
extern volatile int CLA_test;
extern long volatile CLA_Freq;
CLA_Freq=CLA_test;
}
result CLA_freq is updated every time with a new value
static inline CLA_Update_clafreq (void)
{
extern volatile CLA_Estdata_t CLA_estdata;
extern volatile int CLA_test;
extern long volatile CLA_Freq;
CLA_Freq=CLA_estdata.counter;
}
result: CLA_Freq is always zero. In the debug window I see CLA_estdata.counter is counting. So CLA_estdata.counter is filled with the correct data so why can't the cpu get access to it.
Someone a suggestion how to solve this? What is the difference between a single variable and a struct?