AnsweredAssumed Answered

STM32F4 Unknown CFSR register constents problem

Question asked by van_wyk.herman on Nov 5, 2013
Latest reply on Nov 8, 2013 by van_wyk.herman
Hi all,

I am porting code from an existing Intel 8031 platform onto a STM32F407. The software performs PID calculations.
The softwqare has been running without issues on the 8031 for several years, but I am having difficulty getting it to work on the STM32F4.

A hardfault failure occurs as soon as I the contents of a structure is compared/used.
The hardfault errors as printed out via debug messages are:

According to the Cortex-M4 programming manual, the bit set in CFSR is supposed to be reserved, thus I do not know what it means if bit 28 is set. All I know it that it is a user fault.

Here is the structure containing the data for PID calculations:
#pragma pack(push,1)
typedef struct
  int      auto_man;
  int      forward_rev_ctrl_flag;
  int      output_inc_dec_flag;
  int      pid_init;
  int      auto_man_last;
double    *var_x;
double    *var_x_low_end;
double    *var_x_high_end;
double    *setpoint;
double    *prop_gain;
double    *int_time;
double    *diff_time;
double    *output_y_man;
double   integral_pre;
double   differential_pre;
double   prop_term;
double   int_term;
double   diff_term;
double   range;
double   xw;
double   xw_old;
double   xw_sum;
double   output_y;
double   output_y_temp;
#pragma pack(pop)

Here is the declaration of the structure:
static PidStruct pid[2];

Here is the usage of the code. Failure occurs at line 33
01.double pid_compute(  int      arr,
02.                     int      auto_man,
03.                     int      forward_rev_ctrl_flag,
04.                     int      output_inc_dec_flag,
05.                     int      pid_init,
06.                     double   far *var_x,
07.                     double   far *var_x_low_end,
08.                     double   far *var_x_high_end,
09.                     double   far *setpoint,
10.                     double   far *prop_gain,
11.                     double   far *int_time,
12.                     double   far *diff_time,
13.                     double   far *output_y_man
14.                     )
16. int x;
18. x = arr-1;
19. if(pid_init == 1)
20.   {
21.   pid[x].var_x            = var_x;
22.   pid[x].var_x_low_end    = var_x_low_end;
23.   pid[x].var_x_high_end   = var_x_high_end;
24.   pid[x].setpoint         = setpoint;
25.   pid[x].prop_gain        = prop_gain;
26.   pid[x].int_time         = int_time;
27.   pid[x].diff_time        = diff_time;
28.   pid[x].output_y_man     = output_y_man;
29.   pid[x].forward_rev_ctrl_flag  = forward_rev_ctrl_flag;
30.   pid[x].output_inc_dec_flag    = output_inc_dec_flag;
32.   /* precalculations for pid algorithm */
33.   if(*pid[x].int_time == 0.0)
34.      {

Any ideas what might be wrong?