1 year, 3 months ago.

Difference between Morpho and Arduino library?

Hi everyone

I found that if I use the original library from others programs, the pin assignment always based on the Arduino. Because if I choose the Morpho pin, the pin will always be undefined after the compiled. So if I demand to use Morpho , I have to modify the library ,right?

My platform:L152RE

Comment on this question

1 Answer

1 year, 3 months ago.

Hello William,

Arduino pin names are actually alias names of selected Morpho pin names. For the NUCLEO-L152RE board this is defined in the PinNames.h file in section Arduino connector namings (line #102 through #123):

Both pin names, Morpho and Arduino, refer to the same MCU pin which is physically connected to both connectors (Morpho and Arduino). It means that in your code you can use the corresponding Morpho pin name, instead of the Arduino one, even when your external component is connected to the Arduino connector. And vice versa, you can use the corresponding Arduino pin name even when the external component is connected to the Morpho connector.

The reason for using Arduino pin names, in contrast to Morpho ones, is that they do not depend on the type of used MBED board. They always guaranty that the same type of peripheral interface is available at the given pin names regardless of the type of used board.

But please notice that not all Morpho pins are available at the Arduino connector. So in case a component library was written in a way to use only specific pin names and you would like to use others then it could happen that you have to modify the given library.

However, this is not a rule. Some libraries are more generic. They do not rely on pin names but rather on the type of used peripheral. For example, they let you create a peripheral interface (I2C, SPI, CAN, ...) at any pins supported by the given MBED board (indicated on the board specification page in sections Arduino-compatible headers and Morpho headers) and then this peripheral interface is used in the library instead of specific (Arduino) pin names.

Hi Zoltan

It is really an impressive thought that clarify my confusion.

Have a good day and many thanks!! :)

posted by william wu 31 Oct 2017

To post an answer, please log in.