You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by "maxikrie (via GitHub)" <gi...@apache.org> on 2024/02/09 01:08:09 UTC
[I] STM32H7/pwm: multi-channel issue [nuttx]
maxikrie opened a new issue, #11677:
URL: https://github.com/apache/nuttx/issues/11677
I encountered an issue for the case where multiple channels are supposed to output a PWM signal. For the case where the first channel doesn't start with number 1, there is no output.
The issue is the following code in stm32_pwm.c:3317-3338:
```
/* A value of zero means to skip this channel */
if (channel != 0)
{
/* Find the channel */
for (j = 0; j < priv->chan_num; j++)
{
if (priv->channels[j].channel == channel)
{
break;
}
}
/* Check range */
if (j >= priv->chan_num)
{
pwmerr("ERROR: No such channel: %u\n", channel);
ret = -EINVAL;
goto errout;
}
```
For the case where e.g. only channel 3 and 4 (priv->chan_num is 2 in this case) are enabled, the 'check range' fails and the function returns. I suggest to remove this check since it solves the problem and I am not sure if it adds any value.
Please comment if you think this causes any other problems.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] STM32H7/pwm: multi-channel issue [nuttx]
Posted by "acassis (via GitHub)" <gi...@apache.org>.
acassis commented on issue #11677:
URL: https://github.com/apache/nuttx/issues/11677#issuecomment-1946347012
@maxikrie there is something strange, because "chan_num" is the number of channels enabled in each STM32_TIMx timer. So maybe you forgot to configure it correctly in the menuconfig (I'm supposing, not saying you missed to enable/disable CONFIG_STM32_TIMx_CHANNELx) or there is some error in the macro (I checked here and it seems fine).
@raiden00pl any idea why the "check range" is causing this error?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] STM32H7/pwm: multi-channel issue [nuttx]
Posted by "raiden00pl (via GitHub)" <gi...@apache.org>.
raiden00pl commented on issue #11677:
URL: https://github.com/apache/nuttx/issues/11677#issuecomment-1946549018
The channel checking logic looks good at first glance. We cannot remove it because it checks input from the user. Maybe something wrong with the configuration or `PWM_TIMx_NCHANNELS` macros in `stm32_pwm.h` ? I don't have any stm32 on the bench right now to check it quickly, maybe during the weekend
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] STM32H7/pwm: multi-channel issue [nuttx]
Posted by "maxikrie (via GitHub)" <gi...@apache.org>.
maxikrie closed issue #11677: STM32H7/pwm: multi-channel issue
URL: https://github.com/apache/nuttx/issues/11677
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] STM32H7/pwm: multi-channel issue [nuttx]
Posted by "maxikrie (via GitHub)" <gi...@apache.org>.
maxikrie commented on issue #11677:
URL: https://github.com/apache/nuttx/issues/11677#issuecomment-1962176291
@raiden00pl Thanks for looking into this!
My bad, there was a naming confusion on my side. I didn't realize that channel description in `pwm_info_s info` always needs to start from `info.channels[0]`. I originally had timer channels 1-4 enabled and when I later disabled channel 1 and 2. I set
```
info.channels[0].channel=0
info.channels[1].channel=0
info.channels[2].channel=3
info.channels[3].channel=4
```
However, in this case the check described above would fail, which is correct, and I mistake on my side.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org