Interrupt handling STM32F4 Embedded Coder
I'm using the STM32 MAT plugin and embedded coder for Simulink to generate C-Code out of my models to compile them onto an STM32F4. As IDE I use TrueStudio and for my MCU Configuration I use CubeMX.
Because my discrete solver step time in Simulink is set, it seems that the embedded coder tries to make a Software based Interrupt every 0.001 seconds.
#include "main.h"
void SystemClock_Config(void);
static void MX_GPIO_Init(void);
#include
#include "untitled.h" /* Model's header file /
#include "rtwtypes.h" / MathWorks types */
extern RT_MODEL_untitled const untitled_M;
extern void untitled_SetEventsForThisBaseStep(boolean_T);
static boolean_T OverrunFlags[1];
static volatile uint32_t autoReloadTimerLoopVal_S = 1;
static volatile uint32_t remainAutoReloadTimerLoopVal_S = 1;
int main(void)
{
int_T i;
HAL_Init();
SystemClock_Config();
MX_GPIO_Init();
/* Systick configuration and enable SysTickHandler interrupt */
if (SysTick_Config((uint32_t)(SystemCoreClock * 0.001))) {
autoReloadTimerLoopVal_S = 1;
do {
autoReloadTimerLoopVal_S++;
} while ((uint32_t)(SystemCoreClock * 0.001)/autoReloadTimerLoopVal_S >
SysTick_LOAD_RELOAD_Msk);
SysTick_Config((uint32_t)(SystemCoreClock * 0.001)/autoReloadTimerLoopVal_S);
}
remainAutoReloadTimerLoopVal_S = autoReloadTimerLoopVal_S;//Set nb of loop to do
for (i=0;i<1;i++) {
OverrunFlags[i] = 0;
}
untitled_initialize();
while (1) {
/*Process tasks every solver time*/
if (remainAutoReloadTimerLoopVal_S == 0) {
remainAutoReloadTimerLoopVal_S = autoReloadTimerLoopVal_S;
/* Check base rate for overrun */
if (OverrunFlags[0]) {
rtmSetErrorStatus(untitled_M, "Overrun");
}
OverrunFlags[0] = true;
/* Step the model for base rate */
untitled_step();
OverrunFlags[0] = false;
}
}
}
/* SysTick_Handler callback function*/
/*This handler is called every tick and schedules tasks*/
void HAL_SYSTICK_Callback(void)
{
/* For TIME OUT processing */
HAL_IncTick();
/* Manage nb of loop before interrupt has to be processed */
if (remainAutoReloadTimerLoopVal_S) {
remainAutoReloadTimerLoopVal_S--;
}
}Unfortunately when I try to run the Code, nothing happens. The Compiler always stucks at the if condition in the while (1) Loop. So I see that there's something wrong here with the Interrupt handling, but I don't know how to resolve the issue. Probably you can help
