Hello team,

Me and Michal are having a discussion in comments to
https://github.com/apache/incubator-nuttx/pull/6298

The point of discussion is a PWM multi-channel mode. For PWM multi-channel
mode we are having CONFIG_PWM_NCHANNELS that is a "Number of Output
Channels Per Timer" and "struct pwm_info_s" is equipped with
CONFIG_PWM_NCHANNELS number of
struct pwm_chan_s
{
  ub16_t duty;
  int8_t channel;
};

But unfortunately we both fail to find a description of "struct pwm_chan_s"
channel values. The usage in code is not the same for different
implementations.

Per my understanding the "struct pwm_info_s" is an interface structure
between application and the driver, so the application should not have any
idea about the HW specifics of implementation (HW channels that are used)
and is carrying the "virtual" PWM channels from 1 to 16.
On the other hand, the PWM driver should map those "virtual" channels to HW
channels. For example CONFIG_PWM_NCHANNELS is 2 and the board has pins of
HW channels 5 and 6 routed to the connector. So there are 2 HW channels
that are 5 and 6 and an application update of 1 and 2 virtual channels will
lead to an update of HW channels 5 and 6.

Is my understanding correct? Maybe somebody can point me to the description
of PWM multi-channel mode?

Best regards,
Petro


чт, 19 трав. 2022 р. о 01:56 Petro Karashchenko <
petro.karashche...@gmail.com> пише:

> Hello Michal,
>
> Please participate in the review of
> https://github.com/apache/incubator-nuttx/pull/6298
> I would appreciate it if you can try if changes work for you.
>
> Looking forward receiving feedback from you.
>
> Best regards,
> Petro
>
> ср, 18 трав. 2022 р. о 16:33 Petro Karashchenko <
> petro.karashche...@gmail.com> пише:
>
>> Hi,
>>
>> I was able to resolve the issue. Will push patch soon.
>>
>> Best regards,
>> Petro
>>
>> ср, 18 трав. 2022 р. о 16:24 Michal Lenc <michall...@seznam.cz> пише:
>>
>>> Hello
>>>
>>>
>>> > CONFIG_EXAMPLES_PWM=y
>>>
>>> > CONFIG_PWM=y
>>>
>>> > CONFIG_SAMV7_PWM0=y
>>> > CONFIG_SAMV7_PWM0_CH2=y
>>>
>>>
>>>
>>>
>>> I used your configuration options and there indeed seems to be a
>>> problem. I
>>> also wasn´t able to get any PWM output if the driver was configured as a
>>> single channel with CONFIG_PWM_MULTICHAN disabled. The PWM works
>>> if CONFIG_
>>> PWM_MULTICHAN is selected and CONFIG_PWM_NCHANNELS is set as 2 or more.
>>> So
>>> far I am not sure what causes this, my initial debugging did not reveal
>>> any
>>> issues: correct functions are called, correct pin is configured, value
>>> is
>>> written to correct registers etc. Or at least it seems to be correct. I
>>> will
>>> need to take a further look into this during a weekend.
>>>
>>>
>>>
>>>
>>> So far a quick workaround is to enable multiple channel support and set
>>> two
>>> or more channels. The additional channel does not need to have an actual
>>> output, if you set the channel number to 0 it will be skipped. I will
>>> let
>>> you know when I discover what causes this. The driver is mostly a
>>> derivate
>>> from imxRT PWM driver and single PWM worked fine there if I recall
>>> correctly.
>>>
>>> Best regards,
>>> Michal Lenc" "
>>
>>

Reply via email to