# STM32 interrupt from Matlab Code

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))) {
do {
} while ((uint32_t)(SystemCoreClock * 0.001)/autoReloadTimerLoopVal_S >

}

for (i=0;i<1;i++) {
OverrunFlags[i] = 0;
}
untitled_initialize();

while (1) {

/* 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 */
}
}


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

• Without trying to be a smart aleck, it seems like you need to roll up your sleeves and learn how to use your tools. As somebody who has done things like you're describing quite a few times, just getting up to the point you describe is a 20 to 40 hour process. – Scott Seidman Apr 24 at 13:16

NVIC_EnableIRQ(SysTick_IRQn);