cancel
Showing results for 
Search instead for 
Did you mean: 

LED blinking using Simulink and STM32-MAT/TARGET not working

vlal
Associate III

I have installed STM32-MAT/TARGET , generated configuration with CubeMx, made simulink model, generated c code for keil, and compiled with out errors but the port is not toggling. I have been trying for last two weeks to get it work. I have attached cubemx file and simulink model with this message, kindly someone help me

Matlab2019a

STMcubeMx 5.3

I have tried with the simpleGPIO example supplied also, but that too didn't worked, is there any compatibility issue between the cubeMX and Matlab2019 version?

The examples supplied are made with earlier version of cubeMX and Matlab

1 ACCEPTED SOLUTION

Accepted Solutions
Cyril FENARD
ST Employee

Hi @vlal​ ,

Your main.c is not correct, stm32xxxx_it.c is missing.

It seems as if STM32\script\customRoutineProcess.tlc is not the correct one.

This file was strongly changed with the 5.1.0 version of STM32-MAT/TARGET (to fit with STM32CubeMX V5.1.0 and later).

Regards.

Cyril

View solution in original post

14 REPLIES 14
Cyril FENARD
ST Employee

Hi @vlal​ 

Thank you for giving feedback on our delivery of version 5.1.0 of July 2019.

We will analyze the problem and come back with a solution the next day.

Regards.

Cyril

Cyril FENARD
ST Employee

Hi @vlal​ 

In your use-case MATLAB 2019a and STM32CubeMX 5.3.0 are in use, and it is not a problem.

The PIN0 of GPIOA is selected to be toggled and corresponding code is generated correctly:

/* Model step function */
void untitled_step(void)
{
  /* S-Function Block: <Root>/GPIO_Write */
  HAL_GPIO_TogglePin(GPIOA, GPIO_PIN_0);
}

All the GPIOs are used in your STM32CubeMX project.

I simply modified the GPIO settings for pins used for debug (enabling SYS Debug with Trace Asynchronous Sw).

I checked that LED2 can be toggled by PA5 GPIO.

I selected this pin in the GPIO_Write block of the Simulink model, I adjusted solver step size to 0.5s, then regenerated and compiled the project.

The LED is now blinking at the rate of 0.5 time per second.

Hoping it clarified.

Regards

Cyril

vlal
Associate III

So its working in your set up, It may be a problem in my setup

By the way, I am using Proteus to simulate, I didn't ran on hardware yet

vlal
Associate III

I accidently flashed a stm32f103C8 with hex file generated with CubeMX HAL libraries for stm32f103C6. Now target cannot be detected from the flashing software, Did the mcu got damaged, can I recover the mcu?

Cyril FENARD
ST Employee

​Hi @vlal​ 

I'm not sure posting this last issue here is the right place.

The STM32 ST-LINK Utility (STSW-LINK004) can be found on the ST website and can help you.

You should be able to connect your target (knowing that your ST LINK subsystem is still operational).

Regards.

Cyril

OK, now its flashing, it was due to wrong GPIO setting, I am working on it

vlal
Associate III

I tried many times, but I didn't get the LED blink,

I have attached the whole project with this message

Cyril FENARD
ST Employee

​Hi @vlal​ ,

You changed board for your project.

I took a look at your C files.

In the current situation, this can not work, calls to step () can not be made because the interrupt is not implemented correctly (remains AutoReloadTimerLoopVal_S not incremented).

I generated my side and got:

void SysTick_Handler(void)
{
  /* USER CODE BEGIN SysTick_IRQn 0 */
{
  extern volatile uint32_t remainAutoReloadTimerLoopVal_S;
 
  /* Manage number of loop before interrupt has to be processed. */
  if (remainAutoReloadTimerLoopVal_S) {
    remainAutoReloadTimerLoopVal_S--;
  }
}
 
  /* USER CODE END SysTick_IRQn 0 */
  HAL_IncTick();
  /* USER CODE BEGIN SysTick_IRQn 1 */
 
  /* USER CODE END SysTick_IRQn 1 */
}

May you cleanup your Matlab session (remove generated folders of Simulink build, cleanup also path to avoid side effects).

Regards.

Cyril

vlal
Associate III

I have cleaned the path and removed the generated folders of Simulink build and build again

I have attached the resultant project with this message, still the LED is not blinking..