cancel
Showing results for 
Search instead for 
Did you mean: 

I am new and I need some help programming a PWM on the micro STM32F303ZET6

SRami.2
Associate II

I am programming a output PWM using the timers on this processor. since I am new, I decided to start using the examples for this specific processor found in the folder 'en.stm32cubef3_v1.11.0'

As a first instance I execute the project file in the folder I attached here 'SW4STM32". I place that folder into my workspace . when I execute this file the software pretty much set everything form me. but when I build the project always an error shows up:

22:12:56 **** Incremental Build of configuration Release for project STM32F303ZE-Nucleo ****

make all 

make: *** No rule to make target 'C:/Users/steph/OneDrive/Documentos/Src/stm32f3xx_hal_msp.c', needed by 'Example/User/stm32f3xx_hal_msp.o'. Stop.

"make all" terminated with exit code 2. Build might be incomplete.

22:12:57 Build Failed. 1 errors, 0 warnings. (took 250ms)

The other way I am trying to do my project is creating a new 'SM32 project', once I select the processor I have and select C++ as the language. the software set everything for me and create a template of the main.c/main.h file which I replace with the files attached here. In this case the error I am sure is because there is a file missing in the folder, the file is "stm32f3xx_nucleo_144.h". This file contains some variable declarations as "TIM_HandleTypeDef  TimHandle;"

Could you please help me out with this. I am a little confuse regarding this

10 REPLIES 10
MM..1
Chief II

You dont write how IDE you use, KEIL, CubeIDE ....

SW4STM32 is little obsolete or specific.

When you use CubeIDE, here is wizard for examples or open directly from Users\yourNM\STM32Cube\Repository\STM32Cube_FW_F3_Vxxx\

MM..1 Thank you so much for your answer.

Looks like this is the exact same folder I am using the path is: Users\Myname\STM32Cube\Repository\STM32Cube_FW_F3_V1.11.3\Projects\STM32F303ZE-Nucleo\Examples\TIM\TIM_PWMOutput, you will find there the same folder I attached when I create this post plus, the main.c/main.h are located on Src and Inc folders respectively.

To answer the first question I am using STM32CubeIDE 1.7.0.

Thanks in advance for all your help.

MM..1
Chief II

Try when example dont have cubeide folder with .project file simplest way.

Create new project set in opened MX complete config with pwm... And to generated main add only lines to start pwm.

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

SRami.2
Associate II

Thanks so much for your help, that works!!. I have no errors now. I will start testing now.

Greetings MM1.

I am writing to you again to see if you can help me, last time I was having problems building my project because it was generating errors, so what I did was following your recommendation and I use the MX to select the timer I want to use to generate the PWM, once here I go into the 'Mode' options, here we have some settings that can be selected from drop down menus, and in 'slave mode' so far I had selected 'Trigger Mode' and 'disable' for trigger sours I had chosen ITR0 and ITR1, Clock Sours set on internal clock, finally in channel I pick PWM generation and force output.

I do all those combinations mentioned before, but when I hit the debug button and check the GPIO configured by the MX, no PWM show in my oscilloscope.

Could you please help me out with this?

Thanks in advance for all your help.

I just wanted to attached the main.c file generated by the MX

In your main code i dont see one user command to start pwm as i write before. Without this your pwm is inited but not started.

Sorry, Thought I had it in one of the functions, observation mistake. I did not notice the difference between the initialization and and the PWM start code line.

Thanks a lot again.

SRami.2
Associate II

Greetings MM.1

I am needing your help again. I made some modification to the previous code and now I want to generate a the PWM signal and measure the frequency from the PWM signal using TM2 but is not working, it even cancel out my PWM. The code is attached here, could you please let me know what I am doing wrong?

There is another program I am trying to do and that I will add to the PWM, and this is sending information over the USB port,. it is no working either. I attached the code here as well.