You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2024/04/07 19:02:48 UTC

(nuttx) branch master updated: arch/arm64/src/imx9/imx9_flexio_pwm.c: Fix wrong input scale and pulse width

This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git


The following commit(s) were added to refs/heads/master by this push:
     new 5e5640992d arch/arm64/src/imx9/imx9_flexio_pwm.c: Fix wrong input scale and pulse width
5e5640992d is described below

commit 5e5640992d0698046e15573901bd2a1e8ce4f44a
Author: Jukka Laitinen <ju...@ssrc.tii.ae>
AuthorDate: Fri Apr 5 13:20:20 2024 +0300

    arch/arm64/src/imx9/imx9_flexio_pwm.c: Fix wrong input scale and pulse width
    
    Signed-off-by: Jukka Laitinen <ju...@ssrc.tii.ae>
---
 arch/arm64/src/imx9/imx9_flexio_pwm.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/arch/arm64/src/imx9/imx9_flexio_pwm.c b/arch/arm64/src/imx9/imx9_flexio_pwm.c
index f213c1e5ac..1e93a1ffdc 100644
--- a/arch/arm64/src/imx9/imx9_flexio_pwm.c
+++ b/arch/arm64/src/imx9/imx9_flexio_pwm.c
@@ -444,8 +444,7 @@ static int pwm_update_frequency(struct imx9_pwmtimer_s *priv, int freq)
 static int pwm_update_duty(struct imx9_pwmtimer_s *priv, int pwm_ch,
                            ub16_t duty16)
 {
-  uint64_t duty = ub16toi(duty16);
-  uint32_t edge = (duty * priv->period + 0x8000) >> 16;
+  uint32_t edge = ub16toi(duty16 * priv->period + b16HALF);
   int timer = pwm_ch - 1; /* map pwm ch 1 to timer 0 etc.. */
   uint32_t regval;
 
@@ -477,7 +476,7 @@ static int pwm_update_duty(struct imx9_pwmtimer_s *priv, int pwm_ch,
    * timer fully, otherwise just update the duty cycle
    */
 
-  flexio_putreg(priv, IMX9_FLEXIO_TIMCMP_OFFSET(timer), duty);
+  flexio_putreg(priv, IMX9_FLEXIO_TIMCMP_OFFSET(timer), edge);
 
   if (priv->frequency == 0)
     {