Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[New Variant] STM32G0316-DISCO #858

Closed
DurandA opened this issue Jan 6, 2020 · 10 comments
Closed

[New Variant] STM32G0316-DISCO #858

DurandA opened this issue Jan 6, 2020 · 10 comments
Labels
new variant Add support of new bard

Comments

@DurandA
Copy link
Contributor

DurandA commented Jan 6, 2020

I'm interested in using STM32duino for the STM32G0316-DISCO which is based on a STM32G0 in SO8 package.

Board description:

Whilst I think I could add the variant myself according to the documentation, the STM32G031J6 has different pads connected to each pin:

A multi-bonding approach is used on the small packages in order to offer a maximum of alternate functions and analog inputs. This approach results in multiple die pads connected internally to a single package pin.

I am not sure if specific care should be taken or if it's better to let users use pins as if they were on different pins.

Also, how is pin remapping handled by STM32duino? Maybe @fpistm knows about STM32G0 specifics.

@DurandA DurandA added the new variant Add support of new bard label Jan 6, 2020
@DurandA
Copy link
Contributor Author

DurandA commented Jan 6, 2020

I just found out #722. I will close this issue if requested but it would be nice if I can get some advices related to pin multi-bonding and pin remapping.

@fpistm
Copy link
Member

fpistm commented Jan 7, 2020

Hi @DurandA
I was not aware about this.
Regarding the documentation:
image
It should works but this means that the number of digital pins will be higher then the numbers of physical pins. And it will be to end user to use properly each pins capabilities to avoid any shortcut.

@DurandA
Copy link
Contributor Author

DurandA commented Jan 7, 2020

Hi @fpistm and thanks for your comment.

What about pin remapping? PA12 can be remapped to PA10 and PA11 can be remapped to PA9 as in STM32G071RB from NUCLEO_G071RB. I did not found remapping functions in NUCLEO_G071RB variant. I think that it just won't work if users try to use PA10 (pin 2) or PA9 (pin 8).

@fpistm
Copy link
Member

fpistm commented Jan 7, 2020

I think you talk about AF (Alternate Function)
My understanding is that you can use PA12/PA10 to and PA9/PA11 only for one dedicated feature (peripheral). If you want use I2C on physical pin 6 and 5 of the package then you have to choose between PA12/PA11 or PA10/PA11. They are mutually exclusive:

https://github.com/stm32duino/Arduino_Tools/blob/31f3d43d620878dccbf658f65095f66fec9809b2/src/genpinmap/Arduino/STM32G031J(4-6)Mx/PeripheralPins.c#L46-L48

https://github.com/stm32duino/Arduino_Tools/blob/31f3d43d620878dccbf658f65095f66fec9809b2/src/genpinmap/Arduino/STM32G031J(4-6)Mx/PeripheralPins.c#L57-L58

So PA12/PA11 for I2C2 or PA10/PA11 for I2C1.

@DurandA
Copy link
Contributor Author

DurandA commented Jan 7, 2020

I think you talk about AF (Alternate Function)
My understanding is that you can use PA12/PA10 to and PA9/PA11 only for one dedicated feature (peripheral). If you want use I2C on physical pin 6 and 5 of the package then you have to choose between PA12/PA11 or PA10/PA11. They are mutually exclusive:

https://github.com/stm32duino/Arduino_Tools/blob/31f3d43d620878dccbf658f65095f66fec9809b2/src/genpinmap/Arduino/STM32G031J(4-6)Mx/PeripheralPins.c#L46-L48

https://github.com/stm32duino/Arduino_Tools/blob/31f3d43d620878dccbf658f65095f66fec9809b2/src/genpinmap/Arduino/STM32G031J(4-6)Mx/PeripheralPins.c#L57-L58

So PA12/PA11 for I2C2 or PA10/PA11 for I2C1.

image

I think Alternate Function refers to what function a specific pins perform (i.e. ADC1_EXTI11, ADC1_IN15, I2C2_SCL, ... for PA11) while pin remapping enable a physical pin to map to a different pin:

