Topics

Runtime pin remapping on STM32F103


Thomas Hobson <thomas@...>
 

Hi,

I'm looking for how I would switch a physical pin between ADC, PWM and GPIO, all without the chip being reprogrammed.

I have found pinmux, but I can't tell exactly what it does as documentation is lacking.


Thanks a bunch,
Thomas



Carles Cufi
 

Hi Thomas,

 

This is currently not possible, but under active discussion:

https://github.com/zephyrproject-rtos/zephyr/issues/11918

 

Carles

 

From: devel@... <devel@...> On Behalf Of Thomas Hobson via lists.zephyrproject.org
Sent: 23 October 2020 12:16
To: devel@...
Subject: [Zephyr-devel] Runtime pin remapping on STM32F103

 

Hi,

I'm looking for how I would switch a physical pin between ADC, PWM and GPIO, all without the chip being reprogrammed.

I have found pinmux, but I can't tell exactly what it does as documentation is lacking.

 

Thanks a bunch,
Thomas

 


Erwan Gouriou
 

Hi Thomas,

Would you mind giving us some details on your use case ?
Do you expect to be able to change only the affectation of the pin and apply preconfigured settings ?
For instance PIN X is:
ALT FUNC 5, pull up, open drain for PWM
Analog for ADC
Input  when GPIO
And then you switch between those config in the application?

Or do you expect to be able to be able to program the pin at run time to any kind of function ?




On Fri, 23 Oct 2020 at 15:07, Carles Cufi <carles.cufi@...> wrote:

Hi Thomas,

 

This is currently not possible, but under active discussion:

https://github.com/zephyrproject-rtos/zephyr/issues/11918

 

Carles

 

From: devel@... <devel@...> On Behalf Of Thomas Hobson via lists.zephyrproject.org
Sent: 23 October 2020 12:16
To: devel@...
Subject: [Zephyr-devel] Runtime pin remapping on STM32F103

 

Hi,

I'm looking for how I would switch a physical pin between ADC, PWM and GPIO, all without the chip being reprogrammed.

I have found pinmux, but I can't tell exactly what it does as documentation is lacking.

 

Thanks a bunch,
Thomas

 


Thomas Hobson <thomas@...>
 

Hi,

The use case is for this is could be considered as a intelligent GPIO expander for a much larger project, which offloads peripheral tasks to this chip, but so far GPIO/PWM/ADC has been the most problematic

We would have a pin, say A1 which could be mapped to GPIO or PWM by someone unplugging say a button, and plugging in a servo, running a few commands on the chip and it should be ready to control the servo.

Only 5 of the pins need ADC connection, and there are only 8 different combinations of pin "types" I should need to support, with the majority being GPIO input with various different pull up/down and callback configurations.

My problem only arises when I want to switch the pin between, as stated before, a button and a servo where I need to switch between GPIO and PWM.

There are a total of 10 pins I should be controlling, A1-A5 - GPIO/PWM and B1-B5 - GPIO/PWM/ADC.


Hopefully that sums up my use case.

Thanks,
Thomas

On 10/24/20 3:18 AM, Erwan Gouriou wrote:
Hi Thomas,

Would you mind giving us some details on your use case ?
Do you expect to be able to change only the affectation of the pin and apply preconfigured settings ?
For instance PIN X is:
ALT FUNC 5, pull up, open drain for PWM
Analog for ADC
Input  when GPIO
And then you switch between those config in the application?

Or do you expect to be able to be able to program the pin at run time to any kind of function ?




On Fri, 23 Oct 2020 at 15:07, Carles Cufi <carles.cufi@...> wrote:

Hi Thomas,

 

This is currently not possible, but under active discussion:

https://github.com/zephyrproject-rtos/zephyr/issues/11918

 

Carles

 

From: devel@... <devel@...> On Behalf Of Thomas Hobson via lists.zephyrproject.org
Sent: 23 October 2020 12:16
To: devel@...
Subject: [Zephyr-devel] Runtime pin remapping on STM32F103

 

Hi,

I'm looking for how I would switch a physical pin between ADC, PWM and GPIO, all without the chip being reprogrammed.

I have found pinmux, but I can't tell exactly what it does as documentation is lacking.

 

Thanks a bunch,
Thomas