2013-04-07 09:28 PM
Hi all,
i have a problem, i have 6 complementary pwm (TIM1) and i used ADC to change the duty cycle. this my main function:int main(void){ /* System Clocks Configuration */ RCC_Configuration(); /* GPIO Configuration */ GPIO_Configuration(); ADC_Config(); while (1) { pulse =(ADC_GetConversionValue(ADC1)*731)/4096;/* TIM_OCInitStructure.TIM_Pulse = pulse; TIM_OC1Init(TIM1, &TIM_OCInitStructure); TIM_OCInitStructure.TIM_Pulse = pulse; TIM_OC2Init(TIM1, &TIM_OCInitStructure); TIM_OCInitStructure.TIM_Pulse = pulse;TIM_OC3Init(TIM1, &TIM_OCInitStructure);*/ }}the PWM's voltage is between 1v and 3v3 and it must be between 0v and 3v3.Please help me :)2013-04-07 11:44 PM
You didn't mention the hardware you use.
Check the schematics, and see if there is anything connected externally to this pin. Like a pullup resistor, for instance.2013-04-08 05:48 AM
''the PWM's voltage is between 1v and 3v3 and it must be between 0v and 3v3''
For 0V, the wouldn't output have to be OFF...? And, as already noted, check your hardware for sources of offsets...2013-04-08 04:13 PM
yes i connected a resistance with a LED to test the PWM signal. i didn't have a scope yet. So i generated 2 complementary PWM. when the led should be off it stay powred but the brightness decreases :/
2013-04-09 02:25 AM
Did you check the LED forward voltage and current, i.e. can you really drive it directly ?
I suggest to disconnect your LED + resistor, configure the pin as GPIO and measure the voltage statically while toggling. If the problem persists, you might have something else connected to this pin on the board. Edit: Again, it could be an advantage if you tell us more about your hardware. A STM32xx Discovery, Evaluation or Custom board ?2013-04-09 05:49 PM
Hi,
related to pin PA8 and PB13, there are a resitor (220ohm) + RED LED and i have a potentiometer (1k) related to PA0 (ADC CH1) +VCC+GND. That's all2013-04-09 11:27 PM
...related to pin PA8 and PB13, there are a resitor (220ohm) + RED LED...
That should result in about 5mA LED current, assuming 2.4V forward voltage, and sounds o.k. But again, this are the hardware that you connected. Have you checked the the schematics ? If you configure this pin(s) as GPIO, and measure statically, you should see 0V and Vdd when nothing else is connected. I had a similiar case not so long ago, were a GPIO did not go below 2.4V. And when checking the schematics, it turned out that, surprise, a MEMS sensor output was connected to this pin.
2013-04-10 10:23 AM
the schematic is fine.something is weird:
when i fixed the duty cycle and don't use ADC, that works very well but when i use adc i have this problem :/2013-04-10 10:57 AM
You don't try to configure the same pin as ADC input and PWM output, do you ?
If so, it is probably easiest to use another ADC channel, as the timer <-> PWM-out assignment is fixed.2013-04-10 11:05 AM