Discussion:
STM32 PWM
g***@public.gmane.org
2014-03-25 12:49:49 UTC
Permalink
I'd like to know if there is any particular reason that only one channel at a time can be configured with the existing driver?
s***@public.gmane.org
2014-03-25 23:48:59 UTC
Permalink
Hi,
Post by g***@public.gmane.org
I'd like to know if there is any particular reason that only one channel at a time can be configured with the existing driver?
I am not sure how to answer the question... I don't think I even understand the question. What is the your concern with PWM channels? What exactly is the behavior that you are talking about? And what would the alternative behavior be?

Greg
Michael Smith
2014-03-26 02:29:38 UTC
Permalink
Post by g***@public.gmane.org
I'd like to know if there is any particular reason that only one channel at a time can be configured with the existing driver?
Without knowing for certain, I’d say it’s likely that Greg built a single-channel PWM setup as an example, but since nobody was looking for anything more complex he didn’t waste time building out what would be a very complex driver without a customer / test case.

Writing properly generic device drivers for something as complex as the STM32 timer blocks is a very painful and time-consuming exercise. In most cases, as a user of the system it’s better to build a specific driver to suit your application, rather than trying to debug a super-generic architecture that’s never been properly tested.

(source: I might have written some STM32 multichannel PWM drivers that are in wide use…)
g***@public.gmane.org
2014-03-26 11:42:05 UTC
Permalink
g***@public.gmane.org
2014-03-26 11:50:35 UTC
Permalink
I am not sure how to answer the question... I don't think I even understand the question. What is the your concern with PWM channels? What exactly is the behavior that you are talking about? And what would the alternative behavior be?
There is a comment in arch/arm/src/stm32/stm32_pwm.h:125-128:
* NOTE: The STM32 timers are each capable of generating different signals on * each of the four channels with different duty cycles. That capability is * not supported by this driver: Only one output channel per timer. */
Without knowing for certain, I’d say it’s likely that Greg built a single-channel PWM setup as an example, but since nobody was looking for anything more complex he didn’t waste time building out what would be a very complex driver without a customer / test case.
Writing properly generic device drivers for something as complex as the STM32 timer blocks is a very painful and time-consuming exercise. In most cases, as a user of the system it’s better to build a specific driver to suit your application, rather than trying to debug a super-generic architecture that’s never been properly tested.


(source: I might have written some STM32 multichannel PWM drivers that are in wide use
)


Thanks, Michael. I think I'll just write an app-specific driver.
adias.isep-/E1597aS9LQAvxtiuMwx3w@public.gmane.org [nuttx]
2014-05-23 09:04:34 UTC
Permalink
Hi everyone,

I'm working with STM32Discovery Board and I'd like to have access to more GPIO pins working as PWM channels. I have test the NuttX example for PWM and at this moment the pin PD13 is working correctly. It's possible to help me how to include more channels as PWM in the same procedure of /dev/pwm....


Thanks
André Dias
spudarnia-/E1597aS9LQAvxtiuMwx3w@public.gmane.org [nuttx]
2014-05-23 14:57:16 UTC
Permalink
Hi, André,
Post by adias.isep-/***@public.gmane.org [nuttx]
I'm working with STM32Discovery Board and I'd like to have access to more GPIO pins working as PWM channels. I have test the NuttX example for PWM and at this moment the pin PD13 is working correctly. It's possible to help me how to include more channels as PWM in the same procedure of /dev/pwm....
From your other email, I see that you are using apps/examples/pwm to open /dev/pwmN and it fails with errno == 2 meaning that /dev/pwmN. Did you do

nsh> ls /dev

to see if the PWM driver exists? If it does not exist, then certainly you cannot open it.

In order to create another PWM driver instance, you need to extend the logic in configs/stm32f4discovery/src/stm32_pwm.c. The steps to create an PWM driver instance are:

1. Call this function with the timer that you want to use:

struct pwm_lowerhalf_s *stm32_pwminitialize(int timer)

2. Call this function to create the timer driver instance:

int pwm_register(FAR const char *path, FAR struct pwm_lowerhalf_s *dev);

where:

- dev is the value returned by stm32_pwminitialize() and path is the full path to where the driver will reside, like:

pwm = stm32_pwminitialize(3);
ret = pwm_register("/dev/pwmN", pwm);

Greg
spudarnia-/E1597aS9LQAvxtiuMwx3w@public.gmane.org [nuttx]
2014-05-23 14:59:01 UTC
Permalink
And if that doesn't work, you should enable PWM debug output to see what is going on:

CONFIG_DEBUG=y
CONFIG_DEBUG_VERBOSE=y
CONFIG_DEBUG_PWM=y


---In ***@yahoogroups.com, <***@yahoo.com> wrote :


Hi, André,
Post by adias.isep-/***@public.gmane.org [nuttx]
I'm working with STM32Discovery Board and I'd like to have access to more GPIO pins working as PWM channels. I have test the NuttX example for PWM and at this moment the pin PD13 is working correctly. It's possible to help me how to include more channels as PWM in the same procedure of /dev/pwm....
From your other email, I see that you are using apps/examples/pwm to open /dev/pwmN and it fails with errno == 2 meaning that /dev/pwmN. Did you do

nsh> ls /dev

to see if the PWM driver exists? If it does not exist, then certainly you cannot open it.

In order to create another PWM driver instance, you need to extend the logic in configs/stm32f4discovery/src/stm32_pwm.c. The steps to create an PWM driver instance are:

1. Call this function with the timer that you want to use:

struct pwm_lowerhalf_s *stm32_pwminitialize(int timer)

2. Call this function to create the timer driver instance:

int pwm_register(FAR const char *path, FAR struct pwm_lowerhalf_s *dev);

where:

- dev is the value returned by stm32_pwminitialize() and path is the full path to where the driver will reside, like:

pwm = stm32_pwminitialize(3);
ret = pwm_register("/dev/pwmN", pwm);

Greg
adias.isep-/E1597aS9LQAvxtiuMwx3w@public.gmane.org [nuttx]
2014-05-23 16:53:31 UTC
Permalink
Thanks spudarnia for the support

As soon I finish the implementation I will return to share the result.


Thanks Again, Best regards
André

Loading...