cancel
Showing results for 
Search instead for 
Did you mean: 

3-phase sinusoidal PWM (OPEN LOOP)

muratterzi
Associate II
Posted on October 14, 2009 at 10:44

3-phase sinusoidal PWM (OPEN LOOP)

18 REPLIES 18
gayatri
Associate II
Posted on May 17, 2011 at 13:26

Hi ,

I've decided to use TIM1 (PA8 ) as output. I need only one SPWM signal. I wish to know where to keep that code for PWM[i] which you were talking about. I tried keeping that code in STM32f10x_it.c but it was showing me errors when i compliled it.

Thanks..
lowpowermcu
Associate II
Posted on May 17, 2011 at 13:26

Hi gaya,

copy the code below in TIM1_CC_IRQHandler()

i++;

TIM_OCInitStructure.TIM_Pulse = PWMdata[i];

TIM_OC1Init(TIM1, &TIM_OCInitStructure);

/* check if array's index reaches the max: 255 */

if (i == 255) i = 0;

TIM_ClearFlag(TIM1, TIM_Flag_CC1);

Do not forget to declare ''i''.

What is the error message you are getting?

MCU Lüfter

gayatri
Associate II
Posted on May 17, 2011 at 13:26

Hi,

I'm using timer1 & in code TIM_TimeBaseStructure.TIM_Period = 399 i.e to get a output frequency of 20KHz. I've written a loop to get the output to read values in PWM data but the frequency is changing continously. I want to know which is that interrupt or flag or register that will update or set when the timer reaches a count of 400 (399+1). So that i can put my loop code to execute when the timer reaches the desired count. should i change something from timer1 interrupt or from NVIC configuration to check for that timer count.
gayatri
Associate II
Posted on May 17, 2011 at 13:26

Hi Lufter,

The errors I'm getting after pasting that code in stm32f10x_it.c in TIM1_CC_IRQHandler()

 

 

error1:identifier ''TIM_OCInitStructure'' is undefined

error2: identifier ''PWMdata'' is undefined

error3: error:  #20: identifier ''TIM_Flag_CC1'' is undefined

These are the 3 errors i'm facing. & i've declared ''i'' as extern unsigned int i=0;

Posted on May 28, 2011 at 08:43

These are pretty basic errors in C when you don't #include the correct files from the library, and fail to define extern's across source files. If PWMdata is defined in main.c, the only way it will be visible in stm32f10x_it.c is for it to be defined as an extern.

The errors I'm getting after pasting that code in stm32f10x_it.cTIM1_CC_IRQHandler()

 

 

error1:identifier ''TIM_OCInitStructure'' is undefined

 

error2: identifier ''PWMdata'' is undefined

 

error3: error:  #20: identifier ''TIM_Flag_CC1'' is undefined

 

 

These are the 3 errors i'm facing. & i've declared '' i'' as extern unsigned int i=0;
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
gayatri
Associate II
Posted on June 06, 2011 at 10:21

Muratterzi,

Please respond to my queries.

Thanks in advance

esiqueira
Associate II
Posted on December 20, 2011 at 11:46

The original post was too long to process during our migration. Please click on the provided URL to read the original post. https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006I6YZ&d=%2Fa%2F0X0000000bqf%2Fl.2_5LZqTX.H8tEMcXd97EYZOB.Yd8692pgHmmV0.vQ&asPdf=false
sks7592
Associate
Posted on August 20, 2014 at 07:30

Hi,

I have an STM32F051 board. I want to generate a 3 phase sinusoidal pwm waveform, and also control its frequency and duty cycle. How can this be done? F0 series has only 1 parameter for NVIC Priority, whereas F1 and higher versions have multiple priorities. How can the program be transformed to suit my requirements?

Posted on August 20, 2014 at 15:37

Look this is a thread from 2009 (Five Years Ago, the 17-May-2011 date is when the forum melted down last), the interrupt priority really doesn't material effect how it works, and as best I can tell at a glance is that it interrupts on each of the timer channels, and then programs a new pulse width into that channel. The frequency is going to depend on the timer's prescaler, and period, and the length of the table.

Please open a NEW thread for a NEW topic, and refer to, or cite, the old one if you must
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..