Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

PWM_FullConfiguration.ino with open drain output? #56

Answered by fpistm
ericwoud asked this question in Q&A
Discussion options

I want to start on a new project. I would like to use the hardware timer to send a signal, so I think PWM_FullConfiguration.ino will be a good starting point.

However I would like it to be an open drain output.

The example states: No need to configure pin, it will be done by HardwareTimer configuration

So will it work if I would add this to the code?

 gpio_set_mode(digitalPinToPort(pin), PIN_MAP[pin].gpio_bit, GPIO_OUTPUT_OD); // set open drain output

If so, where to add it?

You must be logged in to vote

Replies: 1 comment · 7 replies

Comment options

Hi @ericwoud
it seems you used this core: https://github.com/rogerclarkmelbourne/Arduino_STM32
https://github.com/rogerclarkmelbourne/Arduino_STM32/blob/341cd894516f747f14108de5da593dad99900ae0/STM32F1/cores/maple/libmaple/gpio_f1.c#L124

Not the one linked to STM32Examples:
https://github.com/stm32duino/Arduino_Core_STM32
which do not have gpio_set_mode

So you should ask on the forum in the dedicated libmaple core section:
https://www.stm32duino.com/viewforum.php?f=63

You must be logged in to vote
7 replies
@ABOSTM
Comment options

Yes, overwriting the weak PinMap_TIM sounds good to me for both Open drain and PullUp.
By the way, I am curious to know why you need Open Drain configuration ?

@ericwoud
Comment options

I was thinking of transforming one existing HDMI-CEC library to use a hardware timer and interrupts.

Because I want to minimize the hardware, I am going to use a stm32(f4), because it has open drain outputs, where many other boards do not. I can connect the CEC pin directly to a pin, switching it between input without pullup and open collector output.

I have ordered 2 stm32f401's so I hope I can start soon.

@ericwoud
Comment options

I have ordered the STM32F401CCU6, meaning I would need:
https://github.com/stm32duino/Arduino_Core_STM32/blob/main/variants/STM32F4xx/F401CC(F-U-Y)_F401C(B-D-E)(U-Y)/PeripheralPins.c

Let's say I want pin PA_2 on timer 5, I see:

 {PA_2_ALT1, TIM5,  STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 3, 0)}, // TIM5_CH3

I would need to change it to:

 {PA_2_ALT1, TIM5,  STM_PIN_DATA_EXT(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF2_TIM5, 3, 0)}, // TIM5_CH3

Should this be good enough to make sure I never activate the input pullup, or even worse, force the output to high voltage?

@ABOSTM
Comment options

Yes that sound good.

Did you know that some STM32 MCU support Hardware HDMI-CEC ?
Even within F4 series, like STM32F446RET
https://www.st.com/en/microcontrollers-microprocessors/stm32f446.html
(but not supported on stm32f401)

@ericwoud
Comment options

I know, also some STM32F0xx, but it is not as cheap and available as the STM32F401.

Answer selected by ericwoud
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
🙏
Q&A
Labels
None yet
3 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.