Loading...
 

Zephyr project on STM32

   Zephyr Workbench, a VSCode extension to manage Zephyr on STM32.
It enables users to easily create, develop, and debug Zephyr applications.
Main features:
  • Install host dependencies.
  • Import toolchain and SDK.
  • Create, configure, build and manage apps.
  • Debug STM32.
You can directly download it from the VSCode marketplace
For more details, visit the Zephyr Workbench

System Workbench for STM32


[RESOLVED]I can't modifie an main.c file after first compilation

Hello everyone,

My first problem is corrected, (GPIO and TIM library from home STM), after successfully compile and load the programmeTIM_PWM_output, I have tried to change the “main.c” in order to adapt it to my needs. In the loop “while (1) {}” contained in “int main (void)”, i added this:
/*On commence à jouer au con
* -Cablage:
* - TIM2_CH1 : PA.5 (Arduino A4) -->REDLED
- TIM2_CH2 : PA.1 (Arduino A1) -->GREENLED
- TIM2_CH3 : PA.2 (Arduino A7) -->BLUELED
- TIM2_CH4 : PA.3 (Arduino A2) -->

* */
/*On commnce par faire varier la led rouge
* avec les #define PULSEx_VALUE
* On les remplacera par des fonctions d’ incrémentaions par la suite
* */
sConfig.Pulse = PULSE1_VALUE; HAL_Delay(2000);
sConfig.Pulse = PULSE2_VALUE; HAL_Delay(2000);
sConfig.Pulse = PULSE3_VALUE; HAL_Delay(2000);
sConfig.Pulse = PULSE4_VALUE; HAL_Delay(2000);

I have wanted to create a new file.bin, but it doesn’t work, there is there a manipulation to force SW4STM32 so that the modified program is taken into account?

In fact, the IDE does not try to recompile.

If you have tracks to point me, I’d be happy

EDIT:
I forgot to specify that I commented the following lines:
/* Set the pulse value for channel 1 */
// sConfig.Pulse = PULSE1_VALUE;
// if (HAL_TIM_PWM_ConfigChannel(&TimHandle, &sConfig, TIM_CHANNEL_1) != HAL_OK)
// {
/* Configuration Error */
// Error_Handler();
// }

Sorry, bad understing from me,

i dont use sConfig.Pulse for change the duty cycle in the while.

I search what the good variable for do this.


Hello, the problem was solved, to change the duty cycle in the loop “while (1)”
I have proceeded as follows:

while (1)
{
/*On commence à jouer au con
* -Cablage:
* - TIM2_CH1 : PA.5 (Arduino A4) -->REDLED
- TIM2_CH2 : PA.1 (Arduino A1) -->GREENLED
- TIM2_CH3 : PA.2 (Arduino A7) -->BLUELED
- TIM2_CH4 : PA.3 (Arduino A2) -->

* */
/*On commnce par faire varier la led rouge
* avec les #define PULSEX_VALUE
* On les remplacera par des fonctions d’ incrémentaions par la suite
* */
sConfig.Pulse = PULSE1_VALUE;
if (HAL_TIM_PWM_ConfigChannel(&TimHandle, &sConfig, TIM_CHANNEL_1) != HAL_OK)
{
/* Configuration Error */
Error_Handler();
}
if (HAL_TIM_PWM_Start(&TimHandle, TIM_CHANNEL_1) != HAL_OK)
{
/* PWM Generation Error */
Error_Handler();
}
HAL_Delay(2000);

sConfig.Pulse = PULSE2_VALUE;

if (HAL_TIM_PWM_ConfigChannel(&TimHandle, &sConfig, TIM_CHANNEL_1) != HAL_OK)
{
/* Configuration Error */
Error_Handler();
}
if (HAL_TIM_PWM_Start(&TimHandle, TIM_CHANNEL_1) != HAL_OK)
{
/* PWM Generation Error */
Error_Handler();
}
HAL_Delay(2000);

sConfig.Pulse = PULSE3_VALUE;
if (HAL_TIM_PWM_ConfigChannel(&TimHandle, &sConfig, TIM_CHANNEL_1) != HAL_OK)
{
/* Configuration Error */
Error_Handler();
}
if (HAL_TIM_PWM_Start(&TimHandle, TIM_CHANNEL_1) != HAL_OK)
{
/* PWM Generation Error */
Error_Handler();
}
HAL_Delay(2000);

sConfig.Pulse = PULSE4_VALUE;
if (HAL_TIM_PWM_ConfigChannel(&TimHandle, &sConfig, TIM_CHANNEL_1) != HAL_OK)
{
/* Configuration Error */
Error_Handler();
}
if (HAL_TIM_PWM_Start(&TimHandle, TIM_CHANNEL_1) != HAL_OK)
{
/* PWM Generation Error */
Error_Handler();
}
HAL_Delay(2000);

}

I have therefore been able to vary the intensity of my LED.

Thank Skywodd, who brought me the solution.
How to independently change the duty cycle of a PWM channel from the example TIM / TIM_PWMOut


 

Newest Forum Posts

  1. reservation car service Seattle by Jamesprede, 2025-05-01 10:06
  2. Last day: drone bonus by Danielrug, 2025-04-19 16:55
  3. SPI on Nucleo_STMH533RE by higginsa1, 2025-03-25 07:37
  4. SPI on Nucleo_STMH533RE by royjamil, 2025-03-23 11:31
  5. SPI on Nucleo_STMH533RE by higginsa1, 2025-03-23 09:33
  6. Configuring DMA for ADC in SW? by sam.hodgson, 2025-03-04 12:58
  7. Insightful Perspectives on This Subject by davidsycle, 2025-03-04 05:45
  8. Build a project in "release" mode by info@creosrl.it, 2025-02-20 18:12
  9. Build a project in "release" mode by info@creosrl.it, 2025-02-20 17:05
  10. Build a project in "release" mode by tang, 2025-02-20 10:36

Last-Modified Blogs