volatile struct in ISR?

OP #4725097
Lesenswert?
• ▲
▼
Hallo,

ich versuche Daten von einem Struct in ISR auf dem uC STM32F4 zu 
verändern. Leider klappt es nicht.


kalman_motor.c
1
/*  kalman_motor.c  */
2
#include "kalman_motor.h"
3

4
void pose_estimate(kalman_motor *k, float newPos){...}



kalman_motor.h
1
/*  kalman_motor.h  */
2

3
#ifndef KALMAN_MOTOR_H_
4
#define KALMAN_MOTOR_H_
5

6
typedef struct{
7
    float pos;
8
    float vel;
9

10
    float P1, P2, P3, P4;
11
    float Q1, Q2, Q3, Q4;
12
    float R;
13

14
    float dt;
15
}kalman_motor;
16

17
void pose_estimate(kalman_motor *k, float newPos);
18
#endif /* KALMAN_MOTOR_H_ */


main.c
1
#include "kalman_motor.h"
2

3
kalman_motor motor_pose1;
4

5
int main(void){
6

7
while(1){
8
    start= micros;
9
    control_loop();
10
    dur = micros - start;
11
    Delay(loop_time - dur);
12
}
13

14
void control_loop(void){
15
    pose_estimate(&motor_pose1, measuredPos1);
16
    motor_angle1 = motor_pose1.pos;
17
    motor_velocity1 = motor_pose1.vel;
18
}
19
}

Es funktioniert problemlos, wenn ich die 'control_loop' in der Main 
Schleife mit festen Takt aufrufe, sowie es man oben sieht.

Wenn ich den 'control_loop ' in einer Timer Interrupt aufrufe, bleibt 
der uController hängen. Es bleibt immer noch hängen wenn ich volatile 
kalman_motor motor_pose1 definiere.

Es gibt leider keine Compiler Fehler zu sehen. Compiler Optimierung ist 
bei -Os.

Weiss jemand woran es liegt.

Entschuldigt mich für die schlechte Formulierung. Bin kein 
Muttersprachler.

Danke im Voraus.

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