Pin pair PA9/PA10 can be remapped in place of pin pair PA11/PA12 (default mapping), using SYSCFG_CFGR1 register.

I examined a generated project from STM32CubeMX and if I remap PA12 to PA10, it adds the line HAL_SYSCFG_EnableRemap(SYSCFG_REMAP_PA12); to stm32g0xx_hal_msp.c.

@fpistm
Copy link
Member

fpistm commented Jan 7, 2020

Right, I've didn't see this.
So for this, it is currently not managed by Arduino API. Anyway, you can call the HAL directly.

@DurandA
Copy link
Contributor Author

DurandA commented Jan 7, 2020

Thanks. I think the port will be straightforward then.

@fpistm
Copy link
Member

fpistm commented Jan 7, 2020

I've open a issue to study that.

@DurandA
Copy link
Contributor Author

DurandA commented Jan 8, 2020

@fpistm I am in the process of adding this variant and have a few questions:

  • Would you recommend to configure the clock to 16 MHz from the high-speed internal RC oscillator (HSI16) or to feed HSI16 to the system PLL to the maximum output frequency of 64 MHz? What is your rule of thumb for other boards; maximum speed?
  • There is no serial connected to the built-in ST-Link, only JTCK and JTMS. Is SERIAL_PORT_MONITOR mandatory?
  • How do serials (e.g. Serial, Serial2 in other boards) in variant.h map to a particular UART interface of the STM32? Is it using the PinMap_UART_TX[]/PinMap_UART_RX[]? So Serial is [0] and Serial2 is [2] (or [1])?
  • I don't see any initialization of the serial interfaces in the other variants. Does the Arduino core expect the defined interfaces such as SERIAL_PORT_MONITOR to be readily available?

@DurandA DurandA reopened this Jan 8, 2020
@fpistm
Copy link
Member

fpistm commented Jan 8, 2020

  • Would you recommend to configure the clock to 16 MHz from the high-speed internal RC oscillator (HSI16) or to feed HSI16 to the system PLL to the maximum output frequency of 64 MHz? What is your rule of thumb for other boards; maximum speed?

In a general way, I try to set the maximum speed. But don't worry the clock config is a WEAK function so it can be redefined at sketch level if end user want another clock config.

  • There is no serial connected to the built-in ST-Link, only JTCK and JTMS. Is SERIAL_PORT_MONITOR mandatory?

This is only a define used on some example sketch or library. Define it to the generic Serial instance would be good.

  • How do serials (e.g. Serial, Serial2 in other boards) in variant.h map to a particular UART interface of the STM32? Is it using the PinMap_UART_TX[]/PinMap_UART_RX[]? So Serial is [0] and Serial2 is [2] (or [1])?

Serial is the generic Serial instance name and it is mapped on the defined Serialx instance where x is the U(S)ARTx peripheral number. Ex: Serial2 for USART2

To define automatically the Serial instance, it requires to define in the variant.h the U(S)ARTx peripheral number and the default pins Rx/Tx to use::

// UART Definitions
#define SERIAL_UART_INSTANCE    2

// Default pin used for 'Serial' instance
#define PIN_SERIAL_RX           PA3
#define PIN_SERIAL_TX           PA2

Ten it will be instantiate and when you do the Serial.begin then it check in the PinMap_UART_TX[]/PinMap_UART_RX[] the propre pins config for Rx and Tx.

  • I don't see any initialization of the serial interfaces in the other variants. Does the Arduino core expect the defined interfaces such as SERIAL_PORT_MONITOR to be readily available?

no, the core does not use SERIAL_PORT_MONITOR but for Arduino compatibility it is fine to define it as told in point 1.

fpistm added a commit to fpistm/Arduino_Core_STM32 that referenced this issue Feb 3, 2020
Fixes stm32duino#858

Signed-off-by: Arnaud Durand <arnaud.durand@unifr.ch>
Co-Authored-By: Frederic Pillon <frederic.pillon@st.com>
@fpistm fpistm closed this as completed in e7bb20b Feb 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new variant Add support of new bard
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants