<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>i.MX ProcessorsのトピックRe: user LED control on i.MX93 FRDM board</title>
    <link>https://community.nxp.com/t5/i-MX-Processors/user-LED-control-on-i-MX93-FRDM-board/m-p/2410725#M246597</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/171880"&gt;@ilya_chepurin&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;The RED LED is channel 2, please use below script to test(&lt;STRONG&gt;verified on L6.18.20&lt;/STRONG&gt;)&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;#!/bin/sh
# RGB LED PWM cycle test for i.MX93 EVK/FRDM.
# Sequence per cycle: RED on 1s -&amp;gt; all off 1s -&amp;gt; GREEN on 1s -&amp;gt; all off 1s -&amp;gt; BLUE on 1s -&amp;gt; all off 1s
# Usage: ./run.sh [LOOPS]        LOOPS: number of full cycles, 0 = infinite, default 3
# Timing overridable via env:    ON_TIME=2 REST_TIME=1 ./run.sh

PERIOD=1000000                 # 1 kHz period in ns
ON_TIME=${ON_TIME:-1}          # seconds a color stays ON
REST_TIME=${REST_TIME:-1}      # seconds all OFF between colors
LOOPS=${1:-3}
RETRIES=50

# Channel mapping and polarity (verified on this board, all ACTIVE-HIGH):
#   Red   -&amp;gt; 424f0000.pwm = pwmchip1 ch2  ON=duty PERIOD  OFF=duty 0
#   Green -&amp;gt; 424e0000.pwm = pwmchip0 ch0  ON=duty PERIOD  OFF=duty 0
#   Blue  -&amp;gt; 424e0000.pwm = pwmchip0 ch2  ON=duty PERIOD  OFF=duty 0
RED_CHIP=1;  RED_CH=2
GRN_CHIP=0;  GRN_CH=0
BLU_CHIP=0;  BLU_CH=2

# write_retry FILE VALUE : write VALUE to FILE, retry on transient TPM busy/-ETIME,
# and confirm the value took effect. Returns 0 on success.
write_retry() {
    t=0
    while [ "$t" -lt "$RETRIES" ]; do
        echo "$2" &amp;gt; "$1" 2&amp;gt;/dev/null
        [ "$(cat "$1" 2&amp;gt;/dev/null)" = "$2" ] &amp;amp;&amp;amp; return 0
        t=$((t+1))
    done
    echo "WARN: could not write $2 to $1" &amp;gt;&amp;amp;2
    return 1
}

# init_pwm CHIP CH : export (fresh), set period BEFORE duty, start disabled with duty 0.
# The i.MX TPM shares a counter between channels; a stale export with period=0 makes
# later period writes fail with -EBUSY, so we unexport first for a clean state.
init_pwm() {
    P="/sys/class/pwm/pwmchip${1}"
    [ -d "${P}/pwm${2}" ] &amp;amp;&amp;amp; echo "$2" &amp;gt; "${P}/unexport" 2&amp;gt;/dev/null
    echo "$2" &amp;gt; "${P}/export" 2&amp;gt;/dev/null
    write_retry "${P}/pwm${2}/period" "$PERIOD"      # period must be set before duty
    write_retry "${P}/pwm${2}/duty_cycle" 0          # start OFF
    echo 1 &amp;gt; "${P}/pwm${2}/enable" 2&amp;gt;/dev/null
}

set_duty() {   # CHIP CH DUTY
    write_retry "/sys/class/pwm/pwmchip${1}/pwm${2}/duty_cycle" "$3"
}

led() {        # CHIP CH STATE(on|off)  -- all channels active-high
    if [ "$3" = on ]; then set_duty "$1" "$2" "$PERIOD"; else set_duty "$1" "$2" 0; fi
}

all_off() {
    led $RED_CHIP $RED_CH off
    led $GRN_CHIP $GRN_CH off
    led $BLU_CHIP $BLU_CH off
}

# Init: green and blue share pwmchip0, so init green first, then blue.
init_pwm $RED_CHIP $RED_CH
init_pwm $GRN_CHIP $GRN_CH
init_pwm $BLU_CHIP $BLU_CH

trap "all_off; echo; echo interrupted, all LEDs off; exit 0" INT TERM

all_off
echo "start: all OFF"

n=0
while :; do
    c=$((n+1))
    echo "[cycle $c] RED   on";  led $RED_CHIP $RED_CH on;  sleep "$ON_TIME"
    echo "[cycle $c] --- off";   all_off;                  sleep "$REST_TIME"
    echo "[cycle $c] GREEN on";  led $GRN_CHIP $GRN_CH on;  sleep "$ON_TIME"
    echo "[cycle $c] --- off";   all_off;                  sleep "$REST_TIME"
    echo "[cycle $c] BLUE  on";  led $BLU_CHIP $BLU_CH on;  sleep "$ON_TIME"
    echo "[cycle $c] --- off";   all_off;                  sleep "$REST_TIME"

    n=$c
    [ "$LOOPS" -eq 0 ] &amp;amp;&amp;amp; continue
    [ "$n" -ge "$LOOPS" ] &amp;amp;&amp;amp; break
