cancel
Showing results for 
Search instead for 
Did you mean: 

Remove alternate function of single TIM1 Channel outputs and get the control over these pins by GPIO on the fly and take the alternate function back on the fly.

Tetrastruct
Associate II

I 'v been driven creasy since some days, cause I did not find a way to switch off the PWMs at one channel of timer 1 ( CH1 an CH1N ie.) in order to use these pins controlled by normal GPIO commands on the fly,while the other channels shoud work again in PWM mode.

I thougt simple I could change the MODER register, select GPIO PP Mode program the Pins and it would work - but nothing works so. The PWM did not hide. They are always present at the pin and not the ODR content.

The PWM wont never stop at these pins even when I changed the MODER register and programmed out these two pins in the ODR Register the ODR signals will not leave the chip always the PWMs .

Who can help me ? What I did wrong ? the Lock Register ic completely cleared.

Thank you for answes.

Reinhard

8 REPLIES 8

What STM32 part are we talking about?

You should be able to disassociate AF connectivity on a pin-by-pin basis

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
S.Ma
Principal

If using stm32f103, the alternate function system on newer devices has made progress since then....

STM32F04

Yes I will try that, May be I have to switch it to AF0(System) to switch the port back to ODR.

Tkank you for your comment.

Reinhard

> STM32F04

What's that? STM32F042?

> May be I have to switch it to AF0(System) to switch the port back to ODR.

No, just switch given pin's GPIO_MODER setting from 0b10 (AF) to 0b01 (Out).

Read out and check/post content of relevant GPIO registers before and after the switch. You can do it in debugger, without writing any code.

JW

Tetrastruct
Associate II

sorry wrong typed ST32F405.

Hello Jan, Thanks a lot for your answer, Yes you are right this works, I tried it and imediately it works, indepedent from changing other registers and alternete functions and so on. Thank you very much.

I tried this at the first of all but in this test i forgot to unplug the motor and all three PWM outputs were connected together by the motor coils of some mOhms. So I never saw the result of my activities. The visibility of the PWMs of the other phases made me believe it would not work.

When I remarked this, I plugged off the load and it worked. Somtimes it happens such a stupid failure.

Thanks for your help.

Reinhard

Thanks for coming back with the solution.​ It's sometimes not that easy to spot this kind of mistake.

JW​