Störung bei Matrizenmultiplikation mit DSP von STM32F4

OP #3937957
Lesenswert?

Hallo,

ich bin mit meinem Latein am Ende...

Ich versuche mich gerade darin, die DSP-Lib für den STM32F4 zu nutzen.

Als Anfangsbeispiel habe ich mir die Examples von ARM kopiert und 
getestet.

Geht soweit.

Danach wollte ich mal zwei andere Matrizen multiplizieren und ich habe 
dabei nur noch merkwürdige Werte in meiner Ziel-Matrix erhalten (meist 
nan).

Und jetzt kommt es! Ich habe nur Probleme wenn die Matrix 2 den Namen B 
bzw B_f32 (Array) nutze!!!!

Also es ist so, in der Main untern wenn ich B in C umbenene und B_f32 in 
C_F32 dann läuft alles.

Ach ja, ich rechne unten noch nicht mal mit Matrix B. Ich initalisiere 
sie nur, das reicht schon aus um eine Störung in Matrix X zu erzeugen??

Weis jemand von euch wie das sein kann???

Danke schon mal

hier das Prog.
1
#include "main.h"
2
#include "stm32_ub_usb_cdc.h"
3
#include "stm32f4xx_syscfg.h"
4

5
//DE_func
6
#include "yCinit.h"
7
#include "ControlDE.h"
8
#include "usbControl.h"
9

10
//DSP
11
#include "arm_math.h"
12
#include "math_helper.h"
13

14

15

16

17

18

19
/***********DEFINES / MAKROS**************/
20
#define EXTERN
21
#define SNR_THRESHOLD   90
22

23

24
/*****************GLOBALE Variablen*************************/
25
#include "globale.h"
26

27

28

29
/* --------------------------------------------------------------------------------
30
* Test input data(Cycles) taken from FIR Q15 module for differant cases of blockSize
31
* and tapSize
32
* --------------------------------------------------------------------------------- */
33

34
const float32_t B_f32[16] =
35
{
36
  /* Const,   numTaps,   blockSize,   numTaps*blockSize */
37
  1.0,     3.0,      4.0,     2.0,
38
  1.0,     5.0,     4.0,    3.0,
39
  1.0,     2.0,      4.0,      64.0,
40
  1.0,     1.0,     2.0,    2.0,
41
};
42

43

44
/* --------------------------------------------------------------------------------
45
* Formula to fit is  C1 + C2 * numTaps + C3 * blockSize + C4 * numTaps * blockSize
46
* -------------------------------------------------------------------------------- */
47

48
const float32_t A_f32[16] =
49
{
50
  /* Const,   numTaps,   blockSize,   numTaps*blockSize */
51
  1.0,     4.0,      4.0,     4.0,
52
  1.0,     3.0,     1.0,    7.0,
53
  1.0,     4.0,      2.0,      2.0,
54
  1.0,     3.0,     10.0,    3.0,
55
};
56

57
/* ----------------------------------------------------------------------
58
* Temporary buffers  for storing intermediate values
59
* ------------------------------------------------------------------- */
60
/* Transpose of A Buffer */
61
float32_t AT_f32[16];
62

63
float32_t X_f32[16];
64

65
/* ----------------------------------------------------------------------
66
* Reference ouput buffer C1, C2, C3 and C4 taken from MATLAB
67
* ------------------------------------------------------------------- */
68

69

70
/* ----------------------------------------------------------------------
71
* Max magnitude FFT Bin test
72
* ------------------------------------------------------------------- */
73

74

75

76
  arm_matrix_instance_f32 A;      /* Matrix A Instance */
77
  arm_matrix_instance_f32 AT;     /* Matrix AT(A transpose) instance */
78
  arm_matrix_instance_f32 ATMA;   /* Matrix ATMA( AT multiply with A) instance */
79
  arm_matrix_instance_f32 C;  /* Matrix ATMAI(Inverse of ATMA) instance */
80
  arm_matrix_instance_f32 B;      /* Matrix B instance */
81
  arm_matrix_instance_f32 X;      /* Matrix X(Unknown Matrix) instance */
82

83

84
  uint32_t srcRows, srcColumns;  /* Temporary variables */
85
  arm_status status;
86

87
  clock_t start, stop, dauer;
88

89
/*****************yC Init Prototype*************************/
90
void init();
91
float32_t leastSquareDSP();
92

93
int main(void)
94
{
95

96

97

98

99
     SystemInit(); // Quarz Einstellungen aktivieren
100

101
     // Init vom USB-OTG-Port als CDC-Device
102
     // (Virtueller-ComPort)
103
     UB_USB_CDC_Init();
104

105
     leastSquareDSP();
106

107

108
  while(1)
109
  {
110

111
      //pruefe auf neue Daten am USB-Port
112
      checkUSBPort();
113

114
  }
115
}//end of main
116

117

118
float32_t leastSquareDSP()
119
{
120

121

122

123
  /* Initialise A Matrix Instance with numRows, numCols and data array(A_f32) */
124
  srcRows = 4;
125
  srcColumns = 4;
126
  arm_mat_init_f32(&A, srcRows, srcColumns, (float32_t *)A_f32);
127

128
  /* Initialise Matrix Instance AT with numRows, numCols and data array(AT_f32) */
129
  srcRows = 4;
130
  srcColumns = 4;
131
  arm_mat_init_f32(&AT, srcRows, srcColumns, AT_f32);
132

133
    srcRows = 4;
134
  srcColumns = 4;
135
  arm_mat_init_f32(&X, srcRows, srcColumns, X_f32);
136

137
  srcRows = 4;
138
  srcColumns = 4;
139
  arm_mat_init_f32(&B, srcRows, srcColumns, B_f32);
140

141
  /* calculation of A transpose */
142
  status = arm_mat_trans_f32(&A, &AT);
143

144
  status = arm_mat_mult_f32(&AT , &A , &X);
145

146
 // status = arm_mat_mult_f32(&A, &B , &X);
147

148

149
  if( status != ARM_MATH_SUCCESS)
150
  {
151
    while(1)
152
    {
153
        abstand = 23;
154
    }
155
  }
156

157
  return 0;
158

159

160

161
}
Gast #3972634
Lesenswert?

Daniel Eck schrieb:
> arm_mat_init_f32(&A, srcRows, srcColumns, (float32_t *)A_f32);

Da wird nen const cast durchgeführt. Das kann ins Auge gehen. Je 
nachdem, was das Linker-File sagt, liegen diese Daten im Flash und dann 
können keine Ergebnisse darin gespeichert werden. Nach meiner Recherche 
sind die Argumente von arm_mat_init_f32 alle nicht const! Allerdings 
sehe ich nicht, dass eine der von dir aufgerufenen Funktionen darauf 
schreiben zugreift. Trotzdem will ich es erwähnt haben. Hängt ja oft nen 
Rattenschwanz an Möglichkeiten dran.

Viel Erfolg.

Antwort schreiben

Bitte melde dich an, um einen Beitrag zu schreiben.

oder

Mit Google-Account einloggen

Die Registrierung ist kostenlos und dauert nur eine Minute.

Jetzt registrieren