done

all_off
echo "done ($n cycle(s)), all LEDs off"
&lt;/LI-CODE&gt;
&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;Best Regards,&lt;BR /&gt;Zhiming&lt;/P&gt;</description>
    <pubDate>Thu, 03 Sep 2026 01:27:42 GMT</pubDate>
    <dc:creator>Zhiming_Liu</dc:creator>
    <dc:date>2026-09-03T01:27:42Z</dc:date>
    <item>
      <title>user LED control on i.MX93 FRDM board</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/user-LED-control-on-i-MX93-FRDM-board/m-p/2410646#M246592</link>
      <description>&lt;P&gt;Hi all,&lt;BR /&gt;I started to play with i.MX93 FRDM board and when I wrote a simple script to control RGB LEDs on the board, I've managed to control only Green and Blue LEDs. Red LED stays ON whatever I tried.&lt;BR /&gt;Based on the schematics, all leds are connected in a similar manner, so they operate Active High.&lt;BR /&gt;Here is my script:&lt;/P&gt;&lt;P&gt;---------------------------&lt;/P&gt;&lt;P&gt;#!/bin/sh&lt;/P&gt;&lt;P&gt;PERIOD=1000000&lt;/P&gt;&lt;P&gt;set_pwm() {&lt;BR /&gt;CHIP=$1&lt;BR /&gt;CHANNEL=$2&lt;BR /&gt;DUTY=$3&lt;BR /&gt;PWM_PATH="/sys/class/pwm/pwmchip${CHIP}/pwm${CHANNEL}"&lt;/P&gt;&lt;P&gt;if [ ! -d "$PWM_PATH" ]; then&lt;BR /&gt;echo "$CHANNEL" &amp;gt; "/sys/class/pwm/pwmchip${CHIP}/export" 2&amp;gt;/dev/null&lt;BR /&gt;fi&lt;/P&gt;&lt;P&gt;# Reset duty cycle to 0 first to satisfy TPM driver constraints&lt;BR /&gt;echo 0 &amp;gt; "${PWM_PATH}/duty_cycle" 2&amp;gt;/dev/null&lt;BR /&gt;echo "$PERIOD" &amp;gt; "${PWM_PATH}/period"&lt;BR /&gt;echo "$DUTY" &amp;gt; "${PWM_PATH}/duty_cycle"&lt;BR /&gt;echo 1 &amp;gt; "${PWM_PATH}/enable" 2&amp;gt;/dev/null&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;# Red is Active-Low: Default OFF = 1000000 (3.3V / High)&lt;BR /&gt;RED_DUTY=${1:-0}&lt;/P&gt;&lt;P&gt;# Green and Blue are Active-High: Default OFF = 0 (0V / Low)&lt;BR /&gt;GREEN_DUTY=${2:-0}&lt;BR /&gt;BLUE_DUTY=${3:-0}&lt;/P&gt;&lt;P&gt;# Red -&amp;gt; pwmchip4, Channel 3&lt;BR /&gt;set_pwm 4 3 "$RED_DUTY"&lt;/P&gt;&lt;P&gt;# Green -&amp;gt; pwmchip0, Channel 0&lt;BR /&gt;set_pwm 0 0 "$GREEN_DUTY"&lt;/P&gt;&lt;P&gt;# Blue -&amp;gt; pwmchip0, Channel 2&lt;BR /&gt;set_pwm 0 2 "$BLUE_DUTY"&lt;BR /&gt;-------------------------------------------&lt;/P&gt;&lt;P&gt;I've checked that red LED (GPIO_IO13) is allocated to the ledsgrp2:&lt;BR /&gt;pin 17 (IMX93_IOMUXC_GPIO_IO13): 424f0000.pwm (GPIO UNCLAIMED) function pinctrl group ledsgrp2&lt;BR /&gt;&lt;BR /&gt;as far as I can see with debugfs commands, the pin GPIO_IO13 is configured for ALT1 mode, which is a TPM2 channel 3 (PWM).&lt;BR /&gt;&lt;BR /&gt;when I run the script, I can successfully control Blue and Green LEDS but Red LED stays ON.&lt;BR /&gt;&lt;BR /&gt;Is there something that I miss?&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 02 Sep 2026 15:05:22 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/user-LED-control-on-i-MX93-FRDM-board/m-p/2410646#M246592</guid>
      <dc:creator>ilya_chepurin</dc:creator>
      <dc:date>2026-09-02T15:05:22Z</dc:date>
    </item>
    <item>
      <title>Re: user LED control on i.MX93 FRDM board</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/user-LED-control-on-i-MX93-FRDM-board/m-p/2410725#M246597</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/171880"&gt;@ilya_chepurin&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;The RED LED is channel 2, please use below script to test(&lt;STRONG&gt;verified on L6.18.20&lt;/STRONG&gt;)&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;#!/bin/sh
