Is OUTPUT_OPEN_DRAIN supported

STM32F103 Nucleo boards e.g. STM Nucleo F103RB
Boian Mitov
Posts: 14
Joined: Sun Jul 09, 2017 9:03 pm

Is OUTPUT_OPEN_DRAIN supported

Post by Boian Mitov » Mon Jul 10, 2017 6:48 pm

Hi everyone,

I switched to using stm32duino from the :
http://docs.leaflabs.com/static.leaflab ... gitalwrite

In the Leaf library, there is OUTPUT_OPEN_DRAIN pin mode, and I added it in Visuino https://www.visuino.com as tart of the upcoming STM32 support (Hopefully in the future supporting all STM32 boards :-) ).

I can't find the OUTPUT_OPEN_DRAIN mode in the stm32duino . What is the alternative?

Cheers,
Boian

PS: I am sorry, I posted it in the Nucleo instead of the Maple :-( . If somebody can move it I would really appreciate it!

stevestrong
Posts: 1501
Joined: Mon Oct 19, 2015 12:06 am
Location: Munich, Germany

Re: Is OUTPUT_OPEN_DRAIN supported

Post by stevestrong » Mon Jul 10, 2017 7:45 pm

Use "OUTPUT_OD".

Boian Mitov
Posts: 14
Joined: Sun Jul 09, 2017 9:03 pm

Re: Is OUTPUT_OPEN_DRAIN supported

Post by Boian Mitov » Mon Jul 10, 2017 11:12 pm

Does not work :-(
C:\Users\mitov\AppData\Local\Temp\arduino_modified_sketch_780612\Blink.ino: In function 'void setup()':

Blink:27: error: 'OUTPUT_OD' was not declared in this scope

pinMode(LED_BUILTIN, OUTPUT_OD);

^

exit status 1
'OUTPUT_OD' was not declared in this scope

Target "MapleMini F103CB"

Suggestions?

stevestrong
Posts: 1501
Joined: Mon Oct 19, 2015 12:06 am
Location: Munich, Germany

Re: Is OUTPUT_OPEN_DRAIN supported

Post by stevestrong » Tue Jul 11, 2017 8:43 am


Boian Mitov
Posts: 14
Joined: Sun Jul 09, 2017 9:03 pm

Re: Is OUTPUT_OPEN_DRAIN supported

Post by Boian Mitov » Tue Jul 11, 2017 11:10 pm

stevestrong wrote:
Tue Jul 11, 2017 8:43 am
Sorry, I was wrong, you should use:
OUTPUT_OPEN_DRAIN
see:
https://github.com/rogerclarkmelbourne/ ... e/io.h#L47

https://github.com/rogerclarkmelbourne/ ... f1.cpp#L51
I got the libraries with the board manager from:
https://github.com/stm32duino/BoardManagerFiles

like this:
https://github.com/stm32duino/BoardMana ... index.json

Is that the wrong library? It does not have the OUTPUT_OPEN_DRAIN defined :-(
Which one is the "official" library?

fredbox
Posts: 95
Joined: Tue Jul 07, 2015 4:44 pm

Re: Is OUTPUT_OPEN_DRAIN supported

Post by fredbox » Wed Jul 12, 2017 12:38 am

Code: Select all

const uint8_t led_pin = 33;
uint8_t led = 0;
void setup() {
  pinMode(led_pin, OUTPUT_OPEN_DRAIN);
}
void loop() {
  digitalWrite(led_pin, led);
  led = 1 - led;
  delay(500);
}

Code: Select all

Sketch uses 12292 bytes (11%) of program storage space. Maximum is 110592 bytes.
Global variables use 2560 bytes of dynamic memory.
With the pin set to OUTPUT_OPEN_DRAIN drain instead of OUTPUT, the led no longer blinks as it is connected to ground. My installation is using the boards manager.

fpiSTM
Posts: 167
Joined: Fri Sep 16, 2016 12:33 pm
Location: Le Mans, France

Re: Is OUTPUT_OPEN_DRAIN supported

Post by fpiSTM » Wed Jul 12, 2017 7:45 am

Hi,

it seems there is a misunderstanding around the STM32 core used.
With this one:
https://github.com/stm32duino/Arduino_Core_STM32
Installed thanks https://github.com/stm32duino/BoardManagerFiles
OUTPUT_OPEN_DRAIN is not defined so your sketch should not compile.
On this core only the OUTPUT is defined: and set the GPIO with GPIO_MODE_OUTPUT_PP (Output Push Pull Mode) and GPIO_NOPULL (No Pull-up or Pull-down activation).
It follow Arduino reference for pinMode: https://www.arduino.cc/en/Reference/PinMode
Probably, we could extend and propose other mode, ex: GPIO_MODE_OUTPUT_OD.

I think you use the core provided by Roger:
https://github.com/rogerclarkmelbourne/Arduino_STM32

Boian Mitov
Posts: 14
Joined: Sun Jul 09, 2017 9:03 pm

Re: Is OUTPUT_OPEN_DRAIN supported

Post by Boian Mitov » Wed Jul 12, 2017 5:09 pm

const uint8_t led_pin = 33;
uint8_t led = 0;
void setup() {
pinMode(led_pin, OUTPUT_OPEN_DRAIN);
}
...
Does not work with the libraries installed from the board manager.
I followed this instructions to install from the board manager:
https://github.com/stm32duino/wiki/wiki/Boards-Manager

You can see the error when compiling.
I can also manually get the repository, but I would prefer to use the board manager, as the Visuino customers will have to follow the same procedure.
One of the users already is planning Visuino Wiki tutorial on setting up the Arduino IDE to compile for the STB32Duino boards.
Will be added in the Visuino Wiki:
https://www.visuino.com/wiki/index.php?title=Main_Page
Attachments
STM32Error.png
STM32Error.png (24.65 KiB) Viewed 108 times
STM32BoardManager.png
STM32BoardManager.png (15.64 KiB) Viewed 108 times

User avatar
Rick Kimball
Posts: 988
Joined: Tue Apr 28, 2015 1:26 am
Location: Eastern NC, US
Contact:

Re: Is OUTPUT_OPEN_DRAIN supported

Post by Rick Kimball » Wed Jul 12, 2017 5:51 pm

@Boian Mitov OUTPUT_OPEN_DRAIN isn't supported by the STM32 Core from ST https://github.com/stm32duino/Arduino_Core_STM32

To solve this problem:

o You could add the feature to the code yourself.
o You could ask for an enhancement by creating an issue on github
o You could use the libmaple core. https://github.com/rogerclarkmelbourne/Arduino_STM32
o You could use another core that supports it http://www.stm32duino.com/viewtopic.php?f=42&t=97
-rick

Boian Mitov
Posts: 14
Joined: Sun Jul 09, 2017 9:03 pm

Re: Is OUTPUT_OPEN_DRAIN supported

Post by Boian Mitov » Wed Jul 12, 2017 7:56 pm

Rick Kimball wrote:
Wed Jul 12, 2017 5:51 pm
o You could add the feature to the code yourself.
If I add it it will be included in the official release?
I am asking as I have about 23000 users of Visuino, according to the registration, and they all will need to have access to it.
I am asking how to solve the problem for all users.
This functionality is probably important, and should be included in the official library IMHO ;-)

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests