Multi Source Translation Content

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Multi Source Translation Content

Discussions

Sort by:
[88W8997] WLAN RFテスト こんにちは、 Toradex imx8mp SOMに搭載されている88W8997モジュールについて、WIFI/BTの規制適合性試験を実施したいと考えています。 私たちはここに記載されている手順に従っています: https://www.nxp.com/docs/en/application-note/AN14114.pdf ドライバ作成については、UM11675ドキュメントに従っていました。そこには https://github.com/nxp-imx/mwifiex (ドライバ)そして https://github.com/nxp-imx/imx-firmware (関連するファームウェアパッケージ) ドライバとファームウェアをデバイスにビルドしてインストールし、RFテストモードに入ろうとしました。前述のドライバは、/proc/mwlan/adapter0インターフェースを使う可能性を提供しており、Echoの「rf_test_mode=1」>/proc/mwlan/adapter0/configコマンドでテストモードにスイッチしようとしました。 残念ながら、ドライバのプリントはRFテストモードを設定できませんでした。なぜテストモードに直接切り替えられないのでしょうか? さらに調べたところ、drv_modeを2(drv_mode=2 >設定)に変更すると、「rf_test_mode=1」コマンドでテストモードに切り替えられることがわかりました。これは正しいですか?デフォルトのdrv_mode値(デフォルト:drv_mode=7)でモードに入ることは可能ではないでしょうか? しかし、私は記述したコマンドを入力した文書の作成を続けました。 echo 「tx_frame=0」 > /proc/mwlan/adapter0/config echo "tx_antenna=2" > /proc/mwlan/adapter0/config echo "band=0" > /proc/mwlan/adapter0/config echo "BW=0" > /proc/mwlan/adapter0/config エコー「チャンネル=」+str(チャネル)) echo "tx_power=10 0 1" > /proc/mwlan/adapter0/config echo "tx_frame=1 0x3 0xB496DEB6 0x400 1 100 0 0 0 0 0 0 0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 {MAC_ADDRESS}" > /proc/mwlan/adapter0/config スペクトラムアナライザーで結果を確認しても、変化は見られません。テストモードが正常に動作しているかどうかを確認する別の方法はありますか? もう一つ奇妙な点は、tx_frameで設定しているにもかかわらず、MACアドレスが常に00:00:00:00:00と表示されることです。 hardware_status=0 netlink_num=31 drv_mode=2 hssetpara=7,0xff,200,400 SDCMD52RW=0 0x0 0x00 rf_test_mode=1 tx_antenna=1 rx_antenna=1 バンド=0 BW=0 チャネル= radio_mode[0]= radio_mode[1]= 総処方PKT数=0 RXマルチキャスト/ブロードキャストのPKTカウント=0 rx FCSエラー PKTカウント=0 tx_power= tx_continuous=0 tx_frame=0 he_tb_tx=0 trigger_frame=0 otp_mac_add_rd_wr= 00:00:00:00:00:00 antcfg=0x3 0x3 その他の注記: どこかで読んだのですが、メーカー純正のファームウェアを使用する必要があるそうです。このファームウェアを /lib/firmware/nxp に追加し、wifi_mod_para.conf ファイルを修正し(fw_nameを製造ファームウェアに置き換え、SD8997セクションにmfg_mode=1を追加)、ドライバを再読み込み(rmmod moal.ko;insmod moal.komod_para=nxp/wifi_mod_para.conf。ドライバはファームウェアがすでに動作していることを印刷します。echo "fw_reload=1" > /proc/mwlan/adapterX/config を使うと、ドライバが FW 失敗のダウンロードを印刷します。その場合、再起動が必要です。 手伝ってもらえますか? よろしくお願いします。 Re: [88W8997] WLAN RF Test @sportzfy Toradex imx8mp SOMに搭載されている88W8997モジュールのWIFI/BT規制準拠テストを実施したいと考えています。 私たちはここに記載されている手順に従っています: https://www.nxp.com/docs/en/application-note/AN14114.pdf ドライバ作成については、UM11675ドキュメントに従っていました。そこには https://github.com/nxp-imx/mwifiex(ドライバ)そして https://github.com/nxp-imx/imx-firmware(関連するファームウェアパッケージ) ドライバとファームウェアをデバイスにビルドしてインストールし、RFテストモードに入ろうとしました。前述のドライバは、/proc/mwlan/adapter0インターフェースを使う可能性を提供しており、Echoの「rf_test_mode=1」>/proc/mwlan/adapter0/configコマンドでテストモードに切り替えようとしました。 残念ながら、ドライバのプリントはRFテストモードを設定できませんでした。なぜテストモードに直接切り替えられないのでしょうか? さらに調べたところ、drv_modeを2(drv_mode=2 >設定)に変更すると、「rf_test_mode=1」コマンドでテストモードに切り替えられることがわかりました。これは正しいですか?デフォルトのdrv_mode値(デフォルト:drv_mode=7)でモードに入ることは可能ではないでしょうか? しかし、私は記述したコマンドを入力した文書の作成を続けました。 echo 「tx_frame=0」 > /proc/mwlan/adapter0/config echo "tx_antenna=2" > /proc/mwlan/adapter0/config echo "band=0" > /proc/mwlan/adapter0/config echo "BW=0" > /proc/mwlan/adapter0/config エコー「チャンネル=」+str(チャネル)) echo "tx_power=10 0 1" > /proc/mwlan/adapter0/config echo "tx_frame=1 0x3 0xB496DEB6 0x400 1 100 0 0 0 0 0 0 0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 {MAC_ADDRESS}" > /proc/mwlan/adapter0/config スペクトラムアナライザーで結果を確認しても、変化は見られません。テストモードが正常に動作しているかどうかを確認する別の方法はありますか? もう一つ奇妙なのは、MAC アドレスが tx_frame で設定しているにもかかわらず、常に 00:00:00:00:00 と表示されることです。 hardware_status=0 netlink_num=31 drv_mode=2 hssetpara=7,0xff,200,400 SDCMD52RW=0 0x0 0x00 rf_test_mode=1 tx_antenna=1 rx_antenna=1 バンド=0 BW=0 チャネル= radio_mode[0]= radio_mode[1]= 総処方PKT数=0 RXマルチキャスト/ブロードキャストのPKTカウント=0 rx FCSエラー PKTカウント=0 tx_power= tx_continuous=0 tx_frame=0 he_tb_tx=0 trigger_frame=0 otp_mac_add_rd_wr= 00:00:00:00:00:00 antcfg=0x3 0x3 その他の注記: どこかで読んだのですが、メーカー純正のファームウェアを使用する必要があるそうです。このファームウェアを /lib/firmware/nxp に追加し、wifi_mod_para.conf ファイルを修正し(fw_nameを製造ファームウェアに置き換え、SD8997セクションにmfg_mode=1を追加)、ドライバを再読み込み(rmmod moal.ko;insmod moal.ko mod_para=nxp/wifi_mod_para.conf。ドライバはファームウェアがすでに動作していることを印刷します。echo "fw_reload=1" > /proc/mwlan/adapterX/config を使うと、ドライバが FW 失敗のダウンロードを印刷します。その場合、再起動が必要です。 手伝ってもらえますか? 88W8997に対して、正しい製造ファームウェアとmfg_mode=1の設定が有効になっているかどうか確認してみましたか?また、ドライバーバージョンに対応しているサポートdrv_modeやRFテストコマンドも確認してください。 Re: [88W8997] WLAN RF Test こんにちは、 私たちは現在、toradex wifi レイヤー ( https://github.com/toradex/meta-toradex-wifi/tree/kirkstone-6.xy ) を使用し、統合された labtool ユーティリティを利用しています。さらに、公式画像ではなく、Toradexの参考画像を使用しました。この設定で今はうまく動作しているようです。 ありがとうございます。 Re: [88W8997] WLAN RF Test こんにちは、@joschi2804さん さらに調べたところ、drv_modeを2(drv_mode=2 >設定)に変更すると、「rf_test_mode=1」コマンドでテストモードに切り替えられることがわかりました。これは正しいですか?デフォルトのdrv_mode値(デフォルト:drv_mode=7)でモードに入ることは可能ではないでしょうか? --> drv_mode = 1;3;7で問題ありませんが、mlan0インターフェースを有効にすることを必ず確認してください。 スペクトラムアナライザーで結果を確認しても、変化は見られません。テストモードが正常に動作しているかどうかを確認する別の方法はありますか? --> tx_frame = 1の後に「cat /proc/mwlan/adapter0/config」の出力を共有してもらえますか?すべてのパラメータが正しく設定されているか確認してください。スペクトラム出力も私たちに共有しても構いません。また、スペクトラムの設定もしっかりしてください。 どこかで読んだのですが、メーカー純正のファームウェアを使用する必要があるそうです。このファームウェアを /lib/firmware/nxp に追加し、wifi_mod_para.conf ファイルを修正し(fw_nameを製造ファームウェアに置き換え、SD8997セクションにmfg_mode=1を追加)、ドライバを再読み込み(rmmod moal.ko;insmod moal.komod_para=nxp/wifi_mod_para.conf。ドライバはファームウェアがすでに動作していることを印刷します。echo "fw_reload=1" > /proc/mwlan/adapterX/config を使うと、ドライバが FW 失敗のダウンロードを印刷します。その場合、再起動が必要です。 -->--これはRFテストの別の方法>、 UM11675のみ 参照してください。 Re: [88W8997] WLAN RF Test こんにちは、 私はこのリポジトリの最新ブランチを使用しています。https ://github.com/nxp-imx/imx-firmware/tree/lf-6.6.3_1.0.0/nxp/FwImage_8997_SD wifi_mod_param.conf ファイルは、sdiouart8997_combo_v4.bin ファームウェアを参照しています。 Re: [88W8997] WLAN RF Test こんにちは、@joschi2804さん ドライバとファームウェアのバージョンを教えてもらえますか? よろしくお願いいたします。 ショーン
View full article
使用计算器 1_4 计算 KW45 函数的发射输出功率在 -15、-10、-5、-2 dBm 时的功耗 你好, 在 KW45_WK47_MCXW71_MCXW72_BLE_power_profile_calculator_v1.40.xlsx 文件中,给出了发射功率 (dBm) 在 0dBm 到 10dBm 范围内的功耗。 能否为KW45添加-15、-10、-5和-2 dBm的参数,以完善已添加的文件? 谢谢 Re: Consumption for KW45 function of Tx Output power for : -15,-10,-5,-2 dBm with calculator 1_4 你好, 希望你一切都好。Tx 与我们KW45B(无线电)和 KW45Z(MCU)数据表中所示的典型值相符。 此外,我建议您参考我们的主帖,了解我们所有的配置文件工具: Kinetis(KW3x/4x、MCX W7x 和 MCX W23)无线连接功率我的工具 顺祝商祺! 里卡多
View full article
[88W8997] WLAN射频测试 你好, 我们希望对组装在 Toradex imx8mp SOM 上的 88W8997 模块进行 WIFI/BT 监管合规性测试。 我们正在按照此处的说明进行操作: https://www.nxp.com/docs/en/application-note/AN14114.pdf 构建驱动程序时,我们遵循了 UM11675 文档,其中提到了https://github.com/nxp-imx/mwifiex(驱动程序)和https://github.com/nxp-imx/imx-firmware(相关固件包)。 我在设备上构建并安装了驱动程序和固件,并尝试进入射频测试模式。上述驱动程序现在允许我使用 /proc/mwlan/adapter0 接口,我尝试使用 echo "rf_test_mode=1" > /proc/mwlan/adapter0/config 命令切换到测试模式。 很遗憾,驱动程序显示“无法设置射频测试模式”。为什么不能直接切换到测试模式? 经过进一步调查,我发现如果我将 drv_mode 更改为 2(drv_mode=2 > 配置),则可以使用“rf_test_mode=1”命令切换到测试模式。这样对吗?是否可以使用默认的 drv_mode 值(默认值:drv_mode=7)进入该模式? 但是,我继续在文档中输入了上述命令: echo "tx_frame=0" > /proc/mwlan/adapter0/config echo "tx_antenna=2" > /proc/mwlan/adapter0/config echo "band=0" > /proc/mwlan/adapter0/config echo "bw=0" > /proc/mwlan/adapter0/config echo "channel=" + str(channel)) echo "tx_power=10 0 1" > /proc/mwlan/adapter0/config echo "tx_frame=1 0x3 0xB496DEB6 0x400 1 100 0 0 0 0 0 0 0 -1 -1 -1 -1 -1 -1 -1 -1 {MAC_ADDRESS}" > /proc/mwlan/adapter0/config 当我查看频谱分析仪的结果时,没有发现任何变化。还有其他方法可以检查测试模式是否正常工作吗? 还有一点很奇怪,即使我用 tx_frame 设置了 MAC 地址,它始终显示为 00:00:00:00:00。 硬件状态=0 netlink_num=31 驱动模式=2 hssetpara=7,0xff,200,400 sdcmd52rw=0 0x0 0x00 rf_test_mode=1 tx_antenna=1 接收天线=1 band=0 bw=0 频道= radio_mode[0]= radio_mode[1]= 总处方药包数=0 接收多播/广播数据包计数=0 接收函数调用错误数据包计数=0 发射功率= tx_continuous=0 tx_frame=0 he_tb_tx=0 触发帧=0 otp_mac_add_rd_wr= 00:00:00:00:00:00 antcfg=0x3 0x3 补充说明: 我之前看到过,必须使用厂商提供的固件。当我将此固件添加到 /lib/firmware/nxp 时,修改了 wifi_mod_para.conf 文件(将 fw_name 替换为制造商固件,并在 SD8997 部分添加了 mfg_mode=1),然后重新加载了驱动程序(rmmod moal.ko;insmod moal.komod_para=nxp/wifi_mod_para.conf。驱动程序显示固件已经在运行。当我使用 echo "fw_reload=1" > /proc/mwlan/adapterX/config 时,驱动程序打印出固件下载失败的信息。然后需要重启电脑。 你能帮帮我吗? 谢谢! Re: [88W8997] WLAN RF Test @sportzfy我们想对组装在 Toradex imx8mp SOM 上的 88W8997 模块进行 WIFI/BT 监管合规性测试。 我们正在按照此处的说明进行操作: https://www.nxp.com/docs/en/application-note/AN14114.pdf 构建驱动程序时,我们遵循了 UM11675 文档,其中提到了https://github.com/nxp-imx/mwifiex(驱动程序)和https://github.com/nxp-imx/imx-firmware(相关固件包)。 我在设备上构建并安装了驱动程序和固件,并尝试进入射频测试模式。上述驱动程序现在使我能够使用 /proc/mwlan/adapter0 接口,我尝试使用 echo "rf_test_mode=1" > /proc/mwlan/adapter0/config" 命令切换到测试模式。 很遗憾,驱动程序显示“无法设置射频测试模式”。为什么不能直接切换到测试模式? 经过进一步调查,我发现如果我将 drv_mode 更改为 2(drv_mode=2 > 配置),则可以使用“rf_test_mode=1”命令切换到测试模式。这样对吗?是否可以使用默认的 drv_mode 值(默认值:drv_mode=7)进入该模式? 但是,我继续在文档中输入了上述命令: echo "tx_frame=0" > /proc/mwlan/adapter0/config echo "tx_antenna=2" > /proc/mwlan/adapter0/config echo "band=0" > /proc/mwlan/adapter0/config echo "bw=0" > /proc/mwlan/adapter0/config echo "channel=" + str(channel)) echo "tx_power=10 0 1" > /proc/mwlan/adapter0/config echo "tx_frame=1 0x3 0xB496DEB6 0x400 1 100 0 0 0 0 0 0 0 -1 -1 -1 -1 -1 -1 -1 -1 {MAC_ADDRESS}" > /proc/mwlan/adapter0/config 当我查看频谱分析仪的结果时,没有发现任何变化。还有其他方法可以检查测试模式是否正常工作吗? 还有一件奇怪的事,即使我使用 tx_frame 设置了 MAC 地址,它仍然始终显示为 00:00:00:00:00。 硬件状态=0 netlink_num=31 驱动模式=2 hssetpara=7,0xff,200,400 sdcmd52rw=0 0x0 0x00 rf_test_mode=1 tx_antenna=1 接收天线=1 band=0 bw=0 频道= radio_mode[0]= radio_mode[1]= 总处方药包数=0 接收多播/广播数据包计数=0 接收函数调用错误数据包计数=0 发射功率= tx_continuous=0 tx_frame=0 he_tb_tx=0 触发帧=0 otp_mac_add_rd_wr= 00:00:00:00:00:00 antcfg=0x3 0x3 补充说明: 我之前看到过,必须使用厂商提供的固件。当我将此固件添加到 /lib/firmware/nxp 时,修改了 wifi_mod_para.conf 文件(将 fw_name 替换为制造商固件,并在 SD8997 部分添加了 mfg_mode=1),然后重新加载了驱动程序(rmmod moal.ko;insmod moal.ko mod_para=nxp/wifi_mod_para.conf。驱动程序显示固件已经在运行。当我使用 echo "fw_reload=1" > /proc/mwlan/adapterX/config 时,驱动程序打印出固件下载失败的信息。然后需要重启电脑。 你能帮帮我吗? 您是否检查过 88W8997 是否启用了正确的制造固件和 mfg_mode=1 设置?我还会验证您的驱动程序版本支持的 drv_mode 和 RF 测试命令。 Re: [88W8997] WLAN RF Test 你好, 我们现在使用的是 toradex wifi 层( https://github.com/toradex/meta-toradex-wifi/tree/kirkstone-6.xy ),并利用了集成的 labtool 实用程序。此外,我们使用了 toradex 参考图像而不是我们官方的图像。这样设置后,现在似乎可以正常工作了。 谢谢。 Re: [88W8997] WLAN RF Test 你好@joschi2804 经过进一步调查,我发现如果我将 drv_mode 更改为 2(drv_mode=2 > 配置),则可以使用“rf_test_mode=1”命令切换到测试模式。这样对吗?是否可以使用默认的 drv_mode 值(默认值:drv_mode=7)进入该模式? --> drv_mode = 1;3;7 没问题,只需确保 mlan0 接口已启用即可。 当我查看频谱分析仪的结果时,没有发现任何变化。还有其他方法可以检查测试模式是否正常工作吗? --> 能否分享一下在 tx_frame = 1 之后运行“cat /proc/mwlan/adapter0/config”命令的输出结果?请确保所有参数配置正确。您也可以同时分享频谱输出结果。此外,请确保频谱配置正确。 我之前看到过,必须使用厂商提供的固件。当我将此固件添加到 /lib/firmware/nxp 时,修改了 wifi_mod_para.conf 文件(将 fw_name 替换为制造商固件,并在 SD8997 部分添加了 mfg_mode=1),然后重新加载了驱动程序(rmmod moal.ko;insmod moal.komod_para=nxp/wifi_mod_para.conf。驱动程序显示固件已经在运行。当我使用 echo "fw_reload=1" > /proc/mwlan/adapterX/config 时,驱动程序打印出固件下载失败的信息。然后需要重启电脑。 --> 这是射频测试的另一种方法,请仅参考 UM11675。 Re: [88W8997] WLAN RF Test 你好, 我正在使用此仓库的最新分支。https ://github.com/nxp-imx/imx-firmware/tree/lf-6.6.3_1.0.0/nxp/FwImage_8997_SD wifi_mod_param.conf 文件指的是 sdiouart8997_combo_v4.bin 固件。 Re: [88W8997] WLAN RF Test 你好@joschi2804 能否提供一下驱动程序和固件版本? 顺祝商祺! 肖恩
View full article
i.MX7D UART5 in DTE mode using I2C4 Hi. This is the original i.MX7D board. The 2-wire UART5 circuit uses the I2C4 port. This UART5 is in DTE mode. I am configuring the CCM, IOMUXC ports, IOMUXC DAISY settings, and UART5. CCM_TARGET_ROOTn=0x10000000 CCM_CCGRn=0x3 IOMUXC_SW_MUX_CTL_PAD_I2C4_SCL=1 IOMUXC_SW_MUX_CTL_PAD_I2C4_SDA=1 IOMUXC_UART5_RX_DATA_SELECT_INPUT=1 UART5_UCR1=1 UART5_UCR2=0x7027 UART5_UCR3=0x784 UART5_UCR4=0x8000 UART5_UFCR=0x240 UART5_UBIR=0xF UART5_UBMR=0x271 After sending one character, UART5_UTS remains at 0x20 (having changed from 0x60). I do not know why UART5_UTS does not return to 0x60. Best Regards. Re: i.MX7D UART5 in DTE mode using I2C4 Spoiler (Highlight to read)     Hi. AldoG. There was an error in a portion of the information I sent. UART5_CLK_ROOT(0x30380b18)=0x10000000 The correct version is as follows. UART5_CLK_ROOT(0x3038b180)=0x10000000 Best regards. Re: i.MX7D UART5 in DTE mode using I2C4 Hi. AldoG. Upon startup, for some reason IPG_CLK_ROOT (0x30389080) was set to 0x1, so I changed it to 0x0. UART5_CLK_ROOT(0x30380b18)=0x10000000 UART5_CCM_CCGR=CCM_CCGR152(0x30384980)=0x3 It has been set up this way. I tried changing the pins used from I2C4 to SAI1, but the result was unsuccessful. I set the register to be checked to TXDC within USR2. Best regards. Re: i.MX7D UART5 in DTE mode using I2C4 Hello, For the i.MX7D UART status register, UTS[6] is the TX FIFO empty indication and UTS[5] is the RX FIFO empty indication. Therefore, 0x60 indicates that both FIFOs are empty, while 0x20 indicates that the RX FIFO is empty but the TX FIFO is not yet empty. Seeing 0x20 immediately after writing a character can therefore be expected. UTS[6] only reflects the FIFO state. If you need to determine when the character has completely finished transmitting, check USR2[TXDC], which indicates that the transmit FIFO and shift register are empty. For this two-wire configuration, please also verify the following: Hardware CTS/RTS flow control is disabled. If CTS/RTS is enabled without the corresponding signals being connected, transmission may be prevented. Both the UART5 functional clock and the IPG clock are enabled, and the UBIR/UBMR values are calculated using the actual UART5 clock frequency. The DTE pin mapping is checked against the i.MX7D Reference Manual. DTE mode changes the apparent RX/TX pin direction, so the signal names can be confusing. The I2C4 peripheral is not also enabled or driving the same pads. The UART5 TX pin is probed with an oscilloscope or logic analyzer. If a valid waveform is present, the 0x20 reading is likely only a status-sampling issue. If no waveform is present, check the clock, flow-control, and pin-mux configuration first. Please refer to the i.MX 7Dual Reference Manual (IMX7DRM), especially the UART and IOMUX sections. The NXP discussions iMX7 UART pin setup and i.MX7 IPG_CLK_ROOT and UART's clock may also be useful. Best regards/Saludos, Aldo. Re: i.MX7D UART5 in DTE mode using I2C4 Hello, TXDC indicates that the TX FIFO and shift register are empty. Please check whether USR2[TXDC] becomes 1 after the character is sent. If it remains 0, please also capture the UTS, USR1, and USR2 values before and after transmission, together with the UART5 TX pin waveform. For the two-wire configuration, please also verify that hardware CTS/RTS flow control is disabled. If CTS/RTS is enabled without the corresponding signals being connected, the transmitter may remain blocked. Also confirm that no I2C4 or SAI1 peripheral remains enabled and driving the selected pads. Best regards/Saludos, Aldo. Re: i.MX7D UART5 in DTE mode using I2C4 Hi AldoG, To avoid confusion caused by DTE mode, I modified the board wiring to set it to DCE mode. After initialization in U-Boot, I used an oscilloscope to monitor the pin voltage levels while toggling the IOMUXC pull-up/pull-down settings. The input pins responded correctly to these configuration changes. Next, I set the DTE bit in the UART5_UFCR register and repeated the test; the input pins again responded correctly to the configuration changes. The output pins switch according to the DCE/DTE configuration, and in both cases, the voltage level is '1'. Therefore, the PAD configuration is correct. Since the IRTS bit in the UART5_UCR2 register is set to '1', the RTS signal should be ignored. Could you please provide specific, detailed support on what I should investigate next to resolve this issue? Best regards. Re: i.MX7D UART5 in DTE mode using I2C4 Hi AldoG. The issue has been resolved. I have reverted from the 2-wire DCE mode to the 3-wire DTE mode. The pins used are I2C3_SCL, I2C4_SCL, and I2C4_SDA. The clock is configured via the CCM in `/arch/arm/mach-imx/mx7/clock.c` within the `init_clk_uart()` function. The pin configuration is as follows: static iomux_v3_cfg_t const uart5_pads[] = { MX7D_PAD_I2C3_SCL__UART5_DTE_RTS | MUX_PAD_CTRL(UART_PAD_CTRL), MX7D_PAD_I2C4_SCL__UART5_DTE_TX | MUX_PAD_CTRL(UART_PAD_CTRL), MX7D_PAD_I2C4_SDA__UART5_DTE_RX | MUX_PAD_CTRL(UART_PAD_CTRL), }; imx_iomux_v3_setup_multiple_pads(uart5_pads, ARRAY_SIZE(uart5_pads)); writel(readl(0x30330158) | 0x10, 0x30330158); writel(readl(0x30330160) | 0x10, 0x30330160); writel(readl(0x30330164) | 0x10, 0x30330164); writel(0, 0x30330710); writel(0, 0x30330714); Next, I will proceed with serial initialization and baud rate configuration, using `serial_mx.c` as a reference. However, the UCR2 register will be configured as follows: writel(UCR2_WS | UCR2_TXEN | UCR2_RXEN | UCR2_SRST, &base->cr2); This worked.
View full article
RW612 button multiplexed with ISP pin I would like to use a button to make the RW612 boot into ISP mode when power is first applied to the board while the button is pressed. But that button will also be pressed regularly during normal operation. The button is connected to both ISP0 and GPIO24. In the datasheet it is stated that the ISP0 pin will change its function to EXT_REQ when the bootloader starts the code execution from flash. I dont exactly know what happens when the EXT_REQ pin is pulled low during normal operation. What does happen when EXT_REQ is pulled low occasionally during normal operation? Is there a way to disable its function in software, do I have to isolate EXT_REQ from the button after boot or is there nothing I have to worry about? Product: WiFi RW6XX Re: RW612 button multiplexed with ISP pin Hi @Niwo, hope you are doing well. The EXT_REQ pin is used to coexist with an external radio through PTA interface as mentioned in section 6.3 of the RW612 Datasheet. However, please note that as stated in Table 45 of UM11865, GPIO[24] is used by the ROM code for UART ISP interface and such functionality cannot be changed. Therefore I'd suggest to consider another GPIO for your button functionality and isolate the ISP interface. Also, please consider that ISP can be permanently disabled or limited for a final product implementation to enhance security access to the MCU, therefore it is important to keep in mind this feature for your design. Hope this helps! Re: RW612 button multiplexed with ISP pin Thank you @RomanVR for your reply, To clarify my goals regarding the button; The button should also make the MCU wake up from deep sleep and if I understand the user manual correctly, only GPIO[24] and GPIO[25] support this functionality. You mentioned that GPIO[24] is used for UART functionality by the ISP and it cannot be changed. Does this mean that GPIO[24] will always be a UART pin and I can't change that in my own program? Or does it only mean that I cannot modify which pins the ISP uses while it is running, and afterwards I can do whatever I want with these pins? For the EXT_REQ pin I decided that I will use a solder jumper for development purposes and later use IAP software updates instead of connecting it permanently to the button. Best regards Re: RW612 button multiplexed with ISP pin Hi @Niwo, thank you for providing details on your implementation. I apologize if I was not clear before regarding GPIO[24] functionality; the function of this GPIO can be changed in your application. However, from a ROM code perspective the UART functionality is exclusive from GPIO[24] & GPIO[26] and cannot be changed to another Flexcomm instance or GPIOs. Hope this information clears out your doubts.
View full article
iMX6ULLの改ざん検知機能 i.MX6ULLプロセッサのアクティブ改ざん検出機能を有効にして、デバイスのエンクロージャーが開いたときに検出したいと思っています。 スイッチがハードウェアに追加され、添付図に示されているように外部タンパーピンに接続されています。 ソフトウェア側で改ざん検知をサポートする例やドキュメントはありますか?この機能の設定方法や操作方法を示す実装例やサンプル関数はありますか? Re: Tamper detection function in iMX6ULL こんにちは、 i.MX 6ULLの改ざん防止機能はヒューズによって制御されていますが、NXPは現在、i.MX6ULLのすべての量産部品番号においてこの機能を無効にするように設定しています。 いくつかの顧客向け文書では、i.MX 6ULLが外部改ざんをサポートしていると誤って記載されています。ヒューズは i.MX すべての6ULL部品番号でこの機能を無効にするようにプログラムされているため、タンパーピンは現在のドキュメントに記載されているものの、お客様はタンパー機能を使用できません。 改ざんはサポートされていないことを反映するドキュメントが更新されます。 また、6ULZ i.MX 派生製品もタンパーをサポートしていないことにご注意ください 特長 i.MX 6UL -3 i.MX 6ULL/6ULZ コメント 改ざん検知信号 はい いいえ i.MX 6ULのみでアクティブタンパー機能が有効です。 電圧/温度/周波数検出(ドライアイス) はい いいえ i.MX 6ULL/ULZでは、ドライアイスおよびアクティブタンパー機能はサポートされていません。 よろしくお願いいたします。
View full article
24MHz clock issue RT1052 Hi,  I have develop a customised PCB incl the RT1052 MCU. The clock configuration which I am using is: where C57 and C58 are replaced with 4.7 pF to be conform the evaluation board. However, I am not able to start the oscillator on the chip.  The power up sequence seem to me correct: 1) SNVS 3V3 stable 2) NVCC_x, DCDC_IN, VDD_HIGH (3V3_main) become 3V3 stable. 3) VDD_SOC becomes 1.1V stable which is OK. POR is released after all power lines are OK and option bytes are set to serial download. If I turn the power on I see on the scope that no ossilation is started and XTALO becomes 3V3 stable. Yellow XTALO, blue XTALI, green 3V3_main, red POR (becomes high after 200 ms) If i turn the power of I see some oscillation which I assume the oscillator parameters are OK. also I don't have SWD communication while pinning is correct. I tried to inject 20 MHz clock and got some response but no reliable communication. Therefore I tried first fixing the 24 MHz oscillator first. Does somebody know why the oscillator does not start? i.MX-RT1050 Re: 24MHz clock issue RT1052 Hi @JBA , Thank you so much for your interest in our products and for using our community. Based on your description, I would suggest you check the oscillator-related connections and the actual power-up waveforms. 1:  Please measure VDD_SNVS_IN, VDD_HIGH_IN, DCDC_IN, DCDC_PSWITCH, and POR_B during power-up. In particular, please check that DCDC_PSWITCH rises at least 1 ms after DCDC_IN is stable. 2:Please check your  crystal manufacturer’s specifications for its load capacitance (CL​) and ESR, then calculate the effective load capacitance using the installed capacitor values together with the PCB and MCU pin parasitic capacitance. Verify that the calculated load is appropriate for the crystal. The EVK’s 4.7 pF capacitor values should not be copied directly unless the crystal specifications and board parasitics are comparable. 3:Please measure the voltage at NVCC_PLL after the supplies have stabilized. If you repeat the test using an external clock source, drive XTALO and ensure that the clock’s high-level voltage does not exceed the measured NVCC_PLL voltage. Best Regards May Liu Re: 24MHz clock issue RT1052 1) VDD_SNVS_IN, VDD_HIGH_IN, DCDC_IN, DCDC_PSWITCH, and POR_B during power-up. These are correct and in the correct order: Yellow: VDD_SNVS_IN. Green: VDD_HIGH_IN and DCDC_IN Red: VDD_SOC Blue: POR DCDC_PSWITCH and VDD_SOC. PSWITCH is enabled 30 ms after DCDC_IN is stable. 2) I recalculated the capacitors using CL = 7 pF and stray = 3 pF. Load capacitors are set to 8.2 pF but still no oscillation visible on scope. 3) I am not able to directly measure the NVCC_PLL pin because it is under the BGA package. However, it is directly connected to VDD_HIGH and DCDC_IN. A question about using an external clock source: shouldn't it be injected at XTALI pin, instead of XTALO? What could I do else? thanks for you thoughts.   Re: 24MHz clock issue RT1052 Hi May, we found the NVCC_PLL issues also. I was able to remove the connection and now the oscillators starts working. Thanks for your support. Re: 24MHz clock issue RT1052 Hi @JBA , Thanks for your updated information. Regarding you question about "A question about using an external clock source: shouldn't it be injected at XTALI pin, instead of XTALO?"  I was referring to the configuration described in the RT1050 data sheet: an external 24 MHz oscillator drives XTALO , with an 18 pF capacitor on XTALI . The applied clock level must not exceed NVCC_PLL .  I would also like to clarify your statement that NVCC_PLL is “directly connected to VDD_HIGH and DCDC_IN.” Do you mean that NVCC_PLL, VDD_HIGH_IN, and DCDC_IN are all connected to the same 3.3 V PCB net ? Please check the schematic or PCB net connections to confirm this. NVCC_PLL is the approximately 1.1 V output of the internal LDO_1P1, whereas VDD_HIGH_IN and DCDC_IN are supply inputs. If NVCC_PLL is directly tied to that 3.3 V net, this connection needs to be corrected before further oscillator testing.  Best Regards May  Re: 24MHz clock issue RT1052 It is quite confusing because NVCC_PLL is called the same as other NVCC_x ports. It would be better to call it NVCC_PLL_CAP
View full article
i.MX7D UART5 在 DTE 模式下使用 I2C4 你好。 这是原装的i.MX7D板。 双线 UART5 电路使用 I2C4 端口。 此 UART5 处于 DTE 模式。 我正在配置 CCM、IOMUXC 端口、IOMUXC DAISY 设置和 UART5。 CCM_TARGET_ROOTn=0x10000000 CCM_CCGRn=0x3 IOMUXC_SW_MUX_CTL_PAD_I2C4_SCL=1 IOMUXC_SW_MUX_CTL_PAD_I2C4_SDA=1 IOMUXC_UART5_RX_DATA_SELECT_INPUT=1 UART5_UCR1=1 UART5_UCR2=0x7027 UART5_UCR3=0x784 UART5_UCR4=0x8000 UART5_UFCR=0x240 UART5_UBIR=0xF UART5_UBMR=0x271 发送一个字符后,UART5_UTS 仍为 0x20(之前为 0x60)。 我不知道为什么 UART5_UTS 没有返回 0x60。 顺祝商祺! Re: i.MX7D UART5 in DTE mode using I2C4 剧透 (高亮部分可供阅读)     你好。AldoG。 我发送的信息中有一部分有误。 UART5_CLK_ROOT(0x30380b18)=0x10000000 正确版本如下。 UART5_CLK_ROOT(0x3038b180)=0x10000000 顺祝商祺! Re: i.MX7D UART5 in DTE mode using I2C4 你好。AldoG。 启动时,由于某种原因,IPG_CLK_ROOT (0x30389080) 被设置为 0x1,所以我将其更改为 0x0。 UART5_CLK_ROOT(0x30380b18)=0x10000000 UART5_CCM_CCGR=CCM_CCGR152(0x30384980)=0x3 它就是这样设置的。 我尝试将使用的引脚从 I2C4 改为 SAI1,但结果并不成功。 我已将 USR2 中的寄存器设置为 TXDC 进行检查。 顺祝商祺! Re: i.MX7D UART5 in DTE mode using I2C4 你好, 对于 i.MX7D UART 状态寄存器,UTS[6] 表示 TX FIFO 为空,UTS[5] 表示 RX FIFO 为空。因此,0x60 表示两个 FIFO 都为空,而 0x20 表示 RX FIFO 为空,但 TX FIFO 尚未为空。因此,输入字符后立即看到 0x20 是正常的。 UTS[6] 仅反映 FIFO 状态。如果您需要确定字符何时完全完成传输,请检查 USR2[TXDC],它表示发送 FIFO 和移位寄存器为空。 对于这种两线配置,请同时验证以下内容: 硬件 CTS/RTS 流控制已禁用。如果启用 CTS/RTS 但未连接相应的信号,则可能会阻止传输。 UART5 功能时钟和 IPG 时钟均已启用,UBIR/UBMR 值使用实际的 UART5 时钟频率计算。 DTE引脚映射已对照i.MX7D参考手册进行检查。DTE 模式会改变 RX/TX 引脚的明显方向,因此信号名称可能会令人困惑。 I2C4 外设未启用或未驱动相同的焊盘。 使用示波器或逻辑分析仪探测 UART5 TX 引脚。如果存在有效的波形,则 0x20 读数很可能只是状态采样问题。如果没有波形,请先检查时钟、流控制和引脚复用配置。 请参阅i.MX 7Dual 参考手册 (IMX7DRM) ,特别是 UART 和 IOMUX 部分。NXP 的讨论iMX7 UART 引脚设置以及i.MX7 IPG_CLK_ROOT 和 UART 时钟也可能有用。 此致敬礼/Saludos, 阿尔多。 Re: i.MX7D UART5 in DTE mode using I2C4 你好, TXDC 表示 TX FIFO 和移位寄存器为空。请检查字符发送后 USR2[TXDC] 是否变为 1。如果仍然为 0,请同时捕获传输前后的 UTS、USR1 和 USR2 值以及 UART5 TX 引脚波形。 对于两线配置,请同时确认硬件 CTS/RTS 流控制已禁用。如果启用了 CTS/RTS 但未连接相应的信号,则发射器可能会保持阻塞状态。同时确认没有 I2C4 或 SAI1 外设处于启用状态并驱动所选焊盘。 此致敬礼/Saludos, 阿尔多。 Re: i.MX7D UART5 in DTE mode using I2C4 你好 AldoG, 为了避免 DTE 模式造成的混乱,我修改了板的接线,将其设置为 DCE 模式。 在 U-Boot 初始化后,我使用示波器监测引脚电压等级,同时切换 IOMUXC 上拉/下拉设置。 输入引脚对这些配置更改做出了正确的响应。 接下来,我设置了 UART5_UFCR 寄存器中的 DTE 位并重复了测试;输入引脚再次对配置更改做出了正确的响应。 输出引脚根据 DCE/DTE 配置进行切换,在这两种情况下,电压等级均为“1”。 因此,PAD配置是正确的。 由于 UART5_UCR2 寄存器中的 IRTS 位设置为“1”,因此应忽略 RTS 信号。 请问您能否提供具体、详细的指导,告诉我接下来应该调查哪些方面来解决这个问题? 顺祝商祺! Re: i.MX7D UART5 in DTE mode using I2C4 你好 AldoG。 问题已解决。 我已经将 DCE 模式从两线制改为 DTE 模式。 使用的引脚为 I2C3_SCL、I2C4_SCL 和 I2C4_SDA。 时钟是通过 CCM 在 `/arch/arm/mach-imx/mx7/clock.c` 中进行配置的。在 `init_clk_uart()` 函数中。 引脚配置如下: static iomux_v3_cfg_t const uart5_pads[] = { MX7D_PAD_I2C3_SCL__UART5_DTE_RTS | MUX_PAD_CTRL(UART_PAD_CTRL), MX7D_PAD_I2C4_SCL__UART5_DTE_TX | MUX_PAD_CTRL(UART_PAD_CTRL), MX7D_PAD_I2C4_SDA__UART5_DTE_RX | MUX_PAD_CTRL(UART_PAD_CTRL), }; imx_iomux_v3_setup_multiple_pads(uart5_pads, ARRAY_SIZE(uart5_pads)); writel(readl(0x30330158) | 0x10, 0x30330158); writel(readl(0x30330160) | 0x10, 0x30330160); writel(readl(0x30330164) | 0x10, 0x30330164); writel(0, 0x30330710); writel(0, 0x30330714); 接下来,我将使用 `serial_mx.c` 进行串口初始化和波特率配置。供参考。 但是,UCR2 寄存器将按如下方式配置:writel(UCR2_WS | UCR2_TXEN | UCR2_RXEN | UCR2_SRST, &base->cr2); 这招奏效了。
View full article
RW612按钮与ISP引脚复用 我希望使用一个按钮,使RW612启动到ISP模式,当首次给板通电并按下该按钮。但在正常操作过程中,该按钮也会经常被按下。 该按钮同时连接到ISP0和GPIO24 。 数据手册中指出,当引导加载程序从闪存开始执行代码时, ISP0引脚的功能将变为EXT_REQ 。 我不太清楚在正常运行期间将EXT_REQ引脚拉低时会发生什么情况。 正常运行期间,如果EXT_REQ偶尔被拉低,会发生什么情况?是否有办法通过软件禁用其功能?启动后是否需要将EXT_REQ与按钮隔离?或者我无需担心什么? 产品:WiFi RW6XX Re: RW612 button multiplexed with ISP pin 嗨@Niwo ,希望你一切都好。 如 RW612 数据手册 第 6.3 节 所述,EXT_REQ 引脚用于通过 PTA 接口与外部无线电共存。但是请注意,如UM11865的表 45 所述,GPIO[24] 由 ROM 代码用于 UART ISP 接口,并且此功能无法更改。 因此,我建议考虑使用另一个 GPIO 来实现按钮功能,并将 ISP 接口隔离。另外,请注意,为了增强对 MCU 的网络安全访问,最终产品实现中可以永久禁用或限制 ISP,因此在设计时务必牢记此功能。 希望这能帮到你! Re: RW612 button multiplexed with ISP pin 感谢@RomanVR的回复, 为了阐明我关于按钮的目标;该按钮还应该使 MCU 从深度睡眠中唤醒,如果我理解用户手册正确的话,只有 GPIO[24] 和 GPIO[25] 支持此功能。 您提到 GPIO[24] 被 ISP 用于 UART 功能,并且不能更改。这是否意味着 GPIO[24] 将始终是 UART 引脚,而我无法在自己的程序中更改它?或者这仅仅意味着我不能在 ISP 运行时修改它使用的引脚,而之后我可以随意使用这些引脚? 对于 EXT_REQ 引脚,我决定在开发过程中使用焊接跳线,之后使用 IAP 软件更新,而不是将其永久连接到按钮上。 顺祝商祺! Re: RW612 button multiplexed with ISP pin @Niwo你好,感谢你提供实施方面的详细信息。 如果我之前对 GPIO[24] 的功能解释得不够清楚,我深表歉意;此 GPIO 的功能可以在您的应用程序中更改。但是,从 ROM 代码的角度来看,UART 功能与 GPIO[24] 和 GPIO[26] 互不相同,不能更改为其他 Flexcomm 实例或 GPIO。 希望这些信息能消除您的疑虑。
View full article
RW612ボタンはISPピンと多重化されている。 ボタンを押した状態でボードに電源が最初に投入されたときに、 RW612をISPモードで起動するようにしたいです。しかし、そのボタンは通常の操作中にも頻繁に押されるだろう。 このボタンはISP0とGPIO24の両方にコネクテッドされています。 データシートには、ブートローダーがフラッシュからコードの実行を開始すると、 ISP0ピンの機能がEXT_REQに変更されると記載されています。 通常動作中にEXT_REQピンがローレベルにプルダウンされた場合に何が起こるのか、正確にはわかりません。 通常動作中にEXT_REQが時折ローレベルに引き下げられた場合、何が起こるのでしょうか? ソフトウェア で機能を無効にする方法はありますか?起動後にボタンからEXT_REQを隔離しなければならないのでしょうか?それとも特に心配する必要はありませんか? 製品: WiFi RW6XX Re: RW612 button multiplexed with ISP pin こんにちは、 @Niwo さん。お元気でお過ごしでしょうか。 EXT_REQピンは 、RW612データシート の 6.3節 に記載されているように、PTAインターフェースを介して外部無線機と共存するために使われます。ただし、 UM11865の表45に記載されているように、GPIO[24]はUART ISPインターフェースのROMコードで使用されており、その機能は変更できません。 したがって、ボタン機能用に別のGPIOを検討し、ISPインターフェースを分離することをおすすめします。また、ISPは最終製品実装時に永久に無効化または制限されることがあり、MCUへのセキュリティアクセスを強化するため、デザイン時にこの機能を念頭に置くことが重要です。 お役に立てば幸いです! Re: RW612 button multiplexed with ISP pin @RomanVRさん、ご返信ありがとうございます。 ボタンに関する私の目的を明確にするために;ボタンはMCUをディープスリープから覚醒させるもので、ユーザーマニュアルの理解が正しければ、この機能はGPIO[24]とGPIO[25]のみがサポートしているはずです。 GPIO[24]はISPがUART機能に使っており、変更できないとおっしゃっていましたね。これはつまり、GPIO[24]は常にUARTピンのままで、自分のプログラム内でそれを変更できないということですか?それとも、ISPが稼働中にどのピンを使うかを改めず、その後はそのピンを自由に使えるという意味でしょうか? EXT_REQピンについては、開発用にはんだジャンパーを使い、後でIAPソフトウェアアップデートでボタンに永久接続するのではなく、 よろしくお願いいたします。 Re: RW612 button multiplexed with ISP pin こんにちは、 @Niwo さん。実装の詳細を教えていただきありがとうございます。 GPIO[24]の機能について、以前に明確に説明できていなかったら申し訳ありません。このGPIOの機能はアプリケーション内で変更可能です。しかし、ROMコードの観点から見ると、UART機能はGPIO[24]およびGPIO[26]専用であり、他のFlexcommインスタンスやGPIOに変更することはできません。 この情報であなたの疑問が解消されることを願っています。
View full article
[MCX A153] LPI2C 新手指南(日语博客) 介绍 本文面向微控制器初学者,讲解了恩智浦半导体 (NXP) MCX A153微控制器的外设功能和使用方法。您将通过实际修改恩智浦提供的 SDK 示例程序来学习基本概念和实现方法。 目录   1. 应用中的常见用法示例(I²C 版) 1.1 主要用途 1.2 使用示例 2. I²C 基础知识 2.1 首先,I²C 是什么? 2.2 微控制器 I²C 模块 3. MCX A153 I²C 模块 (LPI2C) 的主要功能和框图 3.1 概述 3.2 方框图 3.3 功能 4. 使用的设备和开发工具 4.1 评估委员会 (FRDM-MCXA153) 4.2 开发工具(适用于 VS Code 和 IDE 的 MCUXpresso) 5. 编程 5.1 检查基础示例代码的内容 5.2 引脚配置 5.3 程序代码的更改 6. 实践训练 6.1 实践培训内容 6.2 实践练习程序 6.3 在评估板上添加上拉电阻 6.4 编码更改 6.5 使用引脚配置器更改引脚设置 6.6 构建与调试、测试功能   1. 应用中的常见用法示例(I²C 版)   本章要点:我们将研究 I²C 的应用场景。   1.1 主要用途 I²C 是一种通过指定设备内部寄存器地址来读写数据的通信方式。由于它使用的信号线较少,因此适合控制单个电路板上的多个集成电路。然而,它容易受到线路电容和噪声的影响,因此通常用于短距离通信。 连接各种传感器,例如温度传感器、加速度传感器和磁传感器。 数字电位器 IO扩展器 EEPROM 实时控制器 显示设备(LCD、LED 等)的输入/输出扩展 微控制器之间的通信(包含在 FRDM-MCXA153 评估板上的示例程序中) 1.2 使用示例 实际应用包括计算机主板、嵌入式系统和移动电话。   2. I²C 基础知识   本章要点:我们将阐明 I²C 的基本术语,包括 SDA、SCL、地址、ACK/NACK 和上拉电阻。   2.1 首先,I²C 是什么? I²C是由飞利浦半导体(现为恩智浦半导体)开发的一种串行总线通信标准。目前,它被广泛用作连接电路板上传感器和外围集成电路的代表性方法。 I²C 是一种同步串行通信方法,它通过时钟信号同步发送数据。数据线称为 SDA,时钟线称为 SCL。通信通过控制 SDA 和 SCL 的时序来实现。 每个从设备都有一个唯一的地址,主设备通过指定该地址进行通信。通信开始时发送地址后,目标从设备会返回一个 ACK(确认)。如果无法收到 ACK,则不返回 ACK,这称为 NACK(非确认)。 通信采用由起始条件、地址、读/写位、ACK/NACK 和停止条件组成的协议进行。 地址可以采用 7 位模式或 10 位模式。 I²C 是一种开漏协议。上拉电阻使 SDA 和 SCL 通常保持高电平,各个器件在需要时将其拉低。因此,通信线路上必须有上拉电阻。 通常使用微控制器作为主设备。有两种方法可以确定通信是否完成:一种是使用从设备的中断,另一种是轮询方法,即主设备反复检查完成标志。使用中断时,每个从设备都必须有一个中断输出,而主设备必须有一个中断输入。使用中断可以加快响应速度,但会增加硬件资源消耗。 有关 I²C 的更多详细信息,请参阅以下文章。 I²C 总线概述(日本博客) 这次,我们将采用轮询方法来匹配评估板的接线情况。 标准模式下的典型传输速度为 100kbps,快速模式下为 400kbps。MCX A153 还支持快速模式增强版,最高通信速度可达 1Mbps。 主设备向从设备发送数据的步骤如下: 主控端发起通信。 主设备指定从设备地址。 从主站向从站发送数据 主控端终止了通信。 相反,主设备从从设备接收数据的过程如下: 主控端发起通信。 主设备指定从设备地址。 主设备从从设备接收数据。 主控端终止了通信。   2.2 微控制器 I²C 模块 下图显示了微控制器中常见的 I²C 模块的框图。 组件数量并不多。主要组件包括用于发送缓冲区的命令/TX FIFO、用于接收缓冲区的RXFIFO、配置寄存器以及控制通信的控制电路。此外,现在大多数微控制器都内置了噪声滤波器。 3. MCX A153 I²C 模块 (LPI2C) 的主要功能和框图   本章要点:我们将研究通用 I²C 和 MCX A153 的 LPI2C 模块之间的区别。   3.1 概述 到目前为止,我们已经介绍了通用 I²C 的基本原理,但本章将重点介绍 MCX A153 的 LPI2C I²C 模块。LPI2C 的功能远比上述基本 I²C 模块强大。LPI2C 支持以主设备(控制器)和从设备(目标设备)两种身份高效地与 I²C 总线连接。 主要功能如下。 支持标准、高速、高速+、HS模式(仅限目标)和超高速运行模式的逻辑。 通过 DMA 将对 FIFO 的访问卸载到 CPU,从而最大限度地减少了 CPU 开销。 LPI2C 也符合系统管理总线 (SMBus) 规范版本 3。 *注1 MCX A153 参考手册中“主站和控制器”以及“从站和目标站”这两个术语交替使用。虽然现在推荐使用“控制器”和“目标站”,但本文档将统一使用“主站和从站”。 3.2 方框图 MCX A153 的 LPI2C 模块上半部分为主控部分,下半部分为从控部分。SDA 和 SCL 模块也分为主控版和从控版,从控版型号后加“S”,因此分别为 SDAS 和 SCLS。通信也可以通过外部 HREQ 端子或内部触发信号启动。 3.3 功能 LPI2C的功能如下: 标准模式、高速模式、高速+模式、超高速模式 多控制器(包括同步和仲裁) 时钟拉伸 仲裁(当系统有多个控制器时) 7位寻址,10位寻址 软件重置、起始字节、设备 ID(还需要软件支持)。 命令和发送 FIFO(4 个字,8 位发送数据 + 3 位命令) 接收到的 FIFO(4 个字,8 位接收数据) 主机请求输入以控制 I²C 总线传输的启动时间 根据接收到的数据匹配情况生成中断,并拒绝不需要的数据。 用于重复启动条件、停止条件、仲裁丢失、意外 NACK 和命令字错误的标志和可选中断信号。 可配置总线空闲超时和引脚堆栈低电平超时。 独立的I²C目标寄存器 7位或10位寻址 支持中断或DMA请求的发送/接收数据寄存器 ACK 或 NACK 可以通过软件控制。 可以配置时钟拉伸来避免发送 FIFO 欠载和接收 FIFO 过载错误。 数据包终止标志和可选的中断、停止条件或位错误检测。 4. 使用的设备和开发工具   4.1 评估委员会 (FRDM-MCXA153) 本次实践练习将使用 Windows PC 和 MCX A153 的FRDM-MCXA153评估套件(使用 MCUXpresso 的 FRDM-MCXA153 开发板 | NXP Semiconductors)。 FRDM-MCXA153 随附一根 USB Type-C 数据线。点击网站上的“设计文件”即可获取 FRDM-MCXA153 的电路板信息和电路图。(需注册账号) FRDM-MCXA153 配备了P3T1755温度传感器。初始状态下,P3T1755 连接到 I3C0,因此这次我们将更改引脚设置,将其连接到 LPI2C,并使用 LPI2C 读取温度。 由于 P3T1755 和 LPI2C 之间没有连接中断线,因此 LPI2C 将用作轮询主控端。此外,由于 MCX A153 和 P3T1755 的信号线上没有上拉电阻,因此需要添加外部电阻。 4.2 开发工具(适用于 VS Code 和 IDE 的 MCUXpresso) 本文将指导您如何使用 MCUXpresso for VS Code 或 MCUXpresso IDE 编辑和运行 SDK 示例。开发工具是创建项目、编辑代码、配置设置和运行应用程序的环境。本文不涉及工具安装或初始设置;请参阅 NXP 官方指南,获取适用于您环境的具体说明。 5. 编程   本章的关键在于首先理解示例代码的工作原理,然后对其进行修改以使其适用于 P3T1755。   5.1 检查基础示例代码的内容 本文提供了几个 I²C 示例程序。 这次,我们将使用示例程序“lpi2c_edma_b2b_polling_master”,该程序采用轮询作为主控端。我们将修改此示例程序,使其能够通过 I²C 接口读取安装在 FRDM-MCXA153 中的 P3T1755 温度传感器的温度数据。 默认情况下,P3T1755 连接到 I3C 模块 I3C0,但我们将修改程序以切换到 LPI2C 模块,并创建一个使用 LPI2C 读取 P3T1755 温度的程序。 在 FRDM-MCXA153 中,P3T1755 和 LPI2C 之间没有连接中断线,因此必须使用 LPI2C 作为轮询主控端。此外,MCX A153 和 P3T1755 之间的连接线没有上拉电阻,因此必须添加一个上拉电阻。 在这个例子中,LPI2C 实例在一个电路板上作为主设备,在另一个电路板上作为从设备。主设备向从设备发送数据,并从从设备接收数据。本示例验证从从设备接收到的数据是否正确。 沟通流程的总体概要如下: 主控单元发送信号开始通信(启动条件)。 主控端发送从控端地址。 从设备向主设备发送信号(确认),表明它已准备好进行通信。 执行数据通信(根据要发送的数据重复执行) 主控单元发出信号结束通信(停止条件)。 进一步分析发现,控制方式有两种:写控制,用于向从设备写入信息;读控制,用于从从设备读取信息。首先执行写控制,然后执行读控制来读取温度数据。 这是使用轮询方式控制主设备的基本步骤。无论从设备是微控制器的 I²C 模块还是温度传感器等传感器 IC,步骤都相同。 [写入控制] 控制写入操作的步骤如下。所使用的函数及其说明列于下方。 ① 发送起始条件 + 从机地址 + 写位: LPI2C_MasterStart:スタート信号とスレーブアドレスを送信。 此功能启动新的主模式传输。 ② 发送目标设备的注册地址和数据: LPI2C_MasterSend:I²Cバスにデータを送信。 该函数会等待缓冲区中的数据发送完毕。 ③ 发送停止条件: LPI2C_MasterStop:I²Cバスにストップ信号を送信。 此函数会等待直到收到停止信号,然后交易才会结束。 等它完成。 [读取控件] 读取控制的步骤如下。所使用的函数及其说明也列于此处。 ① 发送起始条件 + 从机地址 + 写位: LPI2C_MasterStart:スタート信号とスレーブアドレスを送信。 此功能启动新的主模式传输。 ② 发送目标设备的注册地址: LPI2C_MasterRepeatedStart:LPI2C_MasterStart を再度実行する。 该函数通常发送一个寄存器地址。 ③ 发送起始条件 + 从机地址 + 读取位: LPI2C_MasterReceive:I²Cバスからデータを受信。 该函数会等待缓冲区中的数据传输完毕。 ④ 从目标设备接收数据: LPI2C_MasterSend:I²Cバスにデータを送信。 该函数会等待缓冲区中的数据发送完毕。 ⑤ 发送停止条件: LPI2C_MasterStop:I²Cバスにストップ信号を送信。 该函数会一直等待,直到收到停止信号并完成交易。 示例程序“lpi2c_edma_b2b_polling_master”的流程图包含在最后一章末尾的补充说明中,请参考该说明。 此外,虽然MCX A153 API 参考文档中提供了所用函数的解释,但我们已将本示例中使用的函数的解释提取到最后一章末尾的补充说明中。请同时参考该补充说明。 5.2 引脚配置 默认情况下,P3T1755 连接到 I3C 模块的 I3C0 引脚,因此您需要将其更改为 LPI2C 引脚。要更改引脚连接,您可以使用配置工具中的便捷引脚配置器功能。引脚配置器允许您通过图形用户界面 (GUI) 更改引脚分配,甚至可以自动为您生成 C 语言代码。具体操作将在实践练习章节中详细说明。 5.3 程序代码的更改 基本通信流程与示例相同,但从机地址、寄存器地址和数据长度已更改为与 P3T1755 匹配。此外,接收到的 16 位值被转换为温度值。 首先,将从地址更改为 P3T1755 的 0x48U。 示例程序处理 33 字节的数据,但 P3T1755 使用 16 位温度数据,因此我们将数据长度更改为 16 位。 我们定义一个常量来存储从 P3T1755 读取的 16 位温度数据。在这里,我们称之为“温度”。 寄存器地址由 deviceAddress 定义,其值为 0x01U,但在 P3T1755 的情况下,其值为 0x00U。 要传输的数据点数由 txCount 定义,在示例程序中为 0xFFU,但由于从 P3T1755 读取的温度数据为 2 字节(16 位),因此我们将其减少到 0x01U。 在示例程序中,主设备发送数据,从设备发送相同的数据,然后对发送的数据和接收的数据进行比较,但这个过程是不必要的。 相反,需要将从 P3T1755 接收到的数据处理成温度数据。从 P3T1755 接收到的数据为 2 字节(16 位)。接收缓冲区定义为 g_master_rxBuff[1] 和 g_master_rxBuff[0],每个缓冲区包含 1 个字节,因此 g_master_rxBuff[0] 用作高字节,g_master_rxBuff[1] 用作低字节,它们组合成 16 位。组合后的结果存储在 temp 中。 组合温度数据的每一位对应 0.0625°C,因此乘以 0.0625 即可得到温度值。幸运的是,乘以 0.0625 可以通过右移 4 位轻松计算,无需使用浮点运算。计算结果输入到“温度”字段中。 最后,使用 printf 显示主机名。     6. 实践训练   本章重点介绍必要的硬件准备工作以及需要修改 P3T1755 代码的地方,而不是详细介绍工具安装或屏幕操作。   6.1 实践培训内容 此方法使用 LPI2C 读取安装在 FRDM-MCXA153 上的 P3T1755 温度传感器。由于 P3T1755 初始连接到 I3C0,因此需要进行引脚配置才能将其连接到 LPI2C。此外,还必须在 I3C 信号线上添加一个上拉电阻。 该软件基于 LPI2C SDK 示例,对 P3T1755 的从机地址、寄存器地址、数据长度和温度数据的计算过程进行了修改。 6.2 实践培训程序(概述) 将 4.7kΩ 上拉电阻连接到评估板的 SDA 和 SCL 引脚。 在 MCUXpresso 环境下准备一个 LPI2C 示例项目。省略具体的安装和导入步骤。 将引脚设置更改为 P3T1755 所连接的 LPI2C 引脚。 将按照第 6.7 节所示进行以下代码更改。 运行程序并验证是否输出温度值。   6.3 在评估板上添加上拉电阻 P3T1755 的 I²C 总线上有两个结功率放大器 (J20, J21)。将 4.7kΩ 电阻连接到 J20 和 J21,并将 SDA 和 SCL 上拉。 重要的! 内置上拉电阻可能无法提供稳定的通信,具体取决于电路板。为确保通信可靠,请使用外部上拉电阻。 6.4 编码更改 现在我们将把编程章节中解释的概念编写成一个实际的 .c 文件。 现在我们将把“5.3 程序代码的变更”中描述的变更应用到代码中。 (1)将从地址更改为 P3T1755 的 0x48U。 [変更前]#define LPI2C_MASTER_SLAVE_ADDR_7BIT 0x7EU [変更後]#define LPI2C_MASTER_SLAVE_ADDR_7BIT 0x48U (2)将数据长度改为 16 位。 [変更前]#define LPI2C_DATA_LENGTH 33U [変更後]#define LPI2C_DATA_LENGTH 2U (3)定义一个常量“温度”来存储从 P3T1755 读取的 16 位温度数据。 [追加]uint16_t temperature; (4)将寄存器地址 deviceAddress 更改为 0x00U。 [変更前]uint8_t deviceAddress = 0x01U; [変更後]uint8_t deviceAddress = 0x00U; (5)将要传输的数据量 txCount 更改为 0x01U。 [変更前]size_t txCount = 0xFFU; [変更後]size_t txCount = 0x01U; (6)接收数据数量的调整 [変更前]reVal = LPI2C_MasterReceive(EXAMPLE_I2C_MASTER, g_master_rxBuff, LPI2C_DATA_LENGTH - 1); [変更後]reVal = LPI2C_MasterReceive(EXAMPLE_I2C_MASTER, g_master_rxBuff, LPI2C_DATA_LENGTH); (7)删除比较发送数据和接收数据的部分。 [削除] /* Transfer completed. Check the data.*/以下のコード (8)从 P3T1755 接收的数据被合并成温度数据。g_master_rxBuff[0] 的高字节和 g_master_rxBuff[1] 的低字节被合并成一个 16 位数组,合并后的结果存储在 temp 中。 [追加] temp = (((uint16_t) g_master_rxBuff[0] << 8U) | (uint16_t) g_master_rxBuff[1]) >> 4U; (9)将温度值向右移动 4 位,并将其放入温度变量中。 [追加]temperature = temp >> 4; (10)使用 printf 显示温度。 [追加] PRINTF("Temperature=%d", temperature); PRINTF("Celsius"); (11)最后,我们将添加一个无限循环。 [追加]while (1) {} 下面列出了目前为止所做的更改的完整代码,供您参考。   [全部代码] /* * Copyright 2017 NXP * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ /* Standard C Included Files */ #include #include #include "board.h" #include "fsl_debug_console.h" #include "fsl_lpi2c.h" #include "app.h" /******************************************************************************* * Definitions ******************************************************************************/ #define EXAMPLE_I2C_MASTER ((LPI2C_Type *)EXAMPLE_I2C_MASTER_BASE) #define LPI2C_MASTER_SLAVE_ADDR_7BIT 0x48U #define LPI2C_BAUDRATE 100000U #define LPI2C_DATA_LENGTH 2U /******************************************************************************* * Prototypes ******************************************************************************/ /******************************************************************************* * Variables ******************************************************************************/ uint8_t g_master_txBuff[LPI2C_DATA_LENGTH]; uint8_t g_master_rxBuff[LPI2C_DATA_LENGTH]; uint16_t temp; /* 追加 */ uint16_t temperature; /* 追加 */ /******************************************************************************* * Code ******************************************************************************/ /*! * @brief Main function */ int main(void) { lpi2c_master_config_t masterConfig; status_t reVal = kStatus_Fail; uint8_t deviceAddress = 0x00U; size_t txCount = 0x01U; BOARD_InitHardware(); /* Set up i2c master to send data to slave*/ /* First data in txBuff is data length of the transmiting data. */ g_master_txBuff[0] = LPI2C_DATA_LENGTH - 1U; for (uint32_t i = 1U; i < LPI2C_DATA_LENGTH; i++) { g_master_txBuff[i] = i - 1; } for (uint32_t i = 0U; i < LPI2C_DATA_LENGTH - 1U; i++) { if (i % 8 == 0) { } } /* * masterConfig.debugEnable = false; * masterConfig.ignoreAck = false; * masterConfig.pinConfig = kLPI2C_2PinOpenDrain; * masterConfig.baudRate_Hz = 100000U; * masterConfig.busIdleTimeout_ns = 0; * masterConfig.pinLowTimeout_ns = 0; * masterConfig.sdaGlitchFilterWidth_ns = 0; * masterConfig.sclGlitchFilterWidth_ns = 0; */ LPI2C_MasterGetDefaultConfig(&masterConfig); /* Change the default baudrate configuration */ masterConfig.baudRate_Hz = LPI2C_BAUDRATE; /* Initialize the LPI2C master peripheral */ LPI2C_MasterInit(EXAMPLE_I2C_MASTER, &masterConfig, LPI2C_MASTER_CLOCK_FREQUENCY); /* Send master start bit &Slave Address + Write Bit */ if (kStatus_Success == LPI2C_MasterStart(EXAMPLE_I2C_MASTER, LPI2C_MASTER_SLAVE_ADDR_7BIT, kLPI2C_Write)) { LPI2C_MasterGetFifoCounts(EXAMPLE_I2C_MASTER, NULL, &txCount); while (txCount) { LPI2C_MasterGetFifoCounts(EXAMPLE_I2C_MASTER, NULL, &txCount); } if (LPI2C_MasterGetStatusFlags(EXAMPLE_I2C_MASTER) & kLPI2C_MasterNackDetectFlag) { return kStatus_LPI2C_Nak; } reVal = LPI2C_MasterSend(EXAMPLE_I2C_MASTER, &deviceAddress, 1); if (reVal != kStatus_Success) { if (reVal == kStatus_LPI2C_Nak) { LPI2C_MasterStop(EXAMPLE_I2C_MASTER); } return -1; } reVal = LPI2C_MasterSend(EXAMPLE_I2C_MASTER, g_master_txBuff, LPI2C_DATA_LENGTH); if (reVal != kStatus_Success) { if (reVal == kStatus_LPI2C_Nak) { LPI2C_MasterStop(EXAMPLE_I2C_MASTER); } return -1; } reVal = LPI2C_MasterStop(EXAMPLE_I2C_MASTER); if (reVal != kStatus_Success) { return -1; } } for (uint32_t i = 0U; i < WAIT_TIME; i++) { __NOP(); } if (kStatus_Success == LPI2C_MasterStart(EXAMPLE_I2C_MASTER, LPI2C_MASTER_SLAVE_ADDR_7BIT, kLPI2C_Write)) { /* Check master tx FIFO empty or not */ LPI2C_MasterGetFifoCounts(EXAMPLE_I2C_MASTER, NULL, &txCount); while (txCount) { LPI2C_MasterGetFifoCounts(EXAMPLE_I2C_MASTER, NULL, &txCount); } /* Check communicate with slave successful or not */ if (LPI2C_MasterGetStatusFlags(EXAMPLE_I2C_MASTER) & kLPI2C_MasterNackDetectFlag) { return kStatus_LPI2C_Nak; } reVal = LPI2C_MasterSend(EXAMPLE_I2C_MASTER, &deviceAddress, 1); if (reVal != kStatus_Success) { if (reVal == kStatus_LPI2C_Nak) { LPI2C_MasterStop(EXAMPLE_I2C_MASTER); } return -1; } reVal = LPI2C_MasterRepeatedStart(EXAMPLE_I2C_MASTER, LPI2C_MASTER_SLAVE_ADDR_7BIT, kLPI2C_Read); if (reVal != kStatus_Success) { return -1; } reVal = LPI2C_MasterReceive(EXAMPLE_I2C_MASTER, g_master_rxBuff, LPI2C_DATA_LENGTH); if (reVal != kStatus_Success) { if (reVal == kStatus_LPI2C_Nak) { LPI2C_MasterStop(EXAMPLE_I2C_MASTER); } return -1; } reVal = LPI2C_MasterStop(EXAMPLE_I2C_MASTER); if (reVal != kStatus_Success) { return -1; } } for (uint32_t i = 0U; i < LPI2C_DATA_LENGTH; i++) { if (i % 8 == 0) { } } temp = (((uint16_t) g_master_rxBuff[0] << 8U) | (uint16_t) g_master_rxBuff[1]) >> 4U; temperature = temp >> 4; PRINTF("Temperature=%d", temperature); PRINTF("Celsius"); while (1) { } }   6.5 使用引脚配置器更改引脚设置   我们将把目前连接到 P3T1755 的I3C端口重新连接到LPI2C 端口。这是通过MCUXpresso 配置工具中的引脚配置器工具完成的,而不是修改程序代码。 首先,我们将禁用引脚33和34的默认设置,即LPI2C0_SDA和LPI2C0_SCL 。在“引脚”选项卡中,向下滚动以显示引脚33和34。然后,向右滚动以显示LPI2C列。单击LPI2C列中显示的引脚33和34对应的LPI2C0_SDA和LPI2C0_SCL ,即可禁用引脚33和34 。 接下来,在“引脚”选项卡中,将引脚54分配给LPI2C0_SDA 。选中引脚54的复选框将显示分配给该引脚的所有功能。从列表中选择LPI2C0:SDA 。 “引脚”选项卡中的引脚54将变为绿色。单击“完成”以完成分配。 同样,在“引脚”选项卡中,将引脚55分配给LPI2C0_SCL 。选中引脚55的复选框,然后选择LPI2C0:SCL 。“引脚”选项卡中的引脚55将变为绿色。单击“完成”以完成分配。 接下来,我们将配置引脚54和55的功能。要配置这些功能,请使用底部的“布线详情… ”选项。 在“路由详细信息”中,将引脚54 ( LPI2C0_SDA ) 和55 ( LPI2C0_SCL ) 的上拉选择 (Pull Select)设置为Pullup ,并将上拉使能 (Pull Enable)设置为Enabled 。如果将标签设置为I2C_SDA和I2C_SCL ,则需要在 board/pin_mux.h 文件中进行相应设置。它给它增加了一个定义。 引脚配置现已完成。 要反映代码中目前所做的更改,请单击“更新代码”按钮。 6.6 构建与调试、测试功能 代码修改完成后,进行编译。 将鼠标悬停在“项目”上时,会出现一个构建按钮。点击该按钮即可构建项目。 如果看到“构建成功完成”的消息,那就没问题了。 在构建按钮旁边,有一个调试按钮。点击此按钮将进入调试模式。 进入调试模式后,程序会在断点处停止,因此请点击屏幕顶部的“ |▶ ”图标。程序随后会继续运行。 温度将显示在 Tera Term 屏幕上。 总结 本文介绍了I²C通信的基本原理以及MCX A153中安装的LPI2C模块的主要功能。文章还以FRDM-MCXA153中安装的P3T1755温度传感器为例,演示了如何添加上拉电阻、使用引脚配置器配置引脚以及修改LPI2C SDK示例代码。在I²C通信中,根据连接设备的规格配置从机地址、寄存器地址和数据长度至关重要。本文中的信息可用于与各种I²C设备(例如传感器和EEPROM)进行通信。 =========================​ 我们目前无法 回复 此帖子“ 评论”部分留下的评论。 对于由此造成的不便,我们深表歉意,但 在进行咨询时, 请 参考“ NXP 技术问题 - 如何联系我们 ( 日语博客 ) ” 。 (如果您已经是 恩智浦的 分销商或 与 恩智浦 有合作关系 ,您可以直接咨询您的代表。 ) 本文重点介绍恩智浦半导体 (NXP) 微控制器 MCX A153 中包含的 LPI2C(低功耗集成电路间)控制器。在回顾 I²C 的基础知识之后,我们将解释 I²C 和 LPI2C 之间的区别,然后了解 MCX A153 上 LPI2C 的规格和用途。 (阅读时间:30分钟) MCUXpresso IDE MCUXpresso SDK MCX 日本博客
View full article
[MCX A153] LPI2C Beginner's Guide (Japanese Blog) Introduction This article is aimed at beginners in microcontrollers and explains the peripheral functions and usage of the NXP MCX A153 microcontroller. You will learn the basic concepts and implementation methods by actually modifying the SDK sample programs provided by NXP. table of contents   1. Common Usage Examples in Applications (I²C Edition) 1.1 Main Uses 1.2 Usage example 2. Fundamentals of I²C 2.1 What is I²C in the first place? 2.2 Microcontroller I²C Module 3. Main functions and block diagram of the MCX A153 I²C module (LPI2C) 3.1 Overview 3.2 Block Diagram 3.3 Functions 4. Equipment and Development Tools Used 4.1 Evaluation Board (FRDM-MCXA153) 4.2 Development Tools (MCUXpresso for VS Code and IDE) 5. Programming 5.1 Check the contents of the base sample code 5.2 Pin Configuration 5.3 Changes in the program code 6. Practical Training 6.1 Practical Training Content 6.2 Practical Exercise Procedure 6.3 Add pull-up resistors to the evaluation board 6.4 Coding the changes 6.5 Change the pin settings using the PIN configurator 6.6 Build & Debug, Test Functionality   1. Common Usage Examples in Applications (I²C Edition)   Key points of this chapter: We will examine the situations in which I²C is used.   1.1 Main Uses I²C is a communication method that reads and writes data by specifying the register address within a device. Because it uses fewer signal lines, it is suitable for controlling multiple ICs on a single circuit board. However, it is susceptible to wiring capacitance and noise, so it is generally used for short-distance communication. Connection of various sensors such as temperature, acceleration, and magnetic sensors. Digital potentiometer IO Expander EEPROM RTC Input/output expansion for display devices (LCD, LED, etc.) Microcontroller-to-microcontroller communication (included in the sample program on the FRDM-MCXA153 evaluation board) 1.2 Usage example Actual applications include computer motherboards, embedded systems, and mobile phones.   2. Fundamentals of I²C   Key points of this chapter: We will clarify the basic I²C terminology, including SDA, SCL, address, ACK/NACK, and pull-up resistor.   2.1 What is I²C in the first place? I²C is a serial bus communication standard developed by Philips Semiconductors (now NXP Semiconductors). It is now widely used as a representative method for connecting sensors and peripheral ICs on circuit boards. I²C is a synchronous serial communication method that sends data synchronized with a clock. The data line is called SDA, and the clock line is called SCL. Communication is performed by timing SDA to SCL. Each slave has a unique address, and the master communicates by specifying that address. When the address is sent at the start of communication, the target slave returns an ACK (acknowledgment). If an ACK cannot be received, no ACK is returned, which is called a NACK (non-acknowledgment). Communication is performed using a protocol consisting of start condition, address, R/W bits, ACK/NACK, and stop condition. Addresses can be in 7-bit mode or 10-bit mode. I²C is an open-drain protocol. Pull-up resistors keep SDA and SCL normally high, and each device pulls them low when needed. Therefore, pull-up resistors are required on communication lines. A microcontroller is typically used as the master. There are two ways to determine communication completion: using interrupts from the slaves, and a polling method where the master repeatedly checks a completion flag. When using interrupts, each slave must have an interrupt output and the master must have an interrupt input. Using interrupts results in faster response times, but the hardware becomes more resource-intensive. For more detailed information about I²C, please refer to the following article. Overview of the I²C Bus (Japanese Blog) This time, we will use a polling method to match the wiring conditions of the evaluation board. Typical transfer speeds are 100kbps in standard mode and 400kbps in fast mode. The MCX A153 also supports Fast Mode Plus, allowing for communication at a maximum speed of 1Mbps. The procedure for sending data from the master to the slave is as follows: Master initiated communication. The master specifies the slave address. Sending data from master to slave The master terminated the communication. Conversely, the procedure for a master receiving data from a slave is as follows: Master initiated communication. The master specifies the slave address. The master receives data from the slave. The master terminated the communication.   2.2 Microcontroller I²C Module The diagram below shows a block diagram of an I²C module typically found in microcontrollers. The number of components is not that large. The main components are the Command/TX FIFO for the transmit buffer, the RXFIFO for the receive buffer, configuration registers, and the control circuit that controls communication. Furthermore, most microcontrollers nowadays have a built-in noise filter. 3. Main functions and block diagram of the MCX A153 I²C module (LPI2C)   Key points of this chapter: We will examine the differences between general I²C and the LPI2C module of the MCX A153.   3.1 Overview Up to this point, we have explained the basics of general I²C, but in this chapter we will explain the LPI2C I²C module of the MCX A153. LPI2C is far more functional than the basic I²C mentioned above. LPI2C supports efficient interfacing to the I²C bus as both a master (controller) and a slave (target). The main features are listed below. Supports logic for Standard, High Speed, High Speed+, HS Mode (Target Only), and Ultra High Speed operating modes. CPU overhead is minimized by DMA offloading access to the FIFO. LPI2C also complies with the System Management Bus (SMBus) specification version 3. *Note 1 The MCX A153 reference manual uses the terms "master and controller" and "slave and target" interchangeably. While "controller" and "target" are now recommended, we will use "master and slave" consistently in this document. 3.2 Block Diagram The MCX A153's LPI2C module has a master section in the upper half and a slave section in the lower half. The SDA and SCL modules are also divided into master and slave versions, with the slave versions having an "S" appended to them, hence SDAS and SCLS. Communication can also be started using the external HREQ terminal or the internal Trigger signal. 3.3 Functions The functions of LPI2C are as follows: Standard, High Speed, High Speed+, Ultra High Speed Mode Multi-controller (including synchronization and arbitration) Clock stretching Arbitration (when a system has multiple controllers) 7-bit addressing, 10-bit addressing Software reset, start byte, device ID (software support is also required). Command and transmit FIFO (4 words, 8-bit transmit data + 3-bit command) Received FIFO (4 words, 8-bit received data) Host request input for controlling the start time of I²C bus transfer Interrupt generation upon data match and rejection of unwanted data based on received data matching. Flags and optional interrupt signals for repeat start conditions, stop conditions, loss of arbitration, unexpected NACK, and command word errors. configurable bus idle timeout and pin stack low timeout. Independent I²C target registers 7-bit or 10-bit addressing Send/receive data registers that support interrupts or DMA requests ACK or NACK can be controlled by software. Clock stretching can be configured to avoid transmit FIFO underrun and receive FIFO overrun errors. Packet termination flags and optional interrupt, stop condition, or bit error detection. 4. Equipment and Development Tools Used   4.1 Evaluation Board (FRDM-MCXA153) The equipment used for this practical exercise will be a Windows PC and the FRDM-MCXA153 evaluation kit for the MCX A153 (FRDM-MCXA153 Development Board using MCUXpresso | NXP Semiconductors). A USB Type-C cable is included with the FRDM-MCXA153. Board information and circuit diagrams for the FRDM-MCXA153 can be obtained by clicking "Design Files" on the website. (Account registration required) The FRDM-MCXA153 is equipped with a P3T1755 temperature sensor. In its initial state, the P3T1755 is connected to I3C0, so this time we will change the pin settings to connect it to LPI2C and read the temperature using LPI2C. Since there is no interrupt line wired from the P3T1755 to the LPI2C, the LPI2C will be used as a polling master. Also, since there are no pull-up resistors on the signal lines of the MCX A153 and P3T1755, external resistors will be added. 4.2 Development Tools (MCUXpresso for VS Code and IDE) This article will guide you through editing and running SDK samples using MCUXpresso for VS Code or the MCUXpresso IDE. Development tools are the environment for creating projects, editing code, configuring settings, and running applications. This article does not cover tool installation or initial setup; please refer to NXP's official guides for instructions specific to your environment. 5. Programming   The key point of this chapter is to first understand how the sample code works, and then modify it for the P3T1755.   5.1 Check the contents of the base sample code Several sample programs for I²C are provided. This time, we will use the sample program "lpi2c_edma_b2b_polling_master" which uses polling as the master. We will modify this sample program to create a program that reads temperature data from the P3T1755 temperature sensor installed in the FRDM-MCXA153 using I²C. By default, the P3T1755 is connected to the I3C module I3C0, but we will modify the program to switch to the LPI2C module and create a program that uses the LPI2C to read the temperature of the P3T1755. In the FRDM-MCXA153, there is no interrupt line wired from the P3T1755 to the LPI2C, so the LPI2C must be used as the polling master. Also, the wiring connecting the MCX A153 and the P3T1755 does not have a pull-up resistor, so a pull-up resistor must be added. In this example, an LPI2C instance is implemented as a master on one board and as a slave on the other board. The master sends data to the slave and receives data from the slave. This example verifies whether the data received from the slave is correct. The general outline of the communication procedure is as follows: The master unit sends a signal to begin communication (start condition). The master sends the slave address. The slave sends a signal (acknowledgment) to the master indicating that it is ready to communicate. Perform data communication (repeated depending on the data to be sent) The master unit issues a signal to end communication (stop condition). Further breakdown reveals two types of control: Write control, which writes information to the slave, and Read control, which reads information from the slave. First, Write control is performed, followed by Read control to read the temperature data. This is the basic procedure for controlling the master side using polling. It's the same whether the slave is a microcontroller's I²C module or a sensor IC such as a temperature sensor. [Write control] The procedure for controlling the write operation is as follows. The functions used and their explanations are listed below. ① Send Start condition + slave address + write bit: LPI2C_MasterStart:スタート信号とスレーブアドレスを送信。 This function initiates a new master mode transfer. ② Send the register address and data of the target device: LPI2C_MasterSend:I²Cバスにデータを送信。 This function waits until the data in the buffer is sent. ③ Send Stop condition: LPI2C_MasterStop:I²Cバスにストップ信号を送信。 This function waits until a stop signal is sent, and the transaction Wait until it finishes. [Read control] The procedure for Read control is as follows. The functions used and their explanations are also listed here. ① Send Start condition + slave address + write bit: LPI2C_MasterStart:スタート信号とスレーブアドレスを送信。 This function initiates a new master mode transfer. ② Send the register address of the target device: LPI2C_MasterRepeatedStart:LPI2C_MasterStart を再度実行する。 This function typically sends a register address. ③ Send Start condition + slave address + read bit: LPI2C_MasterReceive:I²Cバスからデータを受信。 This function waits until the data in the buffer has been transferred. ④ Receive data from the target device: LPI2C_MasterSend:I²Cバスにデータを送信。 This function waits until the data in the buffer is sent. ⑤ Send Stop condition: LPI2C_MasterStop:I²Cバスにストップ信号を送信。 This function waits until a stop signal is sent and until the transaction is completed. A flowchart for the sample program "lpi2c_edma_b2b_polling_master" is included in the supplementary explanation at the end of the last chapter. Please refer to it. Furthermore, while explanations of the functions used can be found in the MCX A153 API Reference , we have extracted the explanations of the functions used in this example into the supplementary explanations at the end of the last chapter. Please refer to this as well. 5.2 Pin Configuration By default, the P3T1755 is connected to the I3C0 pin of the I3C module, so you need to change this to the LPI2C pin. To change the pin connections, you can use the convenient Pin Configurator function within the Config Tools tool. The Pin Configurator allows you to change pin assignments via a GUI and even automatically generates C language code for you. The specific operation will be explained in detail in the practical exercises chapter. 5.3 Changes in the program code The basic communication flow is the same as the sample, but the slave address, register address, and data length are changed to match the P3T1755. Furthermore, the received 16-bit value is converted to temperature. First, change the slave address to 0x48U of P3T1755. The sample program handles 33 bytes of data, but the P3T1755 uses 16-bit temperature data, so we will change the data length to 16 bits. We define a constant to store the 16-bit temperature data read from the P3T1755. Here, we'll call it "temperature". The register address is defined by deviceAddress, which is 0x01U, but in the case of P3T1755 it is 0x00U. The number of data points to transfer is defined by txCount, which is 0xFFU in the sample program, but since the temperature data read from the P3T1755 is 2 bytes (16 bits), we reduce it to 0x01U. In the sample program, the master sends data and the slave sends the same data back, and then a comparison of the transmitted and received data is performed, but this process is unnecessary. Instead, it is necessary to process the data received from the P3T1755 into temperature data. The data received from the P3T1755 is 2 bytes (16 bits). The receive buffer is defined as g_master_rxBuff[1] and g_master_rxBuff[0], each containing 1 byte, so g_master_rxBuff[0] is used as the upper byte and g_master_rxBuff[1] as the lower byte, and they are combined into 16 bits. The combined result is stored in temp. Each bit of the combined temperature data corresponds to 0.0625°C, so multiplying by 0.0625 gives the temperature. Fortunately, multiplying by 0.0625 can be easily calculated by shifting 4 bits to the right, without using floating-point arithmetic. The calculation result is entered into the 'temperature' field. Finally, display the host using printf.     6. Practical Training   This chapter focuses on the necessary hardware preparations and the points where you need to modify the code for the P3T1755, rather than detailing tool installation or screen operations.   6.1 Practical Training Content This method reads the P3T1755 temperature sensor mounted on the FRDM-MCXA153 using LPI2C. Since the P3T1755 is initially connected to I3C0, pin configuration is required to connect it to LPI2C. Additionally, a pull-up resistor must be added to the I3C signal line. The software is based on the LPI2C SDK sample, with modifications to the calculation process for the P3T1755's slave address, register address, data length, and temperature data. 6.2 Practical Training Procedure (Overview) Connect 4.7kΩ pull-up resistors to the SDA and SCL pins of the evaluation board. Prepare a sample LPI2C project in the MCUXpresso environment. Specific installation and import procedures are omitted. Change the pin settings to the LPI2C pins to which the P3T1755 is connected. The following code changes will be made as shown in Section 6.7. Run the program and verify that a temperature value is output.   6.3 Add pull-up resistors to the evaluation board The P3T1755 has Junction PAs (J20, J21) on its I²C line. Connect 4.7kΩ resistors to J20 and J21, and pull up SDA and SCL. important! The built-in pull-up resistor may not provide stable communication depending on the board. To ensure reliable communication, please use an external pull-up resistor. 6.4 Coding the changes We will now code the concepts explained in the programming chapter into an actual .c file. We will now implement the changes described in "5.3 Changes to the Program Code" into the code. (1) Change the slave address to 0x48U of P3T1755. [変更前]#define LPI2C_MASTER_SLAVE_ADDR_7BIT 0x7EU [変更後]#define LPI2C_MASTER_SLAVE_ADDR_7BIT 0x48U (2) Change the data length to 16 bits. [変更前]#define LPI2C_DATA_LENGTH 33U [変更後]#define LPI2C_DATA_LENGTH 2U (3) Define a constant `temperature` to store the 16 bits of temperature data read from the P3T1755. [追加]uint16_t temperature; (4) Change the register address deviceAddress to 0x00U. [変更前]uint8_t deviceAddress = 0x01U; [変更後]uint8_t deviceAddress = 0x00U; (5) Change the number of data to be transferred, txCount, to 0x01U. [変更前]size_t txCount = 0xFFU; [変更後]size_t txCount = 0x01U; (6) Adjustment of the number of received data [変更前]reVal = LPI2C_MasterReceive(EXAMPLE_I2C_MASTER, g_master_rxBuff, LPI2C_DATA_LENGTH - 1); [変更後]reVal = LPI2C_MasterReceive(EXAMPLE_I2C_MASTER, g_master_rxBuff, LPI2C_DATA_LENGTH); (7) Remove the section comparing the transmitted data and the received data. [削除] /* Transfer completed. Check the data.*/以下のコード (8) The data received from P3T1755 is combined into temperature data. The upper byte of g_master_rxBuff[0] and the lower byte of g_master_rxBuff[1] are combined into a 16-bit array, and the combined result is stored in temp. [追加] temp = (((uint16_t) g_master_rxBuff[0] << 8U) | (uint16_t) g_master_rxBuff[1]) >> 4U; (9) Shift temp to the right by 4 bits and put it into temperature. [追加]temperature = temp >> 4; (10) Display the temperature using printf. [追加] PRINTF("Temperature=%d", temperature); PRINTF("Celsius"); (11) Finally, we'll add an infinite loop. [追加]while (1) {} The complete code reflecting the changes made so far is shown below for reference.   [All Code] /* * Copyright 2017 NXP * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ /* Standard C Included Files */ #include #include #include "board.h" #include "fsl_debug_console.h" #include "fsl_lpi2c.h" #include "app.h" /******************************************************************************* * Definitions ******************************************************************************/ #define EXAMPLE_I2C_MASTER ((LPI2C_Type *)EXAMPLE_I2C_MASTER_BASE) #define LPI2C_MASTER_SLAVE_ADDR_7BIT 0x48U #define LPI2C_BAUDRATE 100000U #define LPI2C_DATA_LENGTH 2U /******************************************************************************* * Prototypes ******************************************************************************/ /******************************************************************************* * Variables ******************************************************************************/ uint8_t g_master_txBuff[LPI2C_DATA_LENGTH]; uint8_t g_master_rxBuff[LPI2C_DATA_LENGTH]; uint16_t temp; /* 追加 */ uint16_t temperature; /* 追加 */ /******************************************************************************* * Code ******************************************************************************/ /*! * @brief Main function */ int main(void) { lpi2c_master_config_t masterConfig; status_t reVal = kStatus_Fail; uint8_t deviceAddress = 0x00U; size_t txCount = 0x01U; BOARD_InitHardware(); /* Set up i2c master to send data to slave*/ /* First data in txBuff is data length of the transmiting data. */ g_master_txBuff[0] = LPI2C_DATA_LENGTH - 1U; for (uint32_t i = 1U; i < LPI2C_DATA_LENGTH; i++) { g_master_txBuff[i] = i - 1; } for (uint32_t i = 0U; i < LPI2C_DATA_LENGTH - 1U; i++) { if (i % 8 == 0) { } } /* * masterConfig.debugEnable = false; * masterConfig.ignoreAck = false; * masterConfig.pinConfig = kLPI2C_2PinOpenDrain; * masterConfig.baudRate_Hz = 100000U; * masterConfig.busIdleTimeout_ns = 0; * masterConfig.pinLowTimeout_ns = 0; * masterConfig.sdaGlitchFilterWidth_ns = 0; * masterConfig.sclGlitchFilterWidth_ns = 0; */ LPI2C_MasterGetDefaultConfig(&masterConfig); /* Change the default baudrate configuration */ masterConfig.baudRate_Hz = LPI2C_BAUDRATE; /* Initialize the LPI2C master peripheral */ LPI2C_MasterInit(EXAMPLE_I2C_MASTER, &masterConfig, LPI2C_MASTER_CLOCK_FREQUENCY); /* Send master start bit &Slave Address + Write Bit */ if (kStatus_Success == LPI2C_MasterStart(EXAMPLE_I2C_MASTER, LPI2C_MASTER_SLAVE_ADDR_7BIT, kLPI2C_Write)) { LPI2C_MasterGetFifoCounts(EXAMPLE_I2C_MASTER, NULL, &txCount); while (txCount) { LPI2C_MasterGetFifoCounts(EXAMPLE_I2C_MASTER, NULL, &txCount); } if (LPI2C_MasterGetStatusFlags(EXAMPLE_I2C_MASTER) & kLPI2C_MasterNackDetectFlag) { return kStatus_LPI2C_Nak; } reVal = LPI2C_MasterSend(EXAMPLE_I2C_MASTER, &deviceAddress, 1); if (reVal != kStatus_Success) { if (reVal == kStatus_LPI2C_Nak) { LPI2C_MasterStop(EXAMPLE_I2C_MASTER); } return -1; } reVal = LPI2C_MasterSend(EXAMPLE_I2C_MASTER, g_master_txBuff, LPI2C_DATA_LENGTH); if (reVal != kStatus_Success) { if (reVal == kStatus_LPI2C_Nak) { LPI2C_MasterStop(EXAMPLE_I2C_MASTER); } return -1; } reVal = LPI2C_MasterStop(EXAMPLE_I2C_MASTER); if (reVal != kStatus_Success) { return -1; } } for (uint32_t i = 0U; i < WAIT_TIME; i++) { __NOP(); } if (kStatus_Success == LPI2C_MasterStart(EXAMPLE_I2C_MASTER, LPI2C_MASTER_SLAVE_ADDR_7BIT, kLPI2C_Write)) { /* Check master tx FIFO empty or not */ LPI2C_MasterGetFifoCounts(EXAMPLE_I2C_MASTER, NULL, &txCount); while (txCount) { LPI2C_MasterGetFifoCounts(EXAMPLE_I2C_MASTER, NULL, &txCount); } /* Check communicate with slave successful or not */ if (LPI2C_MasterGetStatusFlags(EXAMPLE_I2C_MASTER) & kLPI2C_MasterNackDetectFlag) { return kStatus_LPI2C_Nak; } reVal = LPI2C_MasterSend(EXAMPLE_I2C_MASTER, &deviceAddress, 1); if (reVal != kStatus_Success) { if (reVal == kStatus_LPI2C_Nak) { LPI2C_MasterStop(EXAMPLE_I2C_MASTER); } return -1; } reVal = LPI2C_MasterRepeatedStart(EXAMPLE_I2C_MASTER, LPI2C_MASTER_SLAVE_ADDR_7BIT, kLPI2C_Read); if (reVal != kStatus_Success) { return -1; } reVal = LPI2C_MasterReceive(EXAMPLE_I2C_MASTER, g_master_rxBuff, LPI2C_DATA_LENGTH); if (reVal != kStatus_Success) { if (reVal == kStatus_LPI2C_Nak) { LPI2C_MasterStop(EXAMPLE_I2C_MASTER); } return -1; } reVal = LPI2C_MasterStop(EXAMPLE_I2C_MASTER); if (reVal != kStatus_Success) { return -1; } } for (uint32_t i = 0U; i < LPI2C_DATA_LENGTH; i++) { if (i % 8 == 0) { } } temp = (((uint16_t) g_master_rxBuff[0] << 8U) | (uint16_t) g_master_rxBuff[1]) >> 4U; temperature = temp >> 4; PRINTF("Temperature=%d", temperature); PRINTF("Celsius"); while (1) { } }   6.5 Change the pin settings using the PIN Configurator   We will reconnect the I3C port currently connected to the P3T1755 to the LPI2C port . This is done using the Pin Configurator tool within MCUXpresso Config Tools , rather than modifying the program code. First, we will disable the default settings of pins 33 and 34 , which are LPI2C0_SDA and LPI2C0_SCL . In the Pins tab, scroll down to display pins 33 and 34. Then, scroll to the right to display the LPI2C column. Clicking on LPI2C0_SDA and LPI2C0_SCL , respectively, displayed in the LPI2C column for pins 33 and 34 will disable pins 33 and 34 . Next, in the Pins tab, assign pin 54 to LPI2C0_SDA . Clicking the checkbox for pin 54 will display all the functions assigned to that pin. Select LPI2C0:SDA from the list. Pin 54 in the Pins tab will then turn green. Click " Done " to complete the assignment. Similarly, in the Pins tab, assign pin 55 to LPI2C0_SCL . Click the checkbox for pin 55 and select LPI2C0:SCL . Pin 55 in the Pins tab will then turn green. Click " Done " to complete the assignment. Next, we will configure the functions of pins 54 and 55. To configure the functions, use " Routing Details for… " located at the bottom. In Routing Details for…, change the Pull Select for pins 54 ( LPI2C0_SDA ) and 55 ( LPI2C0_SCL ) to Pullup , and change Pull enable to Enabled . If you set the Label to I2C_SDA and I2C_SCL , then in board/pin_mux.hIt adds a definition to it. The pin configuration is now complete. To reflect the changes made so far in the code, click the Update Code button. 6.6 Build & Debug, Test Functionality Once you've finished changing the code, build it. When you hover your cursor over "Projects," a build button will appear. Clicking it will build the project. If you see the message " build finished successfully, " then it's OK . Next to the build button, there's a debug button. Clicking this will enter debug mode. When you enter debug mode, the program stops at the breakpoint, so click the " |▶ " icon at the top of the screen. The program will then run. The temperature will be displayed on the Tera Term screen. summary This article explained the basic I²C communication method and the main functions of the LPI2C module installed in the MCX A153. It also demonstrated how to add pull-up resistors, configure pins using the Pin Configurator, and modify the LPI2C SDK sample code, using the P3T1755 temperature sensor installed in the FRDM-MCXA153 as an example. In I²C communication, it is crucial to configure the slave address, register address, and data length according to the specifications of the connected device. Please use the information in this article to apply it to communication with various I²C devices such as sensors and EEPROMs. =========================​ We are currently unable to respond to comments left in the " Comment " section of this post . We apologize for the inconvenience, but please refer to " Technical Questions to NXP - How to Contact Us( Japanese Blog) " when making inquiries.(If you are already an NXP distributor or have a relationship with NXP, you may ask your representative directly.) This article focuses on the LPI2C (Low Power Inter-Integrated Circuit) controller included in the NXP microcontroller MCX A153. After reviewing the basics of I²C, we will explain the differences between I²C and LPI2C, and then learn about the specifications and usage of the LPI2C on the MCX A153. (Reading time: 30 minutes) MCUXpresso IDE MCUXpresso SDK MCX Japanese Blog
View full article
[MCX A153] LPI2C入門ガイド (日本語ブログ) はじめに 本記事はマイコン初心者を対象に、NXPマイコン MCX A153の周辺機能と使い方を解説し、NXPが提供するSDKサンプルプログラムを実際に変更しながら、基本的な考え方と実装方法を学びます。 目次   1. アプリケーション上のよくある使い方の例(I²C編) 1.1 主な用途 1.2 使用例 2. I²Cの基礎 2.1 そもそもI²Cとは 2.2 マイコンのI²Cモジュール 3. MCX A153 I²Cモジュール(LPI2C)の主な機能とブロック図 3.1 概要 3.2 ブロック図 3.3 機能 4. 使用機材と開発ツール 4.1 評価ボード(FRDM-MCXA153) 4.2 開発ツール(MCUXpresso for VS CodeとIDE) 5. プログラミング 5.1 ベースとなるサンプルコードの内容を確認する 5.2 ピン設定 5.3 プログラムコードの変更点 6. 実習 6.1 実習内容 6.2 実習手順 6.3 評価ボードにプルアップ抵抗を付ける 6.4 変更点のコーディング 6.5 PIN configuratorを使ってピン設定を変更 6.6 ビルド&デバッグ、動作確認   1. アプリケーション上のよくある使い方の例(I²C編)   この章のポイント:I²Cがどのような場面で使われるかを確認します。   1.1 主な用途 I²Cは、デバイス内のレジスタアドレスを指定してデータを読み書きする通信方式です。信号線が少ないため、1枚の基板上で複数のICを制御する用途に向いています。一方、配線容量やノイズの影響を受けやすいため、一般には短距離の通信に使います。 温度・加速度・磁気センサーなどの各種センサー接続 デジタルポテンショメータ IOエキスパンダ EEPROM RTC 表示用デバイス(LCD、LEDなど)の入出力拡張 マイコン間通信(FRDM-MCXA153評価ボードのサンプルプログラムにあります) 1.2 使用例 実際の使用例は、パソコンのマザーボード、組み込みシステム、携帯電話などです。   2. I²Cの基礎   この章のポイント:SDA、SCL、アドレス、ACK/NACK、プルアップ抵抗というI²Cの基本用語を整理します。   2.1 そもそもI²Cとは I²Cは、Philips Semiconductors社(現在のNXP Semiconductors社)が開発したシリアルバス通信規格です。現在では、基板上のセンサーや周辺ICを接続する代表的な方式として広く使われています。 I²Cは、クロックに同期してデータを送る同期式シリアル通信です。データ線をSDA、クロック線をSCLと呼び、SDAをSCLのタイミングに合わせて通信します。 各スレーブは固有のアドレスを持ち、マスターはそのアドレスを指定して通信します。通信開始時にアドレスを送ると、対象のスレーブがACK(アクノリッジ)を返します。受信できない場合はACKを返さず、これをNACK(ナック)と呼びます。 スタートコンディション、アドレス、R/Wビット、ACK/NACK、ストップコンディションというプロトコルで通信します。 アドレスには7ビットモードと10ビットモードがあります。 I²Cはオープンドレイン方式です。プルアップ抵抗によってSDAとSCLを通常Highに保ち、各デバイスが必要なタイミングでLowに引き下げます。そのため、通信ラインにはプルアップ抵抗が必要です。 マスターには通常マイコンを使います。通信完了を知る方法には、スレーブからの割り込みを使う方法と、マスターが完了フラグを繰り返し確認するポーリング方式があります。割り込みを使う時には、各スレーブに割り込み出力、マスターに割り込み入力を設けなければなりません。割り込みを使う場合の方が、レスポンスが速いですが、ハードウェアが重くなります。 I²Cについて、より詳しく知りたい方は以下の記事をご参考ください。 I²Cバスの概要 (日本語ブログ) 今回は、評価ボードの配線条件に合わせてポーリング方式を使います。 代表的な転送速度は、標準モードが100kbps、ファストモードが400kbpsです。MCX A153はファストモードプラスにも対応し、最大1Mbpsで通信できます。 マスターからスレーブにデータを送信する場合の手順は次のようになります。 マスターが通信を開始 マスターがスレーブアドレスを指定 マスターからスレーブにデータを送信 マスターが通信を終了 逆に、マスターがスレーブからデータを受信する場合の手順は次のようになります。 マスターが通信を開始 マスターがスレーブアドレスを指定 マスターがスレーブからデータを受信する マスターが通信を終了   2.2 マイコンのI²Cモジュール 下図に一般的なマイコンに搭載されているI²Cモジュールのブロック図を示します。 構成ブロックはそんなに多くありません。送信バッファのCommand/TX FIFO、受信バッファのRXFIFO、設定用レジスタと、通信を制御する制御回路が主なブロックです。さらに、最近では、ほとんどのマイコンでノイズフィルタが内蔵されています。 3. MCX A153 I²Cモジュール(LPI2C)の主な機能とブロック図   この章のポイント:一般的なI²Cと、MCX A153のLPI2Cモジュールの違いを確認します。   3.1 概要 ここまで、一般的なI²Cの基礎知識を説明しましたが、この章では、MCX A153のI²CモジュールLPI2Cについて説明します。LPI2Cは前述した基本的なI²Cよりはるかに高機能です。LPI2Cは、マスター(コントローラ)およびスレーブ(ターゲット)としてI²Cバスへの効率的なインターフェースをサポートします。 以下に、主な特長を挙げます。 標準、高速、高速+、HSモード(ターゲットのみ)、超高速の各動作モードのロジックをサポート。 FIFOへのアクセスをDMAオフロードすることで、CPUオーバーヘッドを最小限に抑える。 LPI2Cは、システム管理バス(SMBus)仕様バージョン3にも準拠。 ※注1 MCX A153のリファレンスマニュアルの中では、「マスターとコントローラ」、「スレーブとターゲット」という言葉が混在して使われています。現在では「コントローラ」「ターゲット」が推奨されていますが、今回は、マスターとスレーブで統一します。 3.2 ブロック図 MCX A153のLPI2Cモジュールは、上半分がマスター、下半分がスレーブになっています。SDAとSCLもマスター用とスレーブ用に分かれており、スレーブ用には添え字にSが付いているので、SDASとSCLSになります。また、外部端子HREQや内部信号Triggerで通信をスタートすることができます。 3.3 機能 LPI2Cの機能は以下の通りです。 標準、高速、高速+、超高速モード マルチコントローラ(同期およびアービトレーションを含む) クロックストレッチング アービトレーション(システムに複数のコントローラが存在する場合) 7ビットアドレッシング、10ビットアドレッシング ソフトウェアリセット、スタートバイト、デバイスID(ソフトウェアサポートも必要) コマンドおよび送信FIFO(4ワード、8ビット送信データ+3ビットコマンド) 受信FIFO(4ワード、8ビット受信データ) I²Cバス転送の開始時間を制御するためのホスト要求入力 受信データマッチングによる、データ一致時および不要なデータ拒否時の割り込み生成 繰り返し開始条件、停止条件、アービトレーションの喪失、予期しないNACK、およびコマンドワードエラー時のフラグとオプションの割り込み信号 設定可能なバスアイドルタイムアウトおよびピンスタックロータイムアウト 独立したI²Cターゲットレジスタ 7ビットまたは10ビットのアドレス指定 割り込みまたはDMA要求をサポートする送/受信データレジスタ ACKまたはNACKをソフトウェアで制御可能 送信FIFOアンダーランおよび受信FIFOオーバーランエラーを回避するためのクロックストレッチング設定可能 パケット終了時のフラグおよびオプションの割り込み、ストップコンディション、またはビットエラー検出 4. 使用機材と開発ツール   4.1 評価ボード(FRDM-MCXA153) 今回の実習に使用する機材は、Windows PCとMCX A153用の評価キットFRDM-MCXA153(FRDM-MCXA153 Development Board using MCUXpresso | NXP Semiconductors )です。 USB Type-CケーブルはFRDM-MCXA153に同梱されています。FRDM-MCXA153の基板情報や回路については、Webの「デザイン・ファイル」をクリックすると入手できます。(アカウント登録が必要) FRDM-MCXA153には温度センサーP3T1755が搭載されています。初期状態ではP3T1755がI3C0に接続されているため、今回はピン設定を変更してLPI2Cに接続し、LPI2Cで温度を読み出します。 P3T1755からLPI2Cへの割り込みラインは配線されていないため、LPI2Cはポーリング方式のマスターとして使います。また、MCX A153とP3T1755の信号線にはプルアップ抵抗がないため、外付け抵抗を追加します。 4.2 開発ツール(MCUXpresso for VS CodeとIDE) 本記事では、MCUXpresso for VS CodeまたはMCUXpresso IDEを使って、SDKサンプルを編集・実行します。開発ツールは、プロジェクトの作成、コード編集、設定、実行を行うための環境です。ツールのインストール方法や初期設定は、本記事では扱いません。使用する環境に合わせて、NXPの公式ガイドを参照してください。 5. プログラミング   この章のポイント:まずサンプルコードの動きを理解し、その後にP3T1755用へ変更します。   5.1 ベースとなるサンプルコードの内容を確認する I²Cのサンプルプログラムとしていくつかのプログラムが準備されています。 今回は、ポーリングを使ったマスターの「lpi2c_edma_b2b_polling_master」のサンプルプログラムを使います。このサンプルプログラムを変更して、FRDM-MCXA153に搭載されている温度センサーのP3T1755からI²Cを使って温度データを読み取るプログラムを作ります。 デフォルトだと、P3T1755にはI3CモジュールI3C0がつながっていますが、プログラムを変更することでLPI2Cにつなぎ変えて、LPI2Cを使ってP3T1755の温度を読み出すプログラムを作ります。 FRDM-MCXA153では、P3T1755からLPI2Cに割り込みラインは配線されていないため、LPI2Cはポーリングのマスターで使わなければなりません。また、MCX A153とP3T1755をつなぐ配線にはプルアップ抵抗が付いていないため、プルアップ抵抗を追加します。 このサンプルでは、一方のボードに lpi2cインスタンスをマスターとして、もう一方のボードに lpi2cインスタンスをスレーブとして実装します。マスターはスレーブにデータを送信し、スレーブからデータを受信します。このサンプルでは、スレーブから受信したデータが正しいかどうかを確認します。 通信手順の概略は、次のようになります。 マスターから通信開始の合図(スタートコンディション)を送信 マスターからスレーブアドレスを送信 スレーブからマスターに通信可能の合図(アクノリッジ)を返す データの通信を行う (送信データに応じて繰り返す) マスターから通信終了の合図(ストップコンディション)を出す さらに細かく分けると、スレーブに情報を書き込むWrite制御と、スレーブから情報を読み出すRead制御の2つに分けられます。最初にWrite制御を行い、次にRead制御を行い、温度データを読み出します。 ポーリングを使ったマスター側の制御としては、これが基本手順です。スレーブがマイコンのI²Cモジュールだろうが、温度センサーなどのセンサーICだろうが、同じです。 [Write制御] Write制御の手順は、次のようになります。使用する関数と説明を記載します。 ①Start コンディション + スレーブアドレス + ライトビット を送信: LPI2C_MasterStart:スタート信号とスレーブアドレスを送信。 この関数は新しいマスターモード転送を開始する。 ②ターゲットデバイスのレジスタアドレスとデータを送信: LPI2C_MasterSend:I²Cバスにデータを送信。 この関数はバッファのデータを送信するまで待機する。 ③Stop コンディションを送信: LPI2C_MasterStop:I²Cバスにストップ信号を送信。 この関数はストップ信号が送信されるまで待機し、トランザクション が終了するまで待機する。 [Read制御] Read制御の手順は、次のようになります。ここでも使用する関数と説明を記載します。 ①Startコンディション + スレーブアドレス + ライトビットを送信: LPI2C_MasterStart:スタート信号とスレーブアドレスを送信。 この関数は新しいマスターモード転送を開始する。 ②ターゲットデバイスのレジスタアドレスを送信: LPI2C_MasterRepeatedStart:LPI2C_MasterStart を再度実行する。 この関数では通常、レジスタアドレスを送る ③Startコンディション + スレーブアドレス + リードビットを送信: LPI2C_MasterReceive:I²Cバスからデータを受信。 この関数はバッファのデータを転送するまで待機する。 ④ターゲットデバイスのデータを受信: LPI2C_MasterSend:I²Cバスにデータを送信。 この関数はバッファのデータを送信するまで待機する。 ⑤Stop コンディションを送信: LPI2C_MasterStop:I²Cバスにストップ信号を送信。 この関数はストップ信号が送信されるまで待機し、トランザクションが終了するまで待機する。 サンプルプログラム「lpi2c_edma_b2b_polling_master」のフローチャートを、最後の章の補足説明に載せておきました。参考にしてください。 また、使用されている関数の説明は MCX A153 API Reference にありますが、今回使用する関数の説明を最後の章の補足説明に抜き出しました。こちらも参考にしてください。 5.2 ピン設定 P3T1755は、デフォルトだとI3CモジュールのI3C0がつながっていますので、これをLPI2Cにつなぎ変える必要があります。ピン接続の変さらにはConfig Tools というツールの中の、Pin Configuratorという便利な機能を使います。Pin Configuratorを使うと、GUIでピン割り当てを変更できて、さらに自動でC言語コードまで作ってくれます。具体的な操作は実習の章で詳しく説明します。 5.3 プログラムコードの変更点 通信の基本的な流れはサンプルと同じですが、P3T1755に合わせて、スレーブアドレス、レジスタアドレス、データ長を変更します。さらに、受信した16ビット値を温度へ変換します。 まず、スレーブアドレスをP3T1755の0x48Uに変更します サンプルプログラムでは扱うデータが33バイトですが、P3T1755の場合は16ビットの温度データですので、データ長を16ビットに変更します P3T1755から読み出す温度データ16ビットを入れる定数を定義します。ここではtemperatureとします レジスタアドレスは、deviceAddressで定義されていて、0x01Uですが、P3T1755の場合は0x00Uです 転送するデータの数をtxCountで定義していて、サンプルプログラムでは0xFFUですが、P3T1755から読み出す温度データは2バイト(16ビット)なので、0x01Uに減らします サンプルプログラムでは、マスターが送信したデータと同じデータがスレーブから返ってきて、送受信データの比較を行っていますが、ここの処理は不要です その代わりにP3T1755から受信したデータを温度データとしてまとめる処理が必要です。P3T1755から受信するデータは2バイト(16ビット)です。受信バッファはg_master_rxBuff[1]とg_master_rxBuff[0]で定義しており、各々1バイトが入りますので、 g_master_rxBuff[0]を上位バイト、g_master_rxBuff[1]を下位バイトとして 16 ビットに結合します。結合結果をtempに入れます 結合した温度データの1ビットが0.0625℃に相当しますので、0.0625倍すると温度が得られます。幸いにも0.0625倍は、浮動小数点演算など使わずに、右に4ビットシフトすると簡単に計算できます。計算結果はtemperatureに入れます 最後にtemperatureをprintfで表示します     6. 実習   この章では、ツールのインストールや画面操作の詳細ではなく、必要なハードウェア準備と、P3T1755用にコードを変更するポイントに集中します。   6.1 実習内容 FRDM-MCXA153に搭載されたP3T1755温度センサーを、LPI2Cで読み出します。P3T1755は初期状態ではI3C0に接続されているため、LPI2Cへ接続するピン設定が必要です。また、I²C信号線にはプルアップ抵抗を追加します。 ソフトウェアでは、LPI2CのSDKサンプルをベースに、P3T1755のスレーブアドレス、レジスタアドレス、データ長、温度データの計算処理を変更します。 6.2 実習手順(概要) 評価ボードのSDA・SCLに4.7kΩのプルアップ抵抗を接続します。 MCUXpresso環境でLPI2Cのサンプルプロジェクトを準備します。具体的なインストール・インポート手順は省略します。 ピン設定を、P3T1755が接続されているLPI2C用のピンへ変更します。 次の6.7節に示すコード変更を行います。 プログラムを実行し、温度値が出力されることを確認します。   6.3 評価ボードにプルアップ抵抗を付ける P3T1755のI²CラインにはJunction PA(J20、J21)が設けられています。J20とJ21に4.7kΩの抵抗を付け、SDAとSCLをプルアップ接続してください。 重要! 内蔵プルアップだけでは、ボードによって通信が安定しない場合があります。確実に通信するため、外付けのプルアップ抵抗を使用してください。 6.4 変更点のコーディング プログラミングの章で説明した内容を、実際の.cファイルにコーディングします。 「5.3 プログラムコードの変更点」で説明した変更内容を、コードに反映していきます。 (1)スレーブアドレスをP3T1755の0x48Uに変更する。 [変更前]#define LPI2C_MASTER_SLAVE_ADDR_7BIT 0x7EU [変更後]#define LPI2C_MASTER_SLAVE_ADDR_7BIT 0x48U (2)データ長を16ビットに変更する。 [変更前]#define LPI2C_DATA_LENGTH 33U [変更後]#define LPI2C_DATA_LENGTH 2U (3)P3T1755から読み出す温度データ16ビットを入れる定数temperatureを定義する。 [追加]uint16_t temperature; (4)レジスタアドレスdeviceAddressを0x00Uに変更する。 [変更前]uint8_t deviceAddress = 0x01U; [変更後]uint8_t deviceAddress = 0x00U; (5)転送データ数txCountを0x01Uに変更する。 [変更前]size_t txCount = 0xFFU; [変更後]size_t txCount = 0x01U; (6)受信データの数の調整 [変更前]reVal = LPI2C_MasterReceive(EXAMPLE_I2C_MASTER, g_master_rxBuff, LPI2C_DATA_LENGTH - 1); [変更後]reVal = LPI2C_MasterReceive(EXAMPLE_I2C_MASTER, g_master_rxBuff, LPI2C_DATA_LENGTH); (7)送信データと受信データの比較部分を削除。 [削除] /* Transfer completed. Check the data.*/以下のコード (8)P3T1755から受信したデータを温度データとしてまとめる。g_master_rxBuff[0]を上位バイト、g_master_rxBuff[1]を下位バイトとして 16 ビットに結合し、結合結果をtempに入れる。 [追加] temp = (((uint16_t) g_master_rxBuff[0] << 8U) | (uint16_t) g_master_rxBuff[1]) >> 4U; (9)tempを右に4ビットシフトしてtemperatureに入れる。 [追加]temperature = temp >> 4; (10)temperatureをprintfで表示します。 [追加] PRINTF("Temperature=%d", temperature); PRINTF("Celsius"); (11)最後には、無限ループを入れておきます。 [追加]while (1) {} ここまでの変更を反映した全コードを、参考として以下に示します。   [全コード] /* * Copyright 2017 NXP * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ /* Standard C Included Files */ #include #include #include "board.h" #include "fsl_debug_console.h" #include "fsl_lpi2c.h" #include "app.h" /******************************************************************************* * Definitions ******************************************************************************/ #define EXAMPLE_I2C_MASTER ((LPI2C_Type *)EXAMPLE_I2C_MASTER_BASE) #define LPI2C_MASTER_SLAVE_ADDR_7BIT 0x48U #define LPI2C_BAUDRATE 100000U #define LPI2C_DATA_LENGTH 2U /******************************************************************************* * Prototypes ******************************************************************************/ /******************************************************************************* * Variables ******************************************************************************/ uint8_t g_master_txBuff[LPI2C_DATA_LENGTH]; uint8_t g_master_rxBuff[LPI2C_DATA_LENGTH]; uint16_t temp; /* 追加 */ uint16_t temperature; /* 追加 */ /******************************************************************************* * Code ******************************************************************************/ /*! * @brief Main function */ int main(void) { lpi2c_master_config_t masterConfig; status_t reVal = kStatus_Fail; uint8_t deviceAddress = 0x00U; size_t txCount = 0x01U; BOARD_InitHardware(); /* Set up i2c master to send data to slave*/ /* First data in txBuff is data length of the transmiting data. */ g_master_txBuff[0] = LPI2C_DATA_LENGTH - 1U; for (uint32_t i = 1U; i < LPI2C_DATA_LENGTH; i++) { g_master_txBuff[i] = i - 1; } for (uint32_t i = 0U; i < LPI2C_DATA_LENGTH - 1U; i++) { if (i % 8 == 0) { } } /* * masterConfig.debugEnable = false; * masterConfig.ignoreAck = false; * masterConfig.pinConfig = kLPI2C_2PinOpenDrain; * masterConfig.baudRate_Hz = 100000U; * masterConfig.busIdleTimeout_ns = 0; * masterConfig.pinLowTimeout_ns = 0; * masterConfig.sdaGlitchFilterWidth_ns = 0; * masterConfig.sclGlitchFilterWidth_ns = 0; */ LPI2C_MasterGetDefaultConfig(&masterConfig); /* Change the default baudrate configuration */ masterConfig.baudRate_Hz = LPI2C_BAUDRATE; /* Initialize the LPI2C master peripheral */ LPI2C_MasterInit(EXAMPLE_I2C_MASTER, &masterConfig, LPI2C_MASTER_CLOCK_FREQUENCY); /* Send master start bit &Slave Address + Write Bit */ if (kStatus_Success == LPI2C_MasterStart(EXAMPLE_I2C_MASTER, LPI2C_MASTER_SLAVE_ADDR_7BIT, kLPI2C_Write)) { LPI2C_MasterGetFifoCounts(EXAMPLE_I2C_MASTER, NULL, &txCount); while (txCount) { LPI2C_MasterGetFifoCounts(EXAMPLE_I2C_MASTER, NULL, &txCount); } if (LPI2C_MasterGetStatusFlags(EXAMPLE_I2C_MASTER) & kLPI2C_MasterNackDetectFlag) { return kStatus_LPI2C_Nak; } reVal = LPI2C_MasterSend(EXAMPLE_I2C_MASTER, &deviceAddress, 1); if (reVal != kStatus_Success) { if (reVal == kStatus_LPI2C_Nak) { LPI2C_MasterStop(EXAMPLE_I2C_MASTER); } return -1; } reVal = LPI2C_MasterSend(EXAMPLE_I2C_MASTER, g_master_txBuff, LPI2C_DATA_LENGTH); if (reVal != kStatus_Success) { if (reVal == kStatus_LPI2C_Nak) { LPI2C_MasterStop(EXAMPLE_I2C_MASTER); } return -1; } reVal = LPI2C_MasterStop(EXAMPLE_I2C_MASTER); if (reVal != kStatus_Success) { return -1; } } for (uint32_t i = 0U; i < WAIT_TIME; i++) { __NOP(); } if (kStatus_Success == LPI2C_MasterStart(EXAMPLE_I2C_MASTER, LPI2C_MASTER_SLAVE_ADDR_7BIT, kLPI2C_Write)) { /* Check master tx FIFO empty or not */ LPI2C_MasterGetFifoCounts(EXAMPLE_I2C_MASTER, NULL, &txCount); while (txCount) { LPI2C_MasterGetFifoCounts(EXAMPLE_I2C_MASTER, NULL, &txCount); } /* Check communicate with slave successful or not */ if (LPI2C_MasterGetStatusFlags(EXAMPLE_I2C_MASTER) & kLPI2C_MasterNackDetectFlag) { return kStatus_LPI2C_Nak; } reVal = LPI2C_MasterSend(EXAMPLE_I2C_MASTER, &deviceAddress, 1); if (reVal != kStatus_Success) { if (reVal == kStatus_LPI2C_Nak) { LPI2C_MasterStop(EXAMPLE_I2C_MASTER); } return -1; } reVal = LPI2C_MasterRepeatedStart(EXAMPLE_I2C_MASTER, LPI2C_MASTER_SLAVE_ADDR_7BIT, kLPI2C_Read); if (reVal != kStatus_Success) { return -1; } reVal = LPI2C_MasterReceive(EXAMPLE_I2C_MASTER, g_master_rxBuff, LPI2C_DATA_LENGTH); if (reVal != kStatus_Success) { if (reVal == kStatus_LPI2C_Nak) { LPI2C_MasterStop(EXAMPLE_I2C_MASTER); } return -1; } reVal = LPI2C_MasterStop(EXAMPLE_I2C_MASTER); if (reVal != kStatus_Success) { return -1; } } for (uint32_t i = 0U; i < LPI2C_DATA_LENGTH; i++) { if (i % 8 == 0) { } } temp = (((uint16_t) g_master_rxBuff[0] << 8U) | (uint16_t) g_master_rxBuff[1]) >> 4U; temperature = temp >> 4; PRINTF("Temperature=%d", temperature); PRINTF("Celsius"); while (1) { } }   6.5 PIN Configuratorを使ってピン設定を変更   P3T1755につながっているI3CをLPI2Cにつなぎ変えます。これは、プログラムコードを変更するのではなく、MCUXpresso Config Toolsの中のPin Configuratorというツールを使って行います。 まず、デフォルトで33ピンと34ピンがLPI2C0_SDAとLPI2C0_SCLに設定されているのを無効化します。Pinsタグで、下にスクロールして33ピンと34ピンを表示します。そして、右にスクロールしてLPI2C列を表示します。33ピンと34ピンのLPI2C列に表示されているLPI2C0_SDAとLPI2C0_SCLを、それぞれクリックすると、33ピンと34ピンが無効化されます。 次に、Pinsタグで、54ピンをLPI2C0_SDAに割り当てます。54ピンのチェックボックスをクリックすると、ピンに割り当てられている全機能が表示されます。その中からLPI2C0:SDAを選択します。すると、Pinsタグの54ピンが緑色に変わります。「Done」をクリックして割り当て完了です。 同じように、Pinsタグで、 55ピンをLPI2C0_SCLに割り当てます。55ピンのチェックボックスをクリックして、LPI2C0:SCLを選択します。すると、Pinsタグの55ピンが緑色に変わります。「Done」をクリックして割り当て完了です。 次に、54ピンと55ピンの機能設定を行います。機能設定には、下段にある「Routing Details for …」を使います。 Routing Details for …で、54ピン(LPI2C0_SDA)と55ピン( LPI2C0_SCL )のPull SelectをPullupに、Pull enableをEnabledに変更します。LabelをI2C_SDA とI2C_SCLにしておくと、board/pin_mux.h に定義を追加してくれます。 ピン設定は、これで完了です。 今までの変更内容をコードに反映させるには、Update Codeボタンをクリックします。 6.6 ビルド&デバッグ、動作確認 コードの変更が終わったら、ビルドします。 Projectsにカーソルを持っていくと、ビルドボタンが現れます。クリックするとビルドされます。 「build finished successfully.」のメッセージが出ればOKです。 ビルドボタンの隣に、デバッグボタンがあります。これをクリックすると、デバッグモードに入ります。 デバッグモードに入ると、プログラムはブレイクポイントで止まっているので、画面上部のアイコン内の「|▶」をクリックします。するとプログラムが走ります。 Tera Termの画面に、温度が表示されます。 まとめ 本記事では、I²Cの基本的な通信方式と、MCX A153に搭載されているLPI2Cモジュールの主な機能について説明しました。また、FRDM-MCXA153に搭載されたP3T1755温度センサーを例に、プルアップ抵抗の追加、Pin Configuratorによるピン設定、LPI2CのSDKサンプルコードの変更方法を確認しました。I²C通信では、スレーブアドレスやレジスタアドレス、データ長を接続するデバイスの仕様に合わせて設定することが重要です。本記事の内容を参考に、センサーやEEPROMなど、さまざまなI²Cデバイスとの通信に応用してください。 =========================​ 本投稿の「Comment」欄にコメントをいただいても、現在返信に対応しておりません。​ お手数をおかけしますが、お問い合わせの際には「NXPへの技術質問 - 問い合わせ方法 (日本語ブログ)」をご参照ください。​ (既に弊社NXP代理店、もしくはNXPとお付き合いのある方は、直接担当者へご質問いただいてもかまいません。)​ 本記事は、NXPマイコンMCX A153に搭載されているLPI2C(Low Power Inter-Integrated Circuit)コントローラを題材にします。I²Cの基本を確認した後、I²CとLPI2Cの違いについて説明し、MCX A153のLPI2Cの仕様・使い方を学びます。 (読了時間: 30分) MCUXpresso IDE MCUXpresso SDK MCX 日本語ブログ
View full article
Demo EthernetAnalyzer FRDM-A-S32K344 RTD 7.0.1 S32K344 Embedded Ethernet Analyzer Demo with LVGL Overview This article presents an embedded Ethernet Analyzer demo for the S32K344 MCU and the FRDM-A-S32K344 development board.The application captures received and transmitted Ethernet frames and displays them directly on an LCD-PAR-S035 touchscreen. It provides a compact, stand-alone view of Ethernet traffic without requiring the captured frames to be transferred to a host PC.The demo is available in two variants: Bare-metal lwIP application FreeRTOS lwIP application Both variants use the same Ethernet Analyzer, frame parser and graphical application layers.   Figure 1: Complete FRDM-A-S32K344 and LCD-PAR-S035 hardware setup Motivation PC-based packet analyzers remain the preferred solution for detailed network debugging. However, the frames visible to a PC capture application may depend on the Ethernet adapter and its driver configuration.For example, some adapters may process or remove an IEEE 802.1Q VLAN tag before the frame is delivered to the capture application. This can make analysis of VLAN-tagged traffic less straightforward. Automotive Ethernet applications may also use an IEEE 802.1CB redundancy tag, commonly referred to as an R-TAG.The purpose of this demo is to provide a direct view of the Ethernet frames processed by the S32K3 Ethernet interface and to make basic VLAN and R-TAG inspection available directly on the development board.The application is intended as a compact demonstration and debugging aid. It is not intended to replace a full-featured PC packet analyzer.   Main Features The application provides: Capture of received Ethernet frames Capture of transmitted Ethernet frames Configurable RX and TX capture Storage of frame snapshots in a bounded internal buffer Graphical frame list Selection and inspection of individual frames Hexadecimal frame data view Basic decoding of: Source and destination MAC addresses EtherType IEEE 802.1Q VLAN tags IEEE 802.1CB R-TAGs ARP IPv4 ICMP VLAN, R-TAG and multicast display filters RX and TX activity indication Start, pause, resume, stop and clear controls Capacitive touchscreen operation Preserved lwIP TCP/IP connectivity   Figure 2: Frame list with standard Ethernet traffic  Figure 3: Frame list with VLAN and R-TAG traffic  Frame Details A captured frame can be selected from the frame list and opened in the Frame Details screen. This screen provides decoded information about the selected frame together with a hexadecimal data dump. The raw frame data can therefore be compared with the decoded Ethernet, VLAN, R-TAG and higher-layer protocol fields.   Figure 4: Frame Details screen showing decoded fields and hexadecimal data Capture Settings The Capture Settings screen can be used to enable or disable RX and TX capture and to select the types of frames displayed by the application.The available display filters include VLAN-tagged frames, R-TAG frames and multicast frames.   Figure 5: Capture Settings screen Software Architecture The Ethernet capture path is separated from frame decoding and graphical processing. The RX and TX hooks copy a bounded frame snapshot into an application-managed ring buffer. The captured frame is subsequently decoded and displayed from the application context. LVGL functions are not called directly from the Ethernet RX or TX processing context. GUI refresh and activity indication are deferred to the graphical application processing path. The main application-specific software layers are: App.c/.h Application initialization and periodic processing of the LCD, touchscreen, LVGL and Ethernet Analyzer GUI. eth_analyzer.c/.h Frame capture, capture state control, filtering and storage of RX and TX frame snapshots. eth_analyzer_parser.c/.h Parsing and decoding of Ethernet, VLAN, R-TAG and selected higher-layer protocol fields. eth_analyzer_gui.c/.h Connection between the analyzer data model and the LVGL graphical interface.   For a detailed description of the project structure, software components, hardware connections and configuration, refer to the comments in src/main.c. Graphical Application The graphical interface uses LVGL 9.4.0 and was designed using NXP GUI Guider 2.0.1.The GUI Guider-generated screens, widgets and event handlers are stored separately from the custom GUI callbacks and Ethernet Analyzer application logic. This separation allows the graphical screens to be modified in GUI Guider while keeping the custom application layers maintainable. Font Roboto Mono is used for selected frame information and hexadecimal data. The generated LVGL font data retains the original SIL Open Font License 1.1 terms. The original GUI Guider project is included with this article, allowing the graphical application to be modified and regenerated using GUI Guider 2.0.1.   TCP/IP Connectivity The original lwIP TCP/IP functionality is preserved. The example uses the following static IPv4 address 192.168.0.209 Connectivity can be verified from a host configured for the same IPv4 subnet. ping 192.168.0.209 The ping response time may vary while the captured frame list is being refreshed. GUI rendering and blocking LCD transfers temporarily occupy processing time, but the TCP/IP stack remains operational.   Hardware The demo was developed and tested with: S32K344 MCU FRDM-A-S32K344 development board LCD-PAR-S035 display ST7796S LCD controller GT911 capacitive touchscreen controller The display is connected through LPSPI. The touchscreen uses LPI2C together with GPIO signals for interrupt and reset control. Detailed signal connections and hardware configuration are documented in main.c and README.md in the attached projects. Software Requirements NXP S32 Design Studio for S32 Platform 3.6.6 S32K3 RTD 7.0.1 FreeRTOS for S32K3 11.1.0 TCP/IP Stack for S32K3 5.0.0 LVGL 9.4.0 NXP GUI Guider 2.0.1 The attached project packages include README.md, Dependencies.txt, applicable software bill of materials files, license texts and the NXP disclaimer.   Porting to Other Boards The Ethernet Analyzer, parser and GUI layers were intentionally separated from the board-specific LCD, touchscreen and Ethernet initialization.This architecture can be adapted to other S32K3-based FRDM or evaluation boards. Porting requires board-specific changes, including: MCU and board configuration Ethernet controller and PHY setup Pin multiplexing Clock configuration LCD and touchscreen connections RTD and TCP/IP Stack configuration Available flash and RAM resources The project should therefore be treated as a reusable integration reference rather than as a drop-in project for every S32K3 board.   Known Limitations This project is a demonstration application and has several intentional limitations: The internal capture buffer has a finite capacity. Only a bounded portion of each frame is stored. Frame capture and GUI rendering consume MCU processing time. LCD transfers use blocking LPSPI communication. RX and TX indicators are informational and may not visibly represent every individual event. The protocol parser supports selected Ethernet and higher-layer fields only. The analyzer is not intended to provide the capture performance or protocol coverage of a dedicated PC-based packet analyzer. The application has not been designed or qualified as a production monitoring solution.   Attached Projects The following project variants are provided:   Demo_EthernetAnalyzer_BareMetal_FRDM_A_S32K344_v1_0_RTD701 Demo_EthernetAnalyzer_FreeRTOS_FRDM_A_S32K344_v1_0_RTD701 The original GUI Guider project is also included: Demo_EthernetAnalyzer_GUI_Guider_v1_0_GG201 The GUI project can be opened and modified using NXP GUI Guider 2.0.1. It contains the screens, widgets, events, custom callbacks and graphical assets used by the Ethernet Analyzer application. After modifying the graphical application, copy the contents of the GUI Guider generated and custom output directories into the corresponding src/gui_guider directories of the BareMetal or FreeRTOS project. The GUI Guider project package includes the applicable license information and software component documentation. This article presents BareMetal and FreeRTOS variants of an embedded Ethernet Analyzer demo for the S32K344 MCU. The application captures RX and TX Ethernet frames and displays them directly on an LCD-PAR-S035 touchscreen, including basic decoding of VLAN and IEEE 802.1CB R-TAG information and hexadecimal inspection of individual frames. The graphical interface uses LVGL 9.4.0 and was created with NXP GUI Guider 2.0.1.
View full article
能源革命系统评测:它真的有效吗? 如果您正苦于无法预测的停电、不断上涨的每月电费,或者只是想为您的家人建立一个可靠的离网能源备用系统,那么您并不孤单。 最近,能源革命系统在互联网上引起了轰动。这本书被宣传为一本循序渐进的 DIY 指南,教普通人如何在家制造清洁、便携式发电机,这在在线技术论坛和社区留言板上引发了广泛的讨论。 事实上,用户和 DIY 技术爱好者正在NXP 社区论坛和技术问答网站等平台上热烈讨论该系统,询问这些 DIY 磁线圈原理是否真的能转化为现实世界的家庭电力。 在这篇令人震惊的评论中,我们将深入探讨能源革命系统究竟是什么,它是如何运作的,它包含什么,以及它是否真的能在 2026 年兑现其承诺。 产品快速概览 产品名称:能源革命系统 类别:替代能源/DIY家居改造/离网电力 格式:电子蓝图、分步操作手册和高清视频指南 组装时间: 2至4小时(适合初学者) 官方门户网站:点击此处访问官方能源革命系统 退款保证: 60 天(100% 无条件退款) 等级: ⭐⭐⭐⭐⭐ (4.8/5) 什么是能源革命系统? 能源革命系统是一个全面的数字化教学蓝图,旨在指导初学者组装一台静音、轻便且经济高效的能源发电机。 与昂贵、噪音大、耗油的商用发电机不同,该装置专注于使用易于获取的硬件部件(如磁线圈、电线、电池储能组和标准逆变器)来捕获电流。 目标很简单: 大幅降低您的水电费:使用自发电为日常电子产品、照明设备和家用电器供电。 紧急停电保护:在恶劣天气导致电网瘫痪时,准备好安全、适合室内使用的备用电源。 它的工作原理是什么? 其核心机制依赖于基本的电转换和谐振原理。该程序会向您展示如何将磁能捕获装置连接到深循环电池。 能量捕获:线圈结构能够高效地捕获微小的电荷。 存储:能量持续输入到您的电池储能系统中。 逆变器转换:简单的电源逆变器可以将直流电转换为标准的家用交流电。 即插即用:您可以将家用电源插座、充电器、灯具、风扇和小电子产品直接插入本机。 由于它无需内燃即可运行,因此不会产生任何有害烟雾,而且运行完全静音,因此可以在客厅、卧室或公寓内安全使用。 本指南包含哪些内容? 当您从官方网站订购时,即可立即获得以下数字下载权限: 高分辨率蓝图和图表:易于阅读的原理图,显示每个连接和电线规格。 完整的五金材料清单:一份详细的清单,告诉你应该在当地的五金店(如家得宝、劳氏或当地电子产品商店)购买哪些零件,才能获得最优惠的价格。 高清演示视频教程:一步一步的视频说明,展示从开始到结束的组装过程。 维护和扩展手册:延长电池寿命和排除设置故障的指南。 它真的有效吗?(令人震惊的真相) 是的,它确实有效——前提是你的期望值要现实一些。 如果你指望花费 100 美元自制一个工作台就能立即为一栋五居室豪宅或一台工业空调机组供电,那你肯定会失望的。然而,正如成千上万的 DIY 建造者和社区论坛用户所证实的那样,如果按照蓝图建造,它可以提供非常可靠的辅助电源。 它非常适合为普通家用电器、LED 照明、Wi-Fi 路由器、电视屏幕和手机充电器供电,从而大大减轻电表负荷,每年为您节省数百美元的电费。 优点和缺点 优点 大幅降低成本:立即降低您的每月电费支出。 100% 静音安全:无噪音电机或危险的一氧化碳气体。 适合初学者:无需任何电气方面的知识——清晰的视频指南将引导您完成每个步骤。 60 天退款保证:您可以完全无风险地试用本指南两个月。 缺点 需要自行组装:您必须单独购买硬件零件,并花费 2 到 3 个小时进行组装。 仅提供电子版:通过即时 PDF 和视频下载以电子方式交付。 最终结论:2026年还值得购买吗? 由于电网不稳定且电价达到历史新高,掌控家庭能源需求是一个明智之举。能源革命系统提供简单易懂、万无一失的蓝图,将看似复杂的 DIY 建造项目变成一个有趣的周末项目。 我们提供60 天退款保证,您没有任何损失,却能获得真正的能源独立。 立即领取您的专属折扣! 不要等到下一次大风暴或电价飙升才去寻求电力保障。今天就迈出通往能源自由的第一步! 👉 点击这里访问官方能源革命系统网站,立即领取您的 2026 年折扣!
View full article
コードを生成できません コード生成プロセスが停止します。 Re: 无法生成代码 この問題は解決しましたか? Re: 无法生成代码 こんにちは、 @Cui5222 さん。 お使いのGUI Guiderのバージョンは何ですか?本当にインターネットにコネクテッドのですか?GUI Guiderを管理者として実行してみてはどうでしょうか?
View full article
Energy Revolution System Review: Does It Actually Work? If you are struggling with unpredictable power outages, rising monthly electricity bills, or simply want to build a reliable off-grid energy backup for your family, you are not alone. Recently, the Energy Revolution System has taken the internet by storm. Promoted as a step-by-step DIY guide that teaches everyday people how to build a clean, portable power generator at home, it has sparked massive debates across online tech forums and community message boards. In fact, users and DIY tech enthusiasts are heavily discussing this system on platforms like the NXP Community Forum and tech Q&A sites, asking whether these DIY magnetic coil principles genuinely translate into real-world household power. In this shocking review, we take a deep dive into what the Energy Revolution System really is, how it works, what you get inside, and whether it actually delivers on its promises in 2026. Quick Product Overview Product Name: Energy Revolution System Category: Alternative Energy / DIY Home Improvement / Off-Grid Power Format: Digital Blueprints, Step-by-Step Manuals & HD Video Guides Assembly Time: 2 to 4 Hours (Beginner-Friendly) Official Portal: Click Here to Access the Official Energy Revolution System Money-Back Guarantee: 60 Days (100% Unconditional Refund) Rating: ⭐⭐⭐⭐⭐ (4.8/5) What Is the Energy Revolution System? The Energy Revolution System is a comprehensive, digital instructional blueprint designed to guide beginners through assembling a silent, lightweight, and cost-effective energy generator. Unlike expensive, loud, and gas-guzzling commercial generators, this setup focuses on capturing electrical current using easily sourced hardware parts—such as magnetic coils, wiring, a battery storage bank, and a standard inverter. The goal is simple: Slash Your Utility Costs: Use self-generated power to run everyday electronics, light fixtures, and appliances. Emergency Blackout Protection: Have a safe, indoor-friendly power backup ready when the power grid goes down during severe weather. How Does It Work? The core mechanism relies on basic electrical conversion and resonance principles. The program shows you how to connect a magnetic energy capture unit to a deep-cycle battery. Energy Capture: The coil configuration captures small electrical charges efficiently. Storage: Energy feeds continuously into your battery storage bank. Inverter Conversion: A simple power inverter converts the DC charge into standard AC household electricity. Plug & Play: You can plug household power strips, chargers, lamps, fans, and small electronics directly into the unit. Because it operates without internal combustion, it produces zero hazardous fumes and runs completely silent, making it safe to use inside your living room, bedroom, or apartment.  What Do You Get Inside the Guide? When you order from the official website, you gain immediate digital download access to: High-Resolution Blueprints & Diagrams: Easy-to-read schematics showing every connection and wire gauge. Complete Hardware Materials Checklist: A detailed list telling you exactly what parts to buy at local hardware stores (like Home Depot, Lowe's, or local electronics shops) for the best price. HD Walkthrough Video Tutorials: Step-by-step video instructions showing the assembly from start to finish. Maintenance & Expansion Manuals: Guidance on extending battery life and troubleshooting your setup. Does It Actually Work? (The Shocking Truth) Yes, it does work—provided you have realistic expectations. If you expect a $100 DIY bench build to instantly power a whole 5-bedroom mansion or industrial AC unit, you will be disappointed. However, as thousands of DIY builders and community forum users have confirmed, when built according to the blueprints, it delivers a very reliable supplementary power source. It excels at powering regular household electronics, LED lighting, Wi-Fi routers, TV screens, and phone chargers—taking significant load off your electric meter and saving you hundreds of dollars on utility bills each year. Pros and Cons Pros Drastic Cost Reduction: Lower your monthly electricity expenses right away. 100% Silent & Safe: No noisy motors or dangerous carbon monoxide fumes. Beginner Friendly: No prior electrical background required—clear video guides walk you through every step. 60-Day Money-Back Guarantee: Try the guide for two full months completely risk-free. Cons Assembly Required: You must buy the hardware parts separately and dedicate 2 to 3 hours to building it. Digital Format Only: Delivered electronically via instant PDF and video downloads. Final Verdict: Is It Worth Buying in 2026? With power grid instability and electricity prices reaching record highs, taking control of your home's energy needs is a smart move. The Energy Revolution System provides simple, foolproof blueprints that turn a seemingly complex DIY build into a fun weekend project. Backed by a 60-day money-back guarantee, you have nothing to lose and real energy independence to gain. Claim Your Discounted Access Today! Don't wait for the next major storm or price surge to leave you without power. Take the step toward energy freedom today! 👉 CLICK HERE to Visit the Official Energy Revolution System Website & Claim Your 2026 Discount Today!
View full article
无法生成代码 生成代码会卡住 Re: 无法生成代码 请问此问题有解决吗 Re: 无法生成代码 你好@Cui5222 , 你使用的是哪个版本的GUI Guider?你确定你已连接到互联网吗?您能否尝试以管理员身份运行 GUI Guider?
View full article
无法生成c语言代码 当组件超过30个的时候,无法生成代码,软件卡住不动,等好长时间也没用 Re: 无法生成c语言代码 是的,GUI Guider 1.10.0 项目不能在 2.0.0 中直接打开,也不能自动升级。具体请参考:Tutorials — GUI Guider Documentation Re: 无法生成c语言代码 新版本的guiguider导入不了之前旧版本做的界面设计吗?我这点击导入没有反应,我之前用的是1.10.1-GA版本。 Re: 无法生成c语言代码 应该是的,我还没有试,但是我看内部ticket关了。等我空了给你测试下。 Re: 无法生成c语言代码 好的,最新版的不限组件数量吗 Re: 无法生成c语言代码 Hello @J_T @iyutong  这个问题在GUI-Guider的最新版 v2.0.x得到解决,可以在GUI Guider | NXP 半导体下载试用。 BR Celeste Re: 无法生成c语言代码 请问该问题解决了吗? Re: 无法生成c语言代码 好的,了解,我会报告给相关team。 Re: 无法生成c语言代码 最新版1.9.1,也问题依旧,卡这不动,但1.9.1是在50个的时候开住的 最新版1.9.1最新版1.9.1 Re: 无法生成c语言代码 你好,感谢发帖。方便提供更多细节吗?你用的哪个版本的gui-guider。只是添加三十个以上的组件就可以100%复现这个问题吗? 麻烦您帮忙提供更多信息,以便我更好的复现并把情况反映到相关team。感谢理解!
View full article
C言語コードを生成できません コンポーネントが30個を超えると、コードが生成されず、ソフトウェアがフリーズし、長時間経過しても何も起こりません。 Re: 无法生成c语言代码 はい、GUI Guider 1.10.0このプロジェクトはバージョン2.0.0では直接開くことができず、自動アップグレードもできません。詳細は「チュートリアル - GUI Guiderドキュメント」を参照してください。 Re: 无法生成c语言代码 新しいバージョンのGuiGuiderでは、古いバージョンで作成したインターフェースデザインをインポートできないのでしょうか?インポートボタンをクリックしても何も反応がありません。以前はバージョン1.10.1-GAを使用していました。 Re: 无法生成c语言代码 そうであるはずです。まだ試していませんが、内部チケットがクローズされているのを確認しました。時間があるときにテストしてみます。 Re: 无法生成c语言代码 最新バージョンでは、コンポーネントの数に制限はないのでしょうか? Re: 无法生成c语言代码 こんにちは@J_T @iyutong この問題は、GUI-Guiderの最新バージョンであるv2.0.xで解決されています。最新バージョンは、GUI Guider | NXP Semiconductorsからダウンロードして試用できます。 BR セレステ Re: 无法生成c语言代码 この問題は解決しましたか? Re: 无法生成c语言代码 わかりました。担当部署に報告します。 Re: 无法生成c语言代码 最新バージョンの1.9.1でも同じ問題が残っています。フリーズして動かなくなりますが、バージョン1.9.1では50ユニットでロックが解除されます。 最新版1.9.1最新バージョン1.9.1 Re: 无法生成c语言代码 こんにちは、投稿ありがとうございます。もう少し詳しい情報をお聞かせいただけますか?お使いのgui-guiderのバージョンは何ですか?30個以上のコンポーネントを追加するだけで、この問題を100%再現することは可能でしょうか? 問題の再現性を高め、関係部署に報告するために、もう少し詳しい情報をご提供いただけますでしょうか?ご理解いただきありがとうございます。
View full article