# RGB LED PWM cycle test for i.MX93 EVK/FRDM.
# Sequence per cycle: RED on 1s -&amp;gt; all off 1s -&amp;gt; GREEN on 1s -&amp;gt; all off 1s -&amp;gt; BLUE on 1s -&amp;gt; all off 1s
# Usage: ./run.sh [LOOPS]        LOOPS: number of full cycles, 0 = infinite, default 3
# Timing overridable via env:    ON_TIME=2 REST_TIME=1 ./run.sh

PERIOD=1000000                 # 1 kHz period in ns
ON_TIME=${ON_TIME:-1}          # seconds a color stays ON
REST_TIME=${REST_TIME:-1}      # seconds all OFF between colors
LOOPS=${1:-3}
RETRIES=50

# Channel mapping and polarity (verified on this board, all ACTIVE-HIGH):
#   Red   -&amp;gt; 424f0000.pwm = pwmchip1 ch2  ON=duty PERIOD  OFF=duty 0
#   Green -&amp;gt; 424e0000.pwm = pwmchip0 ch0  ON=duty PERIOD  OFF=duty 0
#   Blue  -&amp;gt; 424e0000.pwm = pwmchip0 ch2  ON=duty PERIOD  OFF=duty 0
RED_CHIP=1;  RED_CH=2
GRN_CHIP=0;  GRN_CH=0
BLU_CHIP=0;  BLU_CH=2

# write_retry FILE VALUE : write VALUE to FILE, retry on transient TPM busy/-ETIME,
# and confirm the value took effect. Returns 0 on success.
write_retry() {
    t=0
    while [ "$t" -lt "$RETRIES" ]; do
        echo "$2" &amp;gt; "$1" 2&amp;gt;/dev/null
        [ "$(cat "$1" 2&amp;gt;/dev/null)" = "$2" ] &amp;amp;&amp;amp; return 0
        t=$((t+1))
    done
    echo "WARN: could not write $2 to $1" &amp;gt;&amp;amp;2
    return 1
}

# init_pwm CHIP CH : export (fresh), set period BEFORE duty, start disabled with duty 0.
# The i.MX TPM shares a counter between channels; a stale export with period=0 makes
# later period writes fail with -EBUSY, so we unexport first for a clean state.
init_pwm() {
    P="/sys/class/pwm/pwmchip${1}"
    [ -d "${P}/pwm${2}" ] &amp;amp;&amp;amp; echo "$2" &amp;gt; "${P}/unexport" 2&amp;gt;/dev/null
    echo "$2" &amp;gt; "${P}/export" 2&amp;gt;/dev/null
    write_retry "${P}/pwm${2}/period" "$PERIOD"      # period must be set before duty
    write_retry "${P}/pwm${2}/duty_cycle" 0          # start OFF
    echo 1 &amp;gt; "${P}/pwm${2}/enable" 2&amp;gt;/dev/null
}

set_duty() {   # CHIP CH DUTY
    write_retry "/sys/class/pwm/pwmchip${1}/pwm${2}/duty_cycle" "$3"
}

led() {        # CHIP CH STATE(on|off)  -- all channels active-high
    if [ "$3" = on ]; then set_duty "$1" "$2" "$PERIOD"; else set_duty "$1" "$2" 0; fi
}

all_off() {
    led $RED_CHIP $RED_CH off
    led $GRN_CHIP $GRN_CH off
    led $BLU_CHIP $BLU_CH off
}

# Init: green and blue share pwmchip0, so init green first, then blue.
init_pwm $RED_CHIP $RED_CH
init_pwm $GRN_CHIP $GRN_CH
init_pwm $BLU_CHIP $BLU_CH

trap "all_off; echo; echo interrupted, all LEDs off; exit 0" INT TERM

all_off
echo "start: all OFF"

n=0
while :; do
    c=$((n+1))
    echo "[cycle $c] RED   on";  led $RED_CHIP $RED_CH on;  sleep "$ON_TIME"
    echo "[cycle $c] --- off";   all_off;                  sleep "$REST_TIME"
    echo "[cycle $c] GREEN on";  led $GRN_CHIP $GRN_CH on;  sleep "$ON_TIME"
    echo "[cycle $c] --- off";   all_off;                  sleep "$REST_TIME"
    echo "[cycle $c] BLUE  on";  led $BLU_CHIP $BLU_CH on;  sleep "$ON_TIME"
    echo "[cycle $c] --- off";   all_off;                  sleep "$REST_TIME"

    n=$c
    [ "$LOOPS" -eq 0 ] &amp;amp;&amp;amp; continue
    [ "$n" -ge "$LOOPS" ] &amp;amp;&amp;amp; break
done

all_off
echo "done ($n cycle(s)), all LEDs off"
&lt;/LI-CODE&gt;
&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;Best Regards,&lt;BR /&gt;Zhiming&lt;/P&gt;</description>
      <pubDate>Thu, 03 Sep 2026 01:27:42 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/user-LED-control-on-i-MX93-FRDM-board/m-p/2410725#M246597</guid>
      <dc:creator>Zhiming_Liu</dc:creator>
      <dc:date>2026-09-03T01:27:42Z</dc:date>
    </item>
  </channel>
</rss>

