You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@nuttx.apache.org by di...@gmail.com on 2021/04/03 14:33:39 UTC

PWM advanced and normal timers (STM32)

Hi,

I was implementing the following use-case:
On TIM1 (advanced) timer I want to use pulse counts (By configuring and enabling: "CONFIG_PWM_PULSECOUNT") And for TIM4 I do NOT want to use this. Just normal time-based.

But when I use examples/pwm_main.c this is giving me very strange responses. Also the drivers/timers/pwm.c seems to do something different then what I expect?

Did some of you had this situation? And I do not mean "MULTICHANNEL" usage. Thats something different and another use case.

Thanks
Ben


Re: PWM advanced and normal timers (STM32)

Posted by raiden00pl <ra...@gmail.com>.
Could you try this PR and look if it solves a problem
https://github.com/apache/incubator-nuttx/pull/3660 ?

wt., 6 kwi 2021 o 08:27 <di...@gmail.com> napisał(a):

> Thank you. Then my observation was a good one. This is not like the
> datasheet was telling how the driver "should" work. I was trying to solve
> this, but its deep in the core system where this CONFIG_PWM_PULSECOUNT has
> effect. If I only had more time....
>
> Ben
>
> -----Oorspronkelijk bericht-----
> Van: raiden00pl <ra...@gmail.com>
> Verzonden: dinsdag 6 april 2021 08:10
> Aan: dev@nuttx.apache.org
> Onderwerp: Re: PWM advanced and normal timers (STM32)
>
> As far as I can remember, it never worked that way. If you enable
> PULSECOUNT, you can only use timers that support this feature.
> Other PWM instances will not work properly.
>
> sob., 3 kwi 2021 o 17:19 <di...@gmail.com> napisał(a):
>
> > So /dev/pmw0 = TIM1
> > /dev/pmw1 = TIM4
> >
> > All well...... but with CONFIG_PWM_PULSECOUNT only TIM1 is working
> > when you give in counts.... but with counts=0 nothing happens ....
> > TIM4 is quitting immediatly..... with CONFIG_PWM_PULSECOUNT DISABLED I
> > can use both in a generic way.......
> >
> > I think the:
> > #ifdef CONFIG_PWM_PULSECOUNT
> >               ret = lower->ops->pulse_start(lower, &upper->info,
> > upper); #else
> >               ret = lower->ops->start(lower, &upper->info); #endif
> >
> > Is too generic.... in drivers/timers/pwm.c????
> >
> > Ben
> >
> > -----Oorspronkelijk bericht-----
> > Van: disruptivesolutionsnl@gmail.com <di...@gmail.com>
> > Verzonden: zaterdag 3 april 2021 16:34
> > Aan: dev@nuttx.apache.org
> > Onderwerp: PWM advanced and normal timers (STM32)
> >
> > Hi,
> >
> > I was implementing the following use-case:
> > On TIM1 (advanced) timer I want to use pulse counts (By configuring
> > and
> > enabling: "CONFIG_PWM_PULSECOUNT") And for TIM4 I do NOT want to use
> this.
> > Just normal time-based.
> >
> > But when I use examples/pwm_main.c this is giving me very strange
> > responses. Also the drivers/timers/pwm.c seems to do something
> > different then what I expect?
> >
> > Did some of you had this situation? And I do not mean "MULTICHANNEL"
> > usage. Thats something different and another use case.
> >
> > Thanks
> > Ben
> >
> >
> >
>
>

RE: PWM advanced and normal timers (STM32)

Posted by di...@gmail.com.
Thank you. Then my observation was a good one. This is not like the datasheet was telling how the driver "should" work. I was trying to solve this, but its deep in the core system where this CONFIG_PWM_PULSECOUNT has effect. If I only had more time....

Ben

-----Oorspronkelijk bericht-----
Van: raiden00pl <ra...@gmail.com> 
Verzonden: dinsdag 6 april 2021 08:10
Aan: dev@nuttx.apache.org
Onderwerp: Re: PWM advanced and normal timers (STM32)

As far as I can remember, it never worked that way. If you enable PULSECOUNT, you can only use timers that support this feature.
Other PWM instances will not work properly.

sob., 3 kwi 2021 o 17:19 <di...@gmail.com> napisał(a):

