cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F4 Voltage issue

nicolas_benoit
Associate II
Posted on December 02, 2015 at 19:05

Hello everybody,

First sorry for my english (I'm French). I am a student and i work with my partner on a project of three-motorized drone. For the control of the motors, we use a stm32f429ZI discovery card and we have a problem with the output voltage of the pin pa1 et pa2. We have to generate PWM signal on the pins pa0 pa1 and pa2, but the issue is that pa1 and pa2 output signal is 650mV amplitude instead of 3V. We also use other pins for I2C and the LCD displaying. Is this a problem of lack of power ? I join the code of the pwm generation with this post:

#include ''stm32f4xx_hal.h''
#include ''pwm.h''
#include ''defines.h''
static
GPIO_InitTypeDef PWM_GPIO_Init; 
// DOIT ETRE EN VARIABLE GLOBALE ??????
static
TIM_HandleTypeDef TIM5_Handle;
static
TIM_OC_InitTypeDef PWM_Config;
void
PWM_Init(
void
){
// initialisation
PWM_GPIO_Init.Pin = GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2; 
// from timer5 channel 1/2/3
PWM_GPIO_Init.Mode = GPIO_MODE_AF_PP;
PWM_GPIO_Init.Speed = GPIO_SPEED_FREQ_LOW;
PWM_GPIO_Init.Pull = GPIO_NOPULL;
PWM_GPIO_Init.Alternate = GPIO_AF2_TIM5; 
TIM5_Handle.Instance = TIM5 ;
TIM5_Handle.Init.Prescaler = (SystemCoreClock * PWM_MS_PERIOD) / 2000000 - 1; 
// 2000 crans par période
TIM5_Handle.Init.CounterMode = TIM_COUNTERMODE_UP;
TIM5_Handle.Init.Period = 2000 - 1;
PWM_Config.OCMode = TIM_OCMODE_PWM1;
PWM_Config.Pulse = 100 + PWM_PULSE_INIT - 1;
PWM_Config.OCPolarity = TIM_OCPOLARITY_HIGH;
PWM_Config.OCNPolarity = TIM_OCNPOLARITY_HIGH;
PWM_Config.OCFastMode = TIM_OCFAST_DISABLE;
PWM_Config.OCIdleState = TIM_OCIDLESTATE_RESET;
PWM_Config.OCNIdleState = TIM_OCNIDLESTATE_RESET;
// code
__HAL_RCC_GPIOA_CLK_ENABLE(); 
// active GPIOA si ce n'est pas déjà fait
HAL_GPIO_Init(GPIOA, &PWM_GPIO_Init); 
__TIM5_CLK_ENABLE();
HAL_TIM_PWM_Init(&TIM5_Handle);
HAL_TIM_PWM_ConfigChannel(&TIM5_Handle, &PWM_Config, TIM_CHANNEL_1);
HAL_TIM_PWM_ConfigChannel(&TIM5_Handle, &PWM_Config, TIM_CHANNEL_2);
HAL_TIM_PWM_ConfigChannel(&TIM5_Handle, &PWM_Config, TIM_CHANNEL_3);
}
void
PWM_Start(){
HAL_TIM_PWM_Start(&TIM5_Handle, TIM_CHANNEL_1);
HAL_TIM_PWM_Start(&TIM5_Handle, TIM_CHANNEL_2);
HAL_TIM_PWM_Start(&TIM5_Handle, TIM_CHANNEL_3);
}
void
PWM_Pulse(PWM pwmx, uint8_t value){
if
(value > 100) 
return
;
value+=99; 
// on reformate la valeur pour être entre 5 et 10% de la période
switch
(value){
case
PWMS : TIM5->CCR1 = TIM5->CCR2 = TIM5->CCR3 = value; 
break
;
case
PWM1 : TIM5->CCR1 = value; 
break
;
case
PWM2 : TIM5->CCR2 = value; 
break
;
case
PWM3 : TIM5->CCR3 = value; 
break
;
}
// if (CNT > value) && (CNT < CCR3) ... on met à zéro directement ? non
}

Thank you for your answers ! #stm32f4-discovery-voltage-pwm
6 REPLIES 6
Posted on December 02, 2015 at 19:45

You should probably review the F429I-DISCO User Manual over the pin utilization, and the Data Sheet for the current drive characteristics.

What have you actually got attached to the pins? They will not provide enough current to drive a motor.

What does the signals look like when you don't load the pins? Do they have the voltages you expect then? If they do then you're excessively loading the pins in your application.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
nicolas_benoit
Associate II
Posted on December 02, 2015 at 21:15

Ok we will see that but we don't find any informations about this phenomen for the moment.

No for the moment, we just observe it at the oscilloscope. The thing is that the pin pa0 provides an output signal of 3V like we want but not pa1 and pa2.

When we look at the pins pa1 and pa2, they are exactly like we want but the amplitude is too small.

Thank you for your answer.

Posted on December 02, 2015 at 22:09

Isn't that likely because PA2/PA3 are driven by the interrupt pins of the L3GD20? You're basically fighting one driver with another. Suggest you review pin utilization in the manual, and remove conflicting hardware if appropriate.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
nicolas_benoit
Associate II
Posted on December 06, 2015 at 21:26

Hi !

How do you know we use a L3GD20 ? 🙂

The problem is that we don't see anything special about PA1 or PA2 with the Search function (in the approximately 2000 pages of STM32F4 + STM32F429 datasheets ..). And when we tested the PWM we didn't add any code (just the clock tree initialization). No I2C, no interrupts ..

So I have no idea where there could be a conflicting hardware. Besides the pins rightly follow the PWM signal, but just PA1 and PA2 don't have the good amplitude.

I would add that we tried on another STM32F4-Discovery board, same modele, but we met the same problem.

Thank you for your answer !

Posted on December 06, 2015 at 21:45

How do you know we use a L3GD20 ? 🙂

Well you said you were using an STM32F429I-DISCO, at that's what connected externally to the pins. It's the manual for the board you want to review to understand what circuitry is attached to the part.

http://www.st.com/st-web-ui/static/active/en/resource/technical/document/user_manual/DM00093903.pdf

The pins should be clear on the F4-DISCO.

I can't really help you with the HAL stuff. Make sure the scope has sufficient bandwidth, and the probe is in 10X mode.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
nicolas_benoit
Associate II
Posted on December 09, 2015 at 16:59

Hi,

We try in our code to only put the pwm_init function describes in the first post and nothing else to see if there is some interferences with other function but there is the same problem: output voltage is too low. Morover, we did'nt find anything in the datasheet, maybe you have an idea ?