> So /dev/pmw0 = TIM1
> /dev/pmw1 = TIM4
>
> All well...... but with CONFIG_PWM_PULSECOUNT only TIM1 is working 
> when you give in counts.... but with counts=0 nothing happens ....
> TIM4 is quitting immediatly..... with CONFIG_PWM_PULSECOUNT DISABLED I 
> can use both in a generic way.......
>
> I think the:
> #ifdef CONFIG_PWM_PULSECOUNT
>               ret = lower->ops->pulse_start(lower, &upper->info, 
> upper); #else
>               ret = lower->ops->start(lower, &upper->info); #endif
>
> Is too generic.... in drivers/timers/pwm.c????
>
> Ben
>
> -----Oorspronkelijk bericht-----
> Van: disruptivesolutionsnl@gmail.com <di...@gmail.com>
> Verzonden: zaterdag 3 april 2021 16:34
> Aan: dev@nuttx.apache.org
> Onderwerp: PWM advanced and normal timers (STM32)
>
> Hi,
>
> I was implementing the following use-case:
> On TIM1 (advanced) timer I want to use pulse counts (By configuring 
> and
> enabling: "CONFIG_PWM_PULSECOUNT") And for TIM4 I do NOT want to use this.
> Just normal time-based.
>
> But when I use examples/pwm_main.c this is giving me very strange 
> responses. Also the drivers/timers/pwm.c seems to do something 
> different then what I expect?
>
> Did some of you had this situation? And I do not mean "MULTICHANNEL"
> usage. Thats something different and another use case.
>
> Thanks
> Ben
>
>
>


Re: PWM advanced and normal timers (STM32)

Posted by raiden00pl <ra...@gmail.com>.
As far as I can remember, it never worked that way. If you enable
PULSECOUNT, you can only use timers that support this feature.
Other PWM instances will not work properly.

sob., 3 kwi 2021 o 17:19 <di...@gmail.com> napisał(a):

> So /dev/pmw0 = TIM1
> /dev/pmw1 = TIM4
>
> All well...... but with CONFIG_PWM_PULSECOUNT only TIM1 is working when
> you give in counts.... but with counts=0 nothing happens ....
> TIM4 is quitting immediatly..... with CONFIG_PWM_PULSECOUNT DISABLED I can
> use both in a generic way.......
>
> I think the:
> #ifdef CONFIG_PWM_PULSECOUNT
>               ret = lower->ops->pulse_start(lower, &upper->info, upper);
> #else
>               ret = lower->ops->start(lower, &upper->info);
> #endif
>
> Is too generic.... in drivers/timers/pwm.c????
>
> Ben
>
> -----Oorspronkelijk bericht-----
> Van: disruptivesolutionsnl@gmail.com <di...@gmail.com>
> Verzonden: zaterdag 3 april 2021 16:34
> Aan: dev@nuttx.apache.org
> Onderwerp: PWM advanced and normal timers (STM32)
>
> Hi,
>
> I was implementing the following use-case:
> On TIM1 (advanced) timer I want to use pulse counts (By configuring and
> enabling: "CONFIG_PWM_PULSECOUNT") And for TIM4 I do NOT want to use this.
> Just normal time-based.
>
> But when I use examples/pwm_main.c this is giving me very strange
> responses. Also the drivers/timers/pwm.c seems to do something different
> then what I expect?
>
> Did some of you had this situation? And I do not mean "MULTICHANNEL"
> usage. Thats something different and another use case.
>
> Thanks
> Ben
>
>
>

RE: PWM advanced and normal timers (STM32)

Posted by di...@gmail.com.
So /dev/pmw0 = TIM1
/dev/pmw1 = TIM4

All well...... but with CONFIG_PWM_PULSECOUNT only TIM1 is working when you give in counts.... but with counts=0 nothing happens ....
TIM4 is quitting immediatly..... with CONFIG_PWM_PULSECOUNT DISABLED I can use both in a generic way.......

I think the: 
#ifdef CONFIG_PWM_PULSECOUNT
              ret = lower->ops->pulse_start(lower, &upper->info, upper);
#else
              ret = lower->ops->start(lower, &upper->info);
#endif

Is too generic.... in drivers/timers/pwm.c????

Ben

-----Oorspronkelijk bericht-----
Van: disruptivesolutionsnl@gmail.com <di...@gmail.com> 
Verzonden: zaterdag 3 april 2021 16:34
Aan: dev@nuttx.apache.org
Onderwerp: PWM advanced and normal timers (STM32)

Hi,

I was implementing the following use-case:
On TIM1 (advanced) timer I want to use pulse counts (By configuring and enabling: "CONFIG_PWM_PULSECOUNT") And for TIM4 I do NOT want to use this. Just normal time-based.

But when I use examples/pwm_main.c this is giving me very strange responses. Also the drivers/timers/pwm.c seems to do something different then what I expect?

Did some of you had this situation? And I do not mean "MULTICHANNEL" usage. Thats something different and another use case.

Thanks
Ben