Multi Source Translation Content

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Multi Source Translation Content

ディスカッション

ソート順:
T1014- Error measuring IR length Hello experts of NXP: The link of original issue is : https://community.nxp.com/t5/T-Series/T1014-the-jtag-chain-does-not-contain-any-debuggable-cores/m-p/2424033#M5509 And I add an additional info is that when enabled the jtag Diagnostics, the log reported Error measuring IR length:  Please kindly help to find the root cause of the issue, thanks. Re: T1014- Error measuring IR length Support you in the  https://community.nxp.com/t5/T-Series/T1014-the-jtag-chain-does-not-contain-any-debuggable-cores/m-p/2424033#M5509
記事全体を表示
T1014 - JTAG 链不包含任何可调试内核 恩智浦的各位专家,您好: 我在自研的 T1014rdb 板上设置 Code Warrior TAP 时遇到了“jtag 链不包含任何可调试内核”和“JTAG 链配置失败”的问题。 通过分析,我们确认可以通过使用 ccs 命令测试访问 JTAG 链,但是无论是否重置电路板,都无法通过“get_children”命令获取调试核心: 我们发现的另一个现象是,在 ccs 中无法找到 t1014 芯片类型,只能找到 t10xx 系列,但可以找到 t1040 系列: 目前 RCW 加载方式是通过 SPI Flash,我们可以通过 MISO 获取 0xaa55aa55,并且 HRESET 已成功提升至 1.8V: 目前我们没有其他方法可以解决这个问题,仍然无法通过Code Warrior TAP调试T1014板。 请帮忙提供解决此问题的建议,问题是出在电路板启动还是IDE配置上?谢谢。 Re: T1014 - the jtag chain does not contain any debuggable cores 你好@BowenLi1991 , 请您尝试一下 “ccs::config_chain t1040” 而不是 “ccs::config_chain t1014” 请在 CCS 中以硬编码模式尝试以下命令。 (bin)2% 全部删除 (bin)3% 配置 cc cwtap (bin)4% 显示 cc 0:CodeWarrior TAP (cwtap) CC 软件版本。{0.0} (二进制)5% ccs::config_chain t1040 (bin) 6 % 显示 ::ccs::get_config_chain 链条位置 0:T1040 (bin) 7% ccs::reset_to_debug 如果命令运行正常,请将 T1014 设置为闪存启动模式,然后再次运行该命令。 如果所有命令都能正常运行。 请按照 T1024RM 的图 4-1 检查 PORESET_B、HRESET_B、RESET_REQ_B 和 ASLEEP 的波形。上电复位序列 谢谢! 六月
記事全体を表示
PCA9431HK datasheet and AN12639 access for NFC charging listener design The PCA9431 datasheet and AN12639 (referenced in the CRN120 datasheet) are not visible on the product page, even when logged in. Could you share them or tell us how to request access? Questions: 1. Is the PCA9431 output regulated to a fixed 5 V, and what output current is available at about 0.7 W? 2. Is there a reference schematic or eval kit for the CRN120 plus PCA9431 listener, and the matching CTN730 or CTN530 transmitter? 3. Recommended listener coil size and inductance for a coil of about 10 to 15 mm? Where can I d/l the **bleep** datasheet and docs? Re: PCA9431HK datasheet and AN12639 access for NFC charging listener design Hello, The datasheet and app notes required NDA. Please go to this web page: Secure Access Rights | NXP Semiconductors   Please follow the Step 2 for signing the NDA first. After you got the NDA number, follow the Step 3 to click the "submitting your request".   Then please request the highest access rights of the NFC Changing products.   Please type your project details and the NDA number in the "Reason" for requesting the access rights. 
記事全体を表示
MCUXpressoツールチェーンはどこにありますか? NXPユーザーの皆様へ、 MCUXpressoが最終的な組み込みファームウェアを構築するのと同じツールチェーンを使って、外部ライブラリ(埋め込みTLS)を構築しようとしています。 私はLinuxでMCUXpressoを実行し、同じコンピュータで組み込みTLSをビルディングしています。 embedTLSのライブラリ生成メイクファイルをMCUXpressoツールチェーンと連携させるのを手伝ってもらえますか? Re: Where is MCUXpresso toolchain こんにちは、 @s_hdl 投稿ありがとうございます! Linuxのデフォルトツールチェーンパスは /usr/local/mcuxpressoide- /ide/tools/bin/ です。 使用している実際のバージョンに合わせて変更してください。例:mcuxpressoide-25.6.136 BR Re: Where is MCUXpresso toolchain ご協力いただき、誠にありがとうございました。
記事全体を表示
MCUXpresso 工具链在哪里? 尊敬的NXP用户: 我正在尝试使用与 MCUXpresso 构建最终嵌入式固件相同的工具链来构建一个外部库(嵌入式 TLS)。 我正在 Linux 系统上运行 MCUXpresso,并且正在同一台计算机上构建嵌入式 TLS。 您能否帮我将我的 embedTLS 库生成 makefile 与 MCUXpresso 工具链连接起来? Re: Where is MCUXpresso toolchain 嗨@s_hdl 谢谢你的帖子! Linux 系统中的默认工具链路径为 /usr/local/mcuxpressoide- /ide/tools/bin/ 您应该将版本号修改为您实际使用的版本号,例如 mcuxpressoide-25.6.136 BR Re: Where is MCUXpresso toolchain 非常感谢您的帮助。
記事全体を表示
Where is MCUXpresso toolchain Dear NXP users, I'm trying to build an external library (embed TLS) with the same toolchain MCUXpresso uses to build the final embedded firmware. I'm running MCUXpresso on linux, and I am building embed TLS on the same computer. Could you help me to link my embedTLS library generation makefile with the MCUXpresso tool chain ? Re: Where is MCUXpresso toolchain Hi @s_hdl  Thank you for the post! The default toolchain path in linux is /usr/local/mcuxpressoide- /ide/tools/bin/ you should modify the version to the actual one you are using, example mcuxpressoide-25.6.136 BR  Re: Where is MCUXpresso toolchain Thank you very much for your help.
記事全体を表示
T1014 - 赤外線長さ測定の誤差 NXPの専門家の皆様、こんにちは。 元の記事へのリンクはこちらです: https://community.nxp.com/t5/T-Series/T1014-the-jtag-chain-does-not-contain-any-debuggable-cores/mp/2424033#M5509 さらに、jtag Diagnostics を有効にすると、ログに「IR の長さの測定エラー」と表示されるという情報も追加しておきます。 問題の根本原因の特定にご協力いただければ幸いです。よろしくお願いいたします。 Re: T1014- Error measuring IR length あなたをサポート  https://community.nxp.com/t5/T-Series/T1014-the-jtag-chain-does-not-contain-any-debuggable-cores/m-p/2424033#M5509
記事全体を表示
T1014 - the jtag chain does not contain any debuggable cores Hello experts of NXP: I suffered a problem "the jtag chain does not contain any debuggable cores" and "Failed to correctly configure the JTAG chain" when setting the Code Warrior TAP on a self developping T1014rdb board. Through the analysis, we confirmed that the JTAG chain is accessible by testing using ccs cmd, but can't get the debug core by the cmd "get_children" no matter reset the board or not: And another phenomenon we found is that we can't get the t1014 chip type in ccs, we can only get the t10xx, but we can get t1040: Currently the RCW loading method is by SPI Flash, we can get 0xaa55aa55 through MISO and the HRESET has successfully raised to 1.8V: Currently we don't have any further method to solve the issue and we still can't debug the T1014 board through Code Warrior TAP.  Please help to give suggestion to solve this issue, is the issue due to board bring up or IDE configuration, thanks. Re: T1014 - the jtag chain does not contain any debuggable cores  Hi @BowenLi1991 , Please kindly try the "ccs::config_chain t1040" instead of "ccs::config_chain t1014" Please try the commands below in the CCS with hard coded mode. (bin) 2 % delete all (bin) 3 % config cc cwtap (bin) 4 % show cc 0: CodeWarrior TAP (cwtap) CC software ver. {0.0} (bin) 5 % ccs::config_chain t1040 (bin) 6 % display ::ccs::get_config_chain Chain Position 0: T1040 (bin) 7 % ccs::reset_to_debug If the commands work well, please set the T1014 to your flash boot mode and run the command again. If all the commands work well. Please check the waveform of the PORESET_B, HRESET_B, RESET_REQ_B and ASLEEP follow the T1024RM, Figure 4-1. Power-on reset sequence Thanks June
記事全体を表示
EasyEVSE EVerest MPU build — SE05x middleware version clarification Setting up the NXP EasyEVSE platform using the i.MX93 service processing board. I'm following the EasyEVSE EVerest MPU instructions with this manifest: Branch: release/everest-mpu-2.0 Manifest: imx-6.12.20-2.0.0_everest.xml Target image: imx-image-everest The meta-nxp-everest-mpu README specifies EdgeLock SE05x Plug & Trust Middleware version 04.07.01 (se05x_mw_v04.07.01.zip), but I can only currently find version 04.08.01 (se05x_mw_v04.08.01.zip) on the NXP download site. Is middleware 04.08.01 supported with the release/everest-mpu-2.0 manifest and imx-6.12.20-2.0.0_everest.xml? Which exact recipe or configuration file should be updated, and what changes are required? Is middleware 04.07.01 still available through an official download link if it is required? Re: EasyEVSE EVerest MPU build — SE05x middleware version clarification Hi @ChargeMeMaybe  The README lists only 04.07.01 as a prerequisite; there are no major architectural changes between versions in the 04.x series. You will need to modify the bb file to use 04.08.01. Best Regards, Zhiming
記事全体を表示
T1014 - JTAGチェーンにデバッグ可能なコアが含まれていません NXPの専門家の皆様、こんにちは。 自作のT1014rdbボードでCode Warrior TAPをセットアップした際に、「JTAGチェーンにデバッグ可能なコアが含まれていません」および「JTAGチェーンを正しく構成できませんでした」という問題が発生しました。 解析の結果、ccs cmdでテストすればJTAGチェーンにアクセスできるものの、ボードをリセットしてもいなくてもcmd「get_children」でデバッグコアを取得できないことが確認されました: そして、もう一つ発見した現象は、t1014チップタイプはccsで入手できず、t10xxしか入手できませんが、t1040は入手可能だということです。 現在、RCWのローディング方法はSPI Flashによるもので、MISOを通0xaa55aa55でき、HRESETは1.8Vまで正常に上げられました: 現時点では問題を解決するためのさらなる方法がなく、Code Warrior TAP経由でT1014ボードのデバッグもまだできません。 この問題を解決するための提案をいただけると助かります。問題は基板の起動によるものなのか、IDEsの設定によるのか、ありがとうございます。 Re: T1014 - the jtag chain does not contain any debuggable cores こんにちは、 @BowenLi1991 さん。 どうぞお試しください 「ccs::config_chain t1014」の代わりに「ccs::config_chain t1040」を使用します。 ハードコードモードのCCSで、以下のコマンドを試してみてください。 (bin) 2%すべて削除 (bin) 3 % config cc cwtap (bin) 4% ccを表示 0: CodeWarrior TAP (cwtap) CC ソフトウェアバージョン{0.0} (bin) 5% ccs::config_chain t1040 (bin) 6 % display ::ccs::get_config_chain 鎖位置0:T1040 (bin) 7 % ccs::reset_to_debug コマンドが正常に動作した場合は、T1014をフラッシュブートモードに設定し、再度コマンドを実行してください。 すべてのコマンドが正常に動作した場合。 PORESET_B、HRESET_B、RESET_REQ_B、ASLEEPの波形がT1024RMの図4-1に従っていることを確認してください。電源投入リセットシーケンス よろしくお願いします。 6月
記事全体を表示
T1014-测量红外长度的误差 恩智浦的各位专家,您好: 原问题的链接是: https://community.nxp.com/t5/T-Series/T1014-the-jtag-chain-does-not-contain-any-debuggable-cores/mp/2424033#M5509 另外补充一点信息是,启用 JTAG 诊断功能后,日志报告称测量红外长度时出错: 请帮忙找出问题的根本原因,谢谢。 Re: T1014- Error measuring IR length 支持你 https://community.nxp.com/t5/T-Series/T1014-the-jtag-chain-does-not-contain-any-debuggable-cores/m-p/2424033#M5509
記事全体を表示
[PN7221][Android16] 反复快速刷卡,概率出现nfc无法使用 NFC固件版本,测试过如下两个版本,都能复现问题: 版本1:3.2.4 版本2:3.2.6 log已上传附件,出现问题后,kill HAL可以恢复正常。 Re: [PN7221][Android16] 反复快速刷卡,概率出现nfc无法使用 有升级到03.02.06测试过,也是能复现到问题 Re: [PN7221][Android16] 反复快速刷卡,概率出现nfc无法使用 Hello @zhangkai  从log 看FW:03.02.C4这是个临时的版本,将FW升级到最新03.02.06 nfc-NXPNFCC_FW/InfraFW/pn7220 at master · NXP/nfc-NXPNFCC_FW · GitHub Re: [PN7221][Android16] 反复快速刷卡,概率出现nfc无法使用 客户端是有出现3次正常操作下,NFC无法工作,看log和快速刷卡触发的卡死一样,请看log “20261020_194057_F802E693J0065.zip”,现象是在息屏后nfc无法工作了。 快速反复刷卡只是我这边复现问题的方法。 Re: [PN7221][Android16] 反复快速刷卡,概率出现nfc无法使用 Hello   从您提供的log看,都是timeout error,所以您当前的情况就是读卡间隔太短导致的,不建议这么频繁读卡。 Re: [PN7221][Android16] 反复快速刷卡,概率出现nfc无法使用 慢慢刷,暂时没复现到 Re: [PN7221][Android16] 反复快速刷卡,概率出现nfc无法使用 最快大概1S刷两次,平均大概1S一次 Re: [PN7221][Android16] 反复快速刷卡,概率出现nfc无法使用 Hello @zhangkai  看着像是卡住了没法恢复再次准备读卡。"反复快速"大概是什么样的频次?如果慢一些是不是就不会出现这样的问题? Re: [PN7221][Android16] 反复快速刷卡,概率出现nfc无法使用 你好@zhangkai 请通过电子邮件应用此补丁! BR 凯莉 Re: [PN7221][Android16] 反复快速刷卡,概率出现nfc无法使用 单卡反复刷,测试了20分钟,暂时没有复现到 Re: [PN7221][Android16] 反复快速刷卡,概率出现nfc无法使用 先刷卡1,再刷卡2 卡死,这个现象确认不是patch导致的,导入patch前也是一样的现象。 Re: [PN7221][Android16] 反复快速刷卡,概率出现nfc无法使用 导入邮件补丁后,还是能复现,而且更快复现,按如下步骤测试,必现: 1. 先刷卡1 2. 再刷卡2,卡死 回复: [PN7221][Android16] 反复快速刷卡,概率出现nfc无法使用 Hi,该问题有新进展么?目前看主要是卡1和卡2交替刷,会触发卡死。
記事全体を表示
EasyEVSE EVerest MPUビルド — SE05xミドルウェアバージョンの明確化 i.MX93サービスプロセッシングボードを使ってNXP EasyEVSEプラットフォームをセットアップしています。 私は以下のマニフェストを使用して、EasyEVSE EVerest MPUの手順に従っています。 ブランチ: release/everest-mpu-2.0 マニフェスト: imx-6.12.20-2.0.0_everest.xml 対象画像: imx-image-everest meta-nxp-everest-mpu READMEにはEdgeLock SE05x Plug & Trust Middleware バージョン 04.07.01(se05x_mw_v04.07.01.zip)が指定されていますが、現在NXPのダウンロードサイトで見つかるのはバージョン04.08.01(se05x_mw_v04.08.01.zip)だけです。 ミドルウェア04.08.01はリリース/everest-mpu-2.0でサポートされていますか?マニフェストとimx-6.12.20-2.0.0_everest.xml? 具体的にどのレシピファイルまたは設定ファイルを更新すべきか、またどのような変更が必要か? ミドルウェア04.07.01は、必要であれば公式ダウンロードリンクからまだ入手可能ですか? Re: EasyEVSE EVerest MPU build — SE05x middleware version clarification こんにちは、 @ChargeMeMaybe READMEには前提条件として04.07.01のみが記載されており、04.xシリーズのバージョン間には大きなアーキテクチャ上の変更はありません。04.08.01を使用するようにbbファイルを変更する必要があります。 よろしくお願いします、 志明
記事全体を表示
PCA9431HK 数据手册和 AN12639 可用于 NFC 充电监听器设计 即使登录后,产品页面上也看不到 PCA9431 数据表和 AN12639(CRN120 数据表中引用的)。您能否分享一下这些信息,或者告诉我们如何申请访问权限? 问题: 1.PCA9431 的输出是否稳定在 5V?在约 0.7W 的功率下,可提供的输出电流是多少? 2. 是否有 CRN120 加 PCA9431 监听器以及配套的 CTN730 或 CTN530 发射器的参考原理图或评估套件? 3. 对于直径约为 10 至 15 毫米的线圈,推荐的监听线圈尺寸和电感值是多少? 哪里可以下载**哔——**数据手册和文档? Re: PCA9431HK datasheet and AN12639 access for NFC charging listener design 你好, 数据手册和应用说明需要签署保密协议。 请访问以下网页: 安全访问权限 | 恩智浦半导体   请先按照步骤 2 签署保密协议。 获得 NDA 编号后,请按照步骤 3点击“提交您的请求”。   那么请申请NFC换位产品的最高访问权限。   请在“申请访问权限的原因”一栏中填写您的项目详情和保密协议编号。
記事全体を表示
PCA9431HKデータシートおよびNFC充電リスナー設計のAN12639アクセス PCA9431のデータシートとCRN120データシートに参照されたAN12639は、ログインしても製品ページには表示されません。それらを共有したり、アクセス申請の方法を教えてもらえますか? 質問: 1.PCA9431出力は固定5Vに調整されているのか、また約0.7Wで利用可能な出力電流はどれくらいですか? 2. CRN120プラスPCA9431リスナーと対応するCTN730またはCTN530トランスミッタの参考回路図や評価キットはありますか? 3. 約10〜15mmのコイルに推奨されるリスナーコイルのサイズとインダクタンスは? **ピー音**のデータシートとドキュメントはどこで切り出せますか? Re: PCA9431HK datasheet and AN12639 access for NFC charging listener design こんにちは、 データシートとアプリケーションノートにはNDAが必要でした。 こちらのウェブページにアクセスしてください。 セキュアアクセス権 |NXP Semiconductors   まず、手順2に従ってNDAに署名してください。 NDA番号を取得したら、ステップ3に従って「リクエストを送信する」をクリックしてください。   ぜひNFCチェンジ製品の最高アクセス権を申請してください。   アクセス権を申請する理由欄に、プロジェクトの詳細とNDA番号を入力してください。
記事全体を表示
[PN7221][Android16] Repeatedly swiping the card quickly may result in NFC becoming unusable. The following two NFC firmware versions were tested, and both reproduced the problem: Version 1: 3.2.4 Version 2: 3.2.6 The log has been uploaded as an attachment. If a problem occurs, killing HAL will restore normal operation. Re: [PN7221][Android16] 反复快速刷卡,概率出现nfc无法使用 I've tested it after upgrading to version 03.02.06, and the problem can still be reproduced. Re: [PN7221][Android16] 反复快速刷卡,概率出现nfc无法使用 Hello @zhangkai The log shows FW: 03.02.C4 , which is a temporary version. Upgrade FW to the latest version 03.02.06. (nfc-NXPNFCC_FW/InfraFW/pn7220 at master · NXP/nfc-NXPNFCC_FW · GitHub) Re: [PN7221][Android16] 反复快速刷卡,概率出现nfc无法使用 The client experienced NFC failure after three normal operations. The log showed the same issue as a freeze triggered by a quick card swipe. Please see the log "20261020_194057_F802E693J0065.zip". The symptom is that NFC stops working after the screen is off. Rapidly and repeatedly swiping the card is just my method for reproducing the problem. Re: [PN7221][Android16] 反复快速刷卡,概率出现nfc无法使用 Hello Based on the logs you provided, they all show timeout errors, so your current situation is caused by the card reading interval being too short. It is not recommended to read the card so frequently. Re: [PN7221][Android16] 反复快速刷卡,概率出现nfc无法使用 I'm refreshing slowly, and haven't been able to reproduce the issue yet. Re: [PN7221][Android16] 反复快速刷卡,概率出现nfc无法使用 The fastest refresh rate is about two refreshes per second, and the average refresh rate is about one refresh per second. Re: [PN7221][Android16] 反复快速刷卡,概率出现nfc无法使用 Hello @zhangkai It looks like it's stuck and can't recover, trying to read the card again. "Repeatedly and quickly"—what's the approximate frequency? Would this problem disappear if it were slower? Re: [PN7221][Android16] 反复快速刷卡,概率出现nfc无法使用 Hello @zhangkai  Please apply the patch as email! BR kelly Re: [PN7221][Android16] 反复快速刷卡,概率出现nfc无法使用 I repeatedly swiped the card for 20 minutes, but the problem hasn't been reproduced yet. Re: [PN7221][Android16] 反复快速刷卡,概率出现nfc无法使用 The system freezes when I swipe card 1 first, then card 2. This issue has been confirmed to be unrelated to the patch, as the same phenomenon occurred before importing the patch. Re: [PN7221][Android16] 反复快速刷卡,概率出现nfc无法使用 Even after importing the email patch, the problem can still be reproduced, and even faster. Test with the following steps, and it will definitely be reproduced: 1. Swipe your card first. 2. Swipe card 2 again, and the system freezes. 回复: [PN7221][Android16] 反复快速刷卡,概率出现nfc无法使用 Hi, any new developments on this issue? It seems that the problem mainly involves alternating between SIM 1 and SIM 2, which can trigger a freeze.
記事全体を表示
[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 日本博客
記事全体を表示
[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
記事全体を表示
如何为 i.MX 95 Neutron NPU 编译和运行 AI 模型(日文博客) 介绍 i.MX 95集成的 eIQ Neutron NPU 可以将 AI 模型推理处理卸载到专用加速器上。但是,并非总是可以直接运行模型;需要进行多项准备工作,包括量化、运算符兼容性以及编译器和目标运行时之间的版本兼容性。 本文概述了将使用 ONNX 或 TensorFlow 创建的模型转换为 TFLite 的完整流程,包括执行 INT8 量化、编译以适配 Neutron NPU、部署到 i.MX 95 以及使用 benchmark_model 评估性能。我们将主要介绍标准且灵活的流程 A ,同时也会介绍利用现有 ONNX 量化环境的流程 B。 *本文并未具体限制人工智能模型的使用;它只是描述了该过程中涉及的步骤。 命令示例适用于 Neutron-S。实际使用时,请务必查看目标系统上已安装的Neutron SDK 、 Yocto BSP和运行时附带的文档和发行说明。 目录 概述 主机端工具安装 转换流程(流程 A 详情) 备选流程:流程 B(ONNX 级量化) i.MX 95 目标的部署和性能评估。 (可选)位精确验证:neutron-runner 支持的算符和量化约束 故障排除/常见陷阱 综上所述   1. 概述 本文概述了在 i.MX 95 中安装的 eIQ Neutron NPU 上运行使用 ONNX 或 TensorFlow 训练的 AI 模型的转换过程。它基于安装 Neutron SDK 后 docs 文件夹中包含的官方文档:“Neutron SDK 用户指南”、“Neutron 编译器用户指南”、“TFLite 分析器/量化器用户指南”、“Neutron Runner 用户指南”、“支持的运算符 (Neutron-S / Neutron-C)”以及i.MX 机器学习用户指南 (UG10166) 。 ℹ️ 注:i.MX 95 中的 Neutron NPU 属于“Neutron-S”架构(子系统类型)。它与 i.MX RT700 等 MCU 中使用的“Neutron-C”架构在转换流程和一些工具选项方面有所不同。本文重点介绍 i.MX 95(Neutron-S)。   1.1 总流量(流量 A:推荐) Neutron SDK 提供的标准流程包括将模型转换为 TFLite 格式,在代表性数据集上对其进行分析,然后使用 INT8 对其进行量化,最后使用 neutron-compiler 将其编译为 NPU。 ℹ️首次用户补充信息 i.MX 95 的 Neutron NPU 实际上运行在为 Neutron NPU 编译的 INT8 量化 TFLite 模型上。此过程最终会将您的 ONNX/TensorFlow 模型转换为这种格式。 根据您准备的预训练模型的格式,起始步骤会有所不同。请参考以下步骤,并从适用于您的步骤开始。 INT8 量化 TFLite 模型:跳过步骤 1-3,从步骤 4 开始。 FP32 TFLite 模型:跳过步骤 1,直接从步骤 2 开始。 ONNX/TensorFlow FP32 模型:执行步骤 1 到 1。 有关每个步骤的详细信息,请参阅以下章节。 程序 工作详情 章节号 ① 将 ONNX 转换为 TFLite FP32 步骤 1:将 ONNX 模型转换为 TFLite FP32 格式。 ② 利用代表性数据集进行分析 步骤 2:FP32 模型分析 ③ 基于配置文件的 INT8 量化 步骤 3:基于配置文件信息的 INT8 量化 ④ 为 Neutron NPU 编译 步骤 4:为 Neutron NPU 编译 ⑤ 根据需要进行位精确验证 6.(可选)位精确验证:neutron-runner ⑥ 将转换后的模型部署到目标平台。 5.2 模型部署 ⑦ 推理执行和性能评估 5.3 性能评估(基准模型)   1.2 两种量化流(流 A / 流 B) Neutron SDK 用户指南定义了获取量化 TFLite 模型的两种流程。 流动 管道 量化工具 特点 流程 A(推荐) ONNX FP32 → TFLite FP32 → TFLite INT8 → 中子转换 tflite-profiler + tflite-quantizer(包含在 Neutron SDK 中) 它提供了高度的量化灵活性。特定的算子可以被排除在量化之外,从而允许映射到中子插值器,同时保持FP精度。 流程 B ONNX FP32 → ONNX INT8 → TFLite INT8 → 中子转换 onnx2quant (eIQ ONNX2TFLite) 当已有基于 ONNX 的量化流水线时,此功能非常有用。但其对运算符排除的细粒度控制有限。 💡 提示:如果您不确定,我们推荐流程 A(tflite-profiler + tflite-quantizer)。如果您希望将某些算符(例如非线性激活函数)映射到中子插值器而不对其进行量化,则流程 A 至关重要。   2. 设置主机端工具 模型转换将在开发主机(Linux/Windows PC)上进行。请从NXP eIQ软件仓库安装以下工具。 # ONNX → TFLite 转换工具 pip安装 eiq-onnx2tflite --index-url https://eiq.nxp.com/repository/# eIQ Neutron SDK(包括 tflite-profiler、tflite-quantizer、neutron-compiler、neutron-runner 等) pip安装 eiq-neutron-sdk --index-url https://eiq.nxp.com/repository/ ℹ️ 注意:开发主机(neutron-compiler)的推荐最低配置:CPU 2GHz 或更高,8 核或更高;内存 4GB 或更高。Neutron-S(例如 i.MX 95)使用约束编程求解器,因此转换时间可能需要几分钟到几十分钟不等,具体取决于模型。 ℹ️如果 pip 安装失败 如果 pip install 在您的内部代理环境中无法完成,请考虑以下选项。 使用 eIQ Toolkit 的 zip 版本— 从eIQ Toolkit 产品页面获取并解压 zip 文件后,您可以在 bin/ 下运行 Neutron 工具。zip 版本使用连字符,例如 tflite-profiler 、 tflite-quantizer 、 neutron-compiler 和 neutron-runner 。而 pip/uv 版本可能使用下划线,例如 tflite_profiler 、 tflite_quantizer 和 neutron_compiler 。但是,zip 版本不包含 onnx2tflite 和 onnx2quant ,必须使用 pip 或 uv 安装。以下命令示例使用与 zip 版本等效的表示法。 使用 uv 进行安装——根据您的环境,这可能比使用 pip install 更成功。 pip install uv uv pip install eiq-onnx2tflite \ --index-url https://eiq.nxp.com/repository/ \ --extra-index-url https://pypi.org/simple/ 如果需要代理,您可能需要配置 http_proxy / https_proxy (包括大写的环境变量)。配置方法取决于贵公司的具体环境。   2.1 Neutron SDK 版本和 Yocto BSP 兼容性 Neutron 驱动程序、固件和编译器必须与 Neutron SDK 版本一致。如果它们不兼容,运行时将输出以下警告。 Microcode version mismatch! Neutron Driver is 3.1.0-0X359f358d but model converted with 3.0.1-0Xd5d7918e. Runtime (driver, firmware) should be aligned with compiler Yocto BSP 版本与 Neutron SDK 版本之间的兼容性(摘录,基于截至 2026 年第三季度的最新 BSP): Yocto BSP 支持的发布周期 默认 Neutron SDK LF_6.12.3_1.0.0 2025年第一季度 1.2.0 LF_6.12.20_2.0.0 2025年第二季度 2.0.2 LF_6.12.34_2.1.0 2025年第三季度 2.1.3 LF_6.12.49_2.2.0 2025年第四季度 2.2.2 LF_6.18.2_1.0.0 2026年第一季度 2.2.3 LF_6.18.20_2.0.0 2026年第二季度 3.1.2 LF_6.18.37_2.1.0 2026年第三季度 3.2.1 其他 Neutron SDK 版本也可以作为“可升级版本”使用,但这种情况下,您需要将目标运行时(驱动程序/固件/委托)更新到相应的版本,并使用相同版本的 neutron-compiler 重新编译模型。详情请参阅《Neutron SDK 用户指南》中的版本兼容性表格。 3. 转换流程(流程 A 详情)   步骤 1:将 ONNX 模型转换为 TFLite FP32 格式。 如果您的模型已经是 TFLite FP32 格式,则无需执行此步骤。请使用 onnx2tflite 工具将您的 ONNX 模型转换为 TFLite 格式。 onnx2tflite -o .tflite .onnx ℹ️ 关于 SDK 版本的说明 -i (输入规范)和 -target (FP32/INT8 切换)在某些 SDK 版本中已弃用。输入 ONNX 文件使用位置参数指定,并在执行前使用 onnx2tflite --help 检查最新选项。如果您更改了输入/输出布局,还请检查您使用的 SDK 中是否存在 --keep-io-format / --no-keep-io-format 以及它们的默认值。   步骤 2:FP32 模型分析 我们使用 tflite-profiler,利用代表性的输入数据集(校准数据)测量每个张量的动态范围(最小值/最大值/直方图)。 ./tflite-profiler \ --input < my_model_fp32 > .tflite \ --dataset <输入数据目录> \ --output < my_model_fp32_profile > .csv ℹ️关于输入数据的说明 这包含一个 float32 格式的 .bin 文件,其尺寸与模型的输入尺寸相匹配。对于图像模型,您可以使用 SDK 中包含的 scripts/serialize_image.py 进行调整大小、归一化并转换为 float32 格式 .bin 。当没有代表性数据集时,可以使用 --use_random_data 进行形状验证和通信验证,但不适用于精度验证。 ./tflite-profiler \ --input < my_model_fp32 > .tflite \ --use_random_data \ --random-data-samples 10 \ --output < my_model_fp32_profile > .csv 通常认为,200 到 1000 个样本的样本量足以构建具有代表性的数据集。为了验证量化结果的准确性,建议使用一个未用于校准的独立验证数据集。   步骤 3:基于配置文件信息的 INT8 量化 我们将使用 tflite-quantizer 根据步骤 2 中生成的配置文件 (CSV) 执行 INT8 量化。 ./tflite-quantizer \ --input < my_model_fp32 > .tflite \ --profile < my_model_fp32_profile > .csv \ --output < my_model_quantized > .tflite 主要量化参数(默认值)如下: 选项 说明 默认值 --quantization-constant-type 权重量化数据类型 INT8 --quantization-constant-type-bias 具有偏差的量化数据类型(Conv2D/FC 等) INT32 --quantization-variable-type 激活的量化数据类型 INT8 --quantization-constant-granularity 权重量化粒度(PTQ/PCQ) PCQ(每通道) --quantization-constant-schema 权重量化方案 对称 --quantization-variable-schema 激活量化方案 不对称 --quantization-calibration-method 校准方法(最小值/最大值/百分位数) 最小最大值 要将特定算子排除在量化之外,请使用 --quantize-operator-types-except (例如, ADD,AVERAGE_POOL_2D )。像 LayerNorm 这样对量化敏感的复合算子也可以使用 layernorm 排除。 💡 提示:量化后,您可以使用 --run-after-quantize 选项通过虚拟输入验证操作(仅对标准 INT8 量化配置有效)。 ℹ️关于 SDK 版本的补充信息 量化选项可能因 SDK 而异。在我们的验证环境中,SDK 3.2.3 已确认可与表格中所示的选项以及 --quantization-constant-granularity PCQ 配合使用,但请务必在使用前使用目标 SDK 的 tflite-quantizer --help 进行验证。   步骤 4:为 Neutron NPU 编译 使用 neutron-compiler 为 i.MX 95 Neutron NPU 编译量化的 TFLite 模型。 ./neutron-compiler \ --input < my_model_quantized > .tflite \ --output < my_model_converted > .tflite \ --target imx95 中子编译器分以下三个阶段执行转换: 步 内容 ① 优化 将图转换为符合 Neutron 硬件约束的数学等价形式(图路径)。 ② 提取物 将 NeutronOperator 中的对应运算符按层次结构映射到 NeutronGraph 中的自定义运算符。 ③ 生成 微代码/权重/内核的分块、调度、内存分配和二进制生成。 您可以使用以下命令查看支持的目标和运算符类型列表。 neutron-compiler --show-targets neutron-compiler --show-operator-types neutron-compiler --target imx95 --show-kernel-kinds   3.1 主要编译器选项 选项 说明 --target 要转换的目标 Neutron 对象(例如 imx95)。如果省略,则默认为 mcxn94x。 --output 输出文件路径。如果省略,则会在输入文件名后附加 _compiled 。 --dump-statistics / --dump-statistics-file 将周期估算统计信息(根据 NeutronGraph)输出到控制台/文件。 --optimization-level OFast :快速启发式算法(默认)/ OOpt :使用ILP/SAT求解器求解最优解(转换时间较长) --include-operator-types / --exclude-operator-types 指定要映射到/排除在 NPU 之外的运算符类型。 --min-num-ops-per-graph 要提取为 NeutronGraph 的最小算子数量。较小的图针对 CPU 执行进行了优化。 --use-profiling / --use-profiling-tick-trace 启用实际硬件上的运行时性能分析(内核级/时钟周期级) --keep-graphs 保留中间图(这是中子运行器中进行位精确验证所必需的)。 --force-determinism 这样可以抑制求解器中的多线程争用,并获得明确的转换结果(转换时间大约增加 2-3 倍)。 ℹ️ 注意:由于 Neutron-S(i.MX 95 等)编译器使用约束编程求解器,因此对同一模型进行多次转换时,生成的微代码(尤其是 TCM 地址)可能会略有不同。这是因为多线程竞争会导致选择多个最优解之一,而所有解都是正确的。如果需要确定性,请使用 --force-determinism 。   4. 备选流程:流程 B(ONNX 级别量化) 如果您的现有流程依赖于 ONNX 级别的量化( onnx2quant ),您也可以使用以下流程。与流程 A 相比,该流程对运算符排除的细粒度控制更为有限。 程序 实施细节 使用的工具/主要交付成果 1 将 ONNX FP32 模型量化为 INT8 onnx2quant , model_int8.onnx 2 将 ONNX INT8 转换为 TFLite INT8 onnx2tflite , model_int8.tflite 3 为 Neutron NPU 编译 neutron-compiler --target imx95   # ① ONNXレベルでINT8量子化 # -cには入力テンソル名と.npyキャリブレーションデータのディレクトリを指定 onnx2quant .onnx -o .onnx -c " ; " # ② ONNX INT8 → TFLite INT8変換(QDQ形式の場合) onnx2tflite --qdq-aware-conversion -o .tflite .onnx # ③ Neutron NPU用コンパイル neutron-compiler --input .tflite --output .tflite --target imx95 ℹ️流程 B 笔记 onnx2quant 然后,需要指定 -c (校准数据规范)或 -u (随机校准数据)。对于多个输入模型,请为每个输入指定 -c 。将 ONNX 转换为 QDQ 格式时,请使用 --qdq-aware-conversion 。执行前,请使用 onnx2quant --help / onnx2tflite --help 检查所用 SDK 的选项。   5. 部署到 i.MX 95 目标平台及性能评估   5.1 Neutron 运行时配置 i.MX 95 (Neutron-S) 的 Neutron 运行时由以下三个组件构成: 组件 文件 地点 中子固件 NeutronFirmware.elf /lib/firmware/ 中子驱动器 libNeutronDriver.so /lib/ TensorFlow Neutron Delegate libneutron_delegate.so /lib/ ⚠️ 注意:更新运行时环境前务必备份现有文件。如果驱动程序、固件和编译器版本不匹配,则会显示“微代码版本不匹配”警告,并且系统可能变得不稳定。   5.2 模型部署 将转换后的 TFLite 模型( .tflite )复制到 i.MX 95 目标板(使用 scp 等)。   5.3 性能评估(基准模型) 我们将使用 NXP Yocto BSP 中包含的 TensorFlow Lite benchmark_model 应用程序,并通过 Neutron Delegate 进行性能评估。 /usr/bin/tensorflow-lite-2.19.0/examples/benchmark_model \ --graph = .tflite \ --external_delegate_path = /usr/lib/libneutron_delegate.so \ --enable_op_profiling = true \ --num_threads = 5 示例输出(按节点类型汇总): Number of nodes executed: 26 ============================== Summary by node type ============================== [Node type] [count] [avg ms] [avg %] [cdf %] [mem KB] [times called] NeutronDelegate 1 2.882 87.919% 87.919% 0.000 1 Slice (ND, X8) 10 0.175 5.339% 93.258% 0.000 10 CONCATENATION 2 0.096 2.929% 96.187% 0.000 2 Unary Elementwise (NC) 2 0.078 2.379% 98.566% 0.000 2 Copy (NC, X8) 11 0.047 1.434% 100.000% 0.000 11 Timings (microseconds): count=270 first=3372 curr=3303 min=3015 max=3537 avg=3290.54 std=76 26 nodes observed 💡 提示: “NeutronDelegate”行中较高的平均百分比表示大部分计算已卸载到 NPU。其他节点(例如切片、连接等)则在 CPU 上执行。如果此比例较低,则可能是由于不支持的运算符导致性能瓶颈,因此请查看“支持的运算符”文档中每个运算符的限制。   6.(可选)位精确验证:neutron-runner neutron-runner 是一款用于验证由 neutron-compiler 转换的模型是否能产生与 Neutron Golden Kernel(参考实现)完全匹配的结果的工具。它不用于生产环境部署,但可用于在迁移过程中验证模型的正确性。 项目 中子模 原版模式 目标模型 使用中子编译器将模型转换为 --keep-graphs 标准 TFLite 型号(FP32/FP16/INT8) 目标 IMX95、IMXRT700 不适用 目的 使用黄金内核进行位精确验证 参考运行(用于比较的基准) 典型的验证工作流程: # ① 启用 --keep-graphs 进行编译 neutron-compiler --input model.tflite --output model_neutron.tflite --target imx95 --keep-graphs # ② 使用 Neutron 运行时(黄金内核)执行 neutron-runner --input model_neutron.tflite --dataset inputs/ --use-neutron-runtime = true --target imx95 # ③ 使用 Vanilla 运行时(参考)运行 neutron-runner --input model.tflite --dataset inputs/ --use-neutron-runtime = false # ④ 比较结果 diff model_neutron_results_0.bin model_results_0.bin ℹ️ 注意:Neutron Golden Kernel 不支持的操作符将自动回退到 TFLite Vanilla 实现。执行完成后,控制台将显示回退的操作符列表。 在 pip 安装环境中 neutron-runner 的执行路径 在 pip/uv 版本中,不会生成 neutron-runner Python 包装器,您可能需要直接在站点包中指定 ELF 二进制文件。 /eiq_neutron_sdk/bin/neutron-runner \ --input model_neutron.tflite \ --dataset inputs/ \ --use-neutron-runtime=true \ --target imx95 在 eIQ Toolkit 的 zip 版本中,像往常一样执行 bin/neutron-runner 。   7. 支持的算符和量化约束 中子编译器对可映射到NPU的运算符存在一些常见限制。不满足这些限制的运算符将回退到CPU执行。   7.1 通用约束(Neutron-S / Neutron-C 通用) 张量的形状必须是静态的(固定的)(批次大小 N 固定为 1;Neutron-C 部分支持可变批次)。 张量类型为 UINT8 / INT8 / INT16 / INT32 / INT64 之一。 张量布局为 NHWC(TFLite 标准)。 量化标度必须为正的 FLOAT32 值。 使用 PTQ 或 PCQ 对权重进行对称量化(偏移量 = 0)。 使用 PTQ 或 PCQ 对偏差进行对称量化,其尺度为 input_scale × weights_scale 不符合上述约束条件的图层将不会映射到 NPU。   7.2 i.MX 95 (Neutron-S) 支持的主要运算符 CONV_2D , DEPTHWISE_CONV_2D , FULLY_CONNECTED , ADD , SUB , MUL , AVERAGE_POOL_2D , MAX_POOL_2D , CONCATENATION , PAD , PADV2 , RESHAPE , RESIZE_BILINEAR , RESIZE_NEAREST_NEIGHBOR , MEAN , SUM , LOGISTIC , TANH , HARD_SWISH , PRELU , LEAKY_RELU ,RELU 系统, TRANSPOSE_CONV , UNIDIRECTIONAL_SEQUENCE_LSTM 等(有关详细约束,请参见 SupportedOperatorsS.md )。 ⚠️ 注意:支持的运算符列表会随着 Neutron Compiler 的每个版本而更新(例如,3.2.1 版本支持 Group Conv2D,3.1.1 版本添加了 CAST/SELECT/UNIDIRECTIONAL_SEQUENCE_LSTM)。请务必查看您正在使用的 SDK 版本的发行说明。   8. 故障排除/常见陷阱 症状 原因 处理 微代码版本不匹配警告 驱动程序/固件/编译器版本不匹配 所有组件均已重新转换和重新排列,以匹配相同的 Neutron SDK 版本。 NeutronDelegate 的平均百分比较低(NPU 利用率低)。 该模型包含许多不支持的操作符(例如 Resize/Reduce)。 检查支持的运算符中的约束,用替代运算符替换它们,或者在保持运算符为 FP 的同时,手动将运算符映射到插值器。 量化后准确度显著下降。 校准数据缺乏代表性,或者特定操作员对量化敏感。 增加校准样本数量(200-1000)。排除 LayerNorm 和类似值,使用 --quantize-operator-types-except 中子编译器转换速度极慢。 使用 OOpt 优化级别或大型模型 首先,使用 OFast(默认)进行检查。仅在需要最高性能时才使用 OOpt(最多使用 16 个核心,会增加转换时间)。 在中子跑者中,一些操作符会回退到原始状态。 黄金内核不支持某些运算符。 未发现问题(运行正常)。请检查备用方案列表,确保它不会影响性能。 未找到命令( command not found ) 命令名称和位置因安装方法而异。 对于 pip/uv 版本,请检查站点包中的下划线表示法和实际路径;对于 zip 版本,请检查连字符表示法和 bin/ onnx2tflite 选项错误,错误代码为 onnx2quant 随附文档与 SDK 版本之间的差异 执行前,请用 --help 检查当前选项名称。   综上所述 本文概述了在 i.MX 95 Neutron-S NPU 上运行 AI 模型的标准转换流程。对于实际应用而言,以下三点尤为重要: 请确保 Neutron SDK 和目标运行时版本匹配。驱动程序、固件、委托和编译器之间的不一致将导致 Microcode version mismatch 。 首先,使用流程 A 检查量化和算子之间的对应关系。使用代表性数据集进行性能分析,可以更轻松地调整精度和与 NPU 的映射关系。 逐个检查 benchmark_model 的结果。如果除了 NeutronDelegate 之外还有许多其他操作,则可能是由于使用了不支持的操作或数据转换导致性能瓶颈。 模型精度、NPU卸载率和推理延迟会因模型结构、量化设置、输入数据和SDK版本而异。建议先从小型模型入手,在真机上进行转换和评估,如果没有出现问题,再逐步应用到目标模型。 本文中的命令示例和相关信息可能因您使用的 Neutron SDK 版本而异。有关最新的官方规范,请参阅 SDK 随附的文档和发行说明。 ========================= 即使您在本文的“评论”栏留言,我们目前也无法回复。 给您带来不便,我们深感抱歉。请在询问时参阅“NXP技术问题-联系方式(日本博客)”。 (如果您已经是NXP的代理商或与其有合作关系,可以直接向负责人咨询。) 这是一份关于在i.MX 95的 eIQ Neutron NPU 上运行 AI 模型的实用指南。 本文档解释了将 ONNX/TensorFlow 模型转换为 TFLite、将其量化为 INT8、将其编译为 Neutron NPU、将其部署到目标以及使用 benchmark_model 评估其性能的过程。 (阅读时间:20分钟)*实际编译时间会因型号而异。 i.MX 处理器 技术聚焦 日本博客
記事全体を表示
How to compile and run AI models for the i.MX 95 Neutron NPU (Japanese blog) Introduction The eIQ Neutron NPU integrated into the i.MX 95 allows you to offload AI model inference processing to a dedicated accelerator. However, it's not always possible to run the model directly; several preparations are necessary, including quantization, operator compatibility, and version compatibility between the compiler and target runtime. This article outlines the entire process of converting a model created with ONNX or TensorFlow to TFLite, performing INT8 quantization, compiling for Neutron NPUs, deploying to i.MX 95, and evaluating performance using benchmark_model . We will primarily introduce the standard and flexible Flow A , but will also introduce Flow B , which leverages existing ONNX quantization environments. *This article does not specifically limit the use of the AI model; it simply describes the steps involved in the process. The command examples are for Neutron-S. When actually using them, be sure to check the documentation and release notes that come with your installed Neutron SDK , Yocto BSP , and runtime on your target. table of contents overview Host-side tool setup Conversion procedure (Flow A details) Alternative flow: Flow B (ONNX level quantization) Deployment and performance evaluation of the i.MX 95 target. (Optional) Bit-exact verification: neutron-runner Supported Operators and Quantization Constraints Troubleshooting / Common Pitfalls In conclusion   1. Overview This article outlines the conversion procedure for running AI models trained with ONNX or TensorFlow on the eIQ Neutron NPU installed in the i.MX 95. It is based on the official documentation included in the docs folder after installing the Neutron SDK: "Neutron SDK User Guide," "Neutron Compiler User Guide," "TFLite Profiler/Quantizer User Guide," "Neutron Runner User Guide," "Supported Operators (Neutron-S / Neutron-C)," and the i.MX Machine Learning User Guide (UG10166) . ℹ️ Note: The Neutron NPU in the i.MX 95 is classified as the "Neutron-S" architecture (subsystem type). It differs from "Neutron-C" used in MCUs such as the i.MX RT700 in terms of conversion flow and some tool options. This article focuses on the i.MX 95 (Neutron-S).   1.1 Overall Flow (Flow A: Recommended) The standard flow provided by the Neutron SDK involves converting the model to TFLite format, profiling it on a representative dataset, then quantizing it using INT8, and finally compiling it for the NPU with neutron-compiler . ℹ️Supplementary information for first-time users The i.MX 95's Neutron NPU actually runs on INT8 quantized TFLite models compiled for the Neutron NPU . This procedure will ultimately convert your ONNX/TensorFlow model to this format. The starting step will vary depending on the format of the pre-trained model you have prepared. Please use the following as a guide and start from the step that applies to you. INT8 quantized TFLite model: Skip steps 1-3 and start from step 4. FP32 TFLite model: Skip step 1 and start from step 2 onwards. ONNX/TensorFlow FP32 model: Perform steps 1 through 1. For detailed information on each step, please refer to the following chapters. procedure Work details Chapter number ① Convert from ONNX to TFLite FP32 Step 1: Convert the ONNX model to TFLite FP32 format. ② Profiling with representative datasets Step 2: Profiling the FP32 model ③ INT8 quantization based on profile Step 3: INT8 quantization based on profile information ④ Compiled for Neutron NPU Step 4: Compiling for Neutron NPU ⑤ Bit-exact verification as needed 6. (Optional) Bit-exact verification: neutron-runner ⑥ Deploy the converted model to the target. 5.2 Model Deployment ⑦ Inference execution and performance evaluation 5.3 Performance Evaluation (benchmark_model)   1.2 Two Quantization Flows (Flow A / Flow B) The Neutron SDK User Guide defines two flows for obtaining a quantized TFLite model. flow pipeline Quantization tools Features Flow A (Recommended) ONNX FP32 → TFLite FP32 → TFLite INT8 → Neutron conversion tflite-profiler + tflite-quantizer (included with Neutron SDK) It offers a high degree of quantization flexibility. Specific operators can be excluded from quantization, allowing mapping to the Neutron Interpolator while maintaining FP precision. Flow B ONNX FP32 → ONNX INT8 → TFLite INT8 → Neutron conversion onnx2quant (eIQ ONNX2TFLite) Useful when an existing ONNX-based quantization pipeline is in place. Fine-grained operator exclusion control is limited. 💡 Hint: If you're unsure, we recommend Flow A (tflite-profiler + tflite-quantizer). Flow A is essential if you want to map certain operators (such as nonlinear activation functions) to the Neutron Interpolator without quantizing them.   2. Setting up the host-side tools Model conversion will be performed on the development host (Linux/Windows PC). Install the following tools from the NXP eIQ repository. # ONNX → TFLite Conversion Tool pip install eiq-onnx2tflite --index-url https://eiq.nxp.com/repository/ # eIQ Neutron SDK (including tflite-profiler, tflite-quantizer, neutron-compiler, neutron-runner, etc.) pip install eiq-neutron-sdk --index-url https://eiq.nxp.com/repository/ ℹ️ Note: Recommended minimum configuration for development host (neutron-compiler): CPU 2GHz or higher x 8 cores or higher, RAM 4GB or higher. Neutron-S (i.MX 95, etc.) uses a constraint programming solver, so conversion time may take several minutes to several tens of minutes depending on the model. ℹ️If pip install fails If pip install fails to complete in your internal proxy environment, please consider the following options. Using the zip version of eIQ Toolkit — After obtaining and extracting the zip file from the eIQ Toolkit product page , you can run the Neutron tools under bin/ . The zip version uses hyphens, as in tflite-profiler , tflite-quantizer , neutron-compiler , and neutron-runner . On the other hand, the pip/uv version may use underscores, as in tflite_profiler , tflite_quantizer , and neutron_compiler . However, onnx2tflite and onnx2quant are not included in the zip version and must be installed using pip or uv. The following command examples use notation equivalent to the zip version. Install using uv — this may be more successful than pip install depending on your environment. pip install uv uv pip install eiq-onnx2tflite \ --index-url https://eiq.nxp.com/repository/ \ --extra-index-url https://pypi.org/simple/ If a proxy is required, you may need to configure http_proxy / https_proxy (including uppercase environment variables). The configuration method depends on your company's environment.   2.1 Neutron SDK Version and Yocto BSP Compatibility The Neutron Driver, Firmware, and Compiler must all be the same Neutron SDK version. If they are not compatible, the following warning will be output at runtime. Microcode version mismatch! Neutron Driver is 3.1.0-0X359f358d but model converted with 3.0.1-0Xd5d7918e. Runtime (driver, firmware) should be aligned with compiler Compatibility between Yocto BSP versions and Neutron SDK versions (excerpt, based on the latest BSP as of Q3 2026): Yocto BSP Support Release Period Default Neutron SDK LF_6.12.3_1.0.0 Q1/2025 1.2.0 LF_6.12.20_2.0.0 Q2/2025 2.0.2 LF_6.12.34_2.1.0 Q3/2025 2.1.3 LF_6.12.49_2.2.0 Q4/2025 2.2.2 LF_6.18.2_1.0.0 Q1/2026 2.2.3 LF_6.18.20_2.0.0 Q2/2026 3.1.2 LF_6.18.37_2.1.0 Q3/2026 3.2.1 Other Neutron SDK versions can also be used as "Upgradable," but in that case, you will need to update the target runtime (Driver/Firmware/Delegate) to the corresponding version and re-compile the model with the same version of neutron-compiler. For details, please refer to the version compatibility table in the "Neutron SDK User Guide." 3. Conversion Procedure (Flow A Details)   Step 1: Convert the ONNX model to TFLite FP32 format. If your model is already in TFLite FP32 format, this step is unnecessary. Use the onnx2tflite tool to convert your ONNX model to TFLite format. onnx2tflite -o .tflite .onnx ℹ️ Note regarding SDK version -i (Input specification) and -target (FP32/INT8 switching) are deprecated in some SDK versions. The input ONNX file is specified using positional arguments, and check the latest options with onnx2tflite --help before execution. If you change the input/output layout, also check the presence and default values of --keep-io-format / --no-keep-io-format in the SDK you are using.   Step 2: Profiling the FP32 model Using tflite-profiler, we measure the dynamic range (min/max/histogram) of each tensor using a representative input dataset (calibration data). ./tflite-profiler \ --input < my_model_fp32 > .tflite \ --dataset < input_data_dir > \ --output < my_model_fp32_profile > .csv ℹ️Notes regarding input data This contains a .bin file in float32 format that matches the input dimensions of the model. For image models, you can use scripts/serialize_image.py included with the SDK to resize, normalize, and convert to float32 .bin . --use_random_data , used when there is no representative dataset, is for shape verification and communication verification, but is not suitable for accuracy verification. ./tflite-profiler \ --input < my_model_fp32 > .tflite \ --use_random_data \ --random-data-samples 10 \ --output < my_model_fp32_profile > .csv A sample size of 200 to 1000 samples is usually considered sufficient for a representative dataset. For accuracy validation of quantization results, it is recommended to use a separate validation dataset that was not used for calibration.   Step 3: INT8 quantization based on profile information We will use tflite-quantizer to perform INT8 quantization based on the profile (CSV) generated in step 2. ./tflite-quantizer \ --input < my_model_fp32 > .tflite \ --profile < my_model_fp32_profile > .csv \ --output < my_model_quantized > .tflite The main quantization parameters (default values) are as follows: option explanation Default value --quantization-constant-type Weight quantization data type INT8 --quantization-constant-type-bias Quantized data types with bias (Conv2D/FC, etc.) INT32 --quantization-variable-type Quantized data type of activation INT8 --quantization-constant-granularity Granularity of weight quantization (PTQ/PCQ) PCQ (per channel) --quantization-constant-schema Weight quantization schema Symmetric --quantization-variable-schema Activation Quantization Schema Asymmetric --quantization-calibration-method Calibration method (MinMax/Percentile) MinMax To exclude a specific operator from quantization, use --quantize-operator-types-except (e.g., ADD,AVERAGE_POOL_2D ). Quantization-sensitive compound operators like LayerNorm can also be excluded using layernorm . 💡 Hint: After quantization, you can verify the operation with a dummy input using the --run-after-quantize option (only valid for standard INT8 quantization configurations). ℹ️Supplementary information regarding SDK versions Quantization options may vary depending on the SDK. In our verification environment, SDK 3.2.3 has been confirmed to work with the options shown in the table and --quantization-constant-granularity PCQ , but please be sure to verify with tflite-quantizer --help of your target SDK before use.   Step 4: Compiling for Neutron NPU Compile the quantized TFLite model for the i.MX 95 Neutron NPU using neutron-compiler. ./neutron-compiler \ --input < my_model_quantized > .tflite \ --output < my_model_converted > .tflite \ --target imx95 neutron-compiler performs the conversion in the following three stages: step Content ① Optimize Transform the graph into a mathematically equivalent form that conforms to Neutron hardware constraints (graph path). ② Extract Hierarchically mapping corresponding operators from NeutronOperator to custom operators in NeutronGraph. ③ Generate Tile partitioning, scheduling, memory allocation, and binary generation of microcode/weights/kernels. You can check the list of supported targets and operator types using the following command. neutron-compiler --show-targets neutron-compiler --show-operator-types neutron-compiler --target imx95 --show-kernel-kinds   3.1 Major Compiler Options option explanation --target The target Neutron object to be converted (e.g., imx95). If omitted, it defaults to mcxn94x. --output Output file path. If omitted, _compiled will be appended to the input name. --dump-statistics / --dump-statistics-file Output cycle estimation statistics (per NeutronGraph) to console/file. --optimization-level OFast : Fast heuristic (default) / OOpt : Optimal solution using ILP/SAT solver (conversion time is long) --include-operator-types / --exclude-operator-types Specify the operator types to map to/exclude from the NPU. --min-num-ops-per-graph The minimum number of operators to extract as a NeutronGraph. Smaller graphs are optimized for CPU execution. --use-profiling / --use-profiling-tick-trace Enable runtime profiling on actual hardware (kernel level/tick level) --keep-graphs Preserve the intermediate graph (necessary for bit-exact verification in neutron-runner) --force-determinism This suppresses multithreaded contention in the solver and obtains definitive conversion results (conversion time increases by approximately 2-3 times). ℹ️ Note: Because Neutron-S (i.MX 95, etc.) compilers use a constraint programming solver, the generated microcode (especially the TCM address) may differ slightly when the same model is converted multiple times. This is because one of several optimal solutions is selected due to multithreaded contention, and all are correct results. Use --force-determinism when determinism is required.   4. Alternative Flow: Flow B (ONNX Level Quantization) If your existing pipeline relies on ONNX-level quantization ( onnx2quant ), you can also use the following flow. Fine-grained operator exclusion control is more limited than in Flow A. procedure Implementation details Tools used / Main deliverables 1 Quantizing the ONNX FP32 model to INT8 onnx2quant , model_int8.onnx 2 Converting from ONNX INT8 to TFLite INT8 onnx2tflite , model_int8.tflite 3 Compiled for Neutron NPU neutron-compiler --target imx95   # ① ONNXレベルでINT8量子化 # -cには入力テンソル名と.npyキャリブレーションデータのディレクトリを指定 onnx2quant .onnx -o .onnx -c " ; " # ② ONNX INT8 → TFLite INT8変換(QDQ形式の場合) onnx2tflite --qdq-aware-conversion -o .tflite .onnx # ③ Neutron NPU用コンパイル neutron-compiler --input .tflite --output .tflite --target imx95 ℹ️Flow B Notes onnx2quant Then, either -c (calibration data specification) or -u (random calibration data) is required. For multiple input models, specify -c for each input. Use --qdq-aware-conversion when converting ONNX in QDQ format. Before execution, check the options of the SDK being used with onnx2quant --help / onnx2tflite --help .   5. Deployment to the i.MX 95 target and performance evaluation   5.1 Neutron Runtime Configuration The Neutron runtime for i.MX 95 (Neutron-S) consists of the following three components: component file Location Neutron Firmware NeutronFirmware.elf /lib/firmware/ Neutron Driver libNeutronDriver.so /lib/ TensorFlow Neutron Delegate libneutron_delegate.so /lib/ ⚠️ Note: Always back up existing files before updating the runtime. If the driver, firmware, and compiler versions do not match, a "Microcode version mismatch" warning will be displayed, and the system may become unstable.   5.2 Model Deployment Copy the converted TFLite model ( .tflite ) to the i.MX 95 target board (using scp, etc.).   5.3 Performance Evaluation (benchmark_model) We will use the TensorFlow Lite benchmark_model application included in the NXP Yocto BSP and perform performance evaluation via Neutron Delegate. /usr/bin/tensorflow-lite-2.19.0/examples/benchmark_model \ --graph =< my_model_converted > .tflite \ --external_delegate_path = /usr/lib/libneutron_delegate.so \ --enable_op_profiling = true \ --num_threads = 5 Example output (summary by node type): Number of nodes executed: 26 ============================== Summary by node type ============================== [Node type] [count] [avg ms] [avg %] [cdf %] [mem KB] [times called] NeutronDelegate 1 2.882 87.919% 87.919% 0.000 1 Slice (ND, X8) 10 0.175 5.339% 93.258% 0.000 10 CONCATENATION 2 0.096 2.929% 96.187% 0.000 2 Unary Elementwise (NC) 2 0.078 2.379% 98.566% 0.000 2 Copy (NC, X8) 11 0.047 1.434% 100.000% 0.000 11 Timings (microseconds): count=270 first=3372 curr=3303 min=3015 max=3537 avg=3290.54 std=76 26 nodes observed 💡 Hint: A higher avg % in the "NeutronDelegate" row indicates that the majority of the computation is offloaded to the NPU. Other nodes (Slice, Concatenation, etc.) are executed on the CPU. If this ratio is low, unsupported operators may be causing bottlenecks, so check the constraints of each operator in the "Supported Operators" documentation.   6. (Optional) Bit-exact verification: neutron-runner neutron-runner is a tool that verifies whether a model converted by neutron-compiler produces results that perfectly match the Neutron Golden Kernel (reference implementation). It is not used for production deployment, but is useful for verifying the correctness of models during migration. item Neutron Mode Vanilla Mode Target models Model converted with --keep-graphs using neutron-compiler Standard TFLite models (FP32/FP16/INT8) Target IMX95, IMXRT700 N/A the purpose bit-exact verification using Golden Kernel Reference run (baseline for comparison) Typical validation workflow: # ① Compile with --keep-graphs enabled neutron-compiler --input model.tflite --output model_neutron.tflite --target imx95 --keep-graphs # ② Execute using the Neutron runtime (Golden Kernel) neutron-runner --input model_neutron.tflite --dataset inputs/ --use-neutron-runtime = true --target imx95 # ③ Run with Vanilla runtime (reference) neutron-runner --input model.tflite --dataset inputs/ --use-neutron-runtime = false # ④ Compare results diff model_neutron_results_0.bin model_results_0.bin ℹ️ Note: Operators not supported by the Neutron Golden Kernel will automatically fall back to the TFLite Vanilla implementation. After execution is complete, a list of the operators to which it fell back will be displayed in the console. neutron-runner execution path in a pip install environment In the pip/uv version, a Python wrapper for neutron-runner is not generated, and you may need to directly specify the ELF binary within the site package. /eiq_neutron_sdk/bin/neutron-runner \ --input model_neutron.tflite \ --dataset inputs/ \ --use-neutron-runtime=true \ --target imx95 In the zip version of eIQ Toolkit, execute bin/neutron-runner as usual.   7. Supported Operators and Quantization Constraints There are common constraints on the operators that neutron-compiler can map to the NPU. Operators that do not satisfy these constraints will fall back to CPU execution.   7.1 Common constraints (common to Neutron-S / Neutron-C) The shape of the tensor must be static (fixed) (batch size N is fixed at 1; Neutron-C partially supports variable batches). The tensor type is one of UINT8 / INT8 / INT16 / INT32 / INT64. The tensor layout is NHWC (TFLite standard). The quantization scale must be a positive FLOAT32 value. The weights are symmetrically quantized (offset = 0) using PTQ or PCQ. The bias is symmetrically quantized using PTQ or PCQ, and its scale is input_scale × weights_scale Layers that do not meet the above constraints will not be mapped to the NPU.   7.2 Main operators supported by i.MX 95 (Neutron-S) CONV_2D , DEPTHWISE_CONV_2D , FULLY_CONNECTED , ADD , SUB , MUL , AVERAGE_POOL_2D , MAX_POOL_2D , CONCATENATION , PAD , PADV2 , RESHAPE , RESIZE_BILINEAR , RESIZE_NEAREST_NEIGHBOR , MEAN , SUM , LOGISTIC , TANH , HARD_SWISH , PRELU , LEAKY_RELU , RELU systems, TRANSPOSE_CONV , UNIDIRECTIONAL_SEQUENCE_LSTM etc (see SupportedOperatorsS.md for detailed constraints). ⚠️ Note: The list of supported operators is updated with each version of the Neutron Compiler (e.g., Group Conv2D support in 3.2.1, CAST/SELECT/UNIDIRECTIONAL_SEQUENCE_LSTM added in 3.1.1). Be sure to check the release notes for the SDK version you are using.   8. Troubleshooting / Common Pitfalls Symptoms cause handle Microcode version mismatch warning Driver/Firmware/Compiler version mismatch All components are reconverted and rearranged to match the same Neutron SDK version. The average percentage of NeutronDelegate is low (low NPU utilization). The model contains many unsupported operators (such as Resize/Reduce). Check the constraints in Supported Operators, replace them with alternative operators, or manually map the operators to the Interpolator while keeping them as FP. Accuracy decreases significantly after quantization. Calibration data lacks representativeness, or specific operators are sensitive to quantization. Increase the number of calibration samples (200-1000). Exclude LayerNorm and similar values using --quantize-operator-types-except The neutron-compiler conversion is extremely slow. Use OOpt optimization level, or large model First, check with OFast (default). Use OOpt only when maximum performance is required (uses up to 16 cores, increases conversion time). In neutron-runner, some operators fall back to vanilla. There are operators that are not supported by the Golden Kernel. No issues found (expected operation). Check the fallback list to ensure it's not a performance-critical area. Command not found ( command not found ) The command name and location vary depending on the installation method. For pip/uv versions, check for underscore notation and actual paths within the site package; for zip versions, check for hyphen notation and what is under bin/ onnx2tflite Option error with onnx2quant Differences between the included documentation and the SDK version Check the current option name with --help before execution.   In conclusion This article outlined a standard conversion flow for running AI models on the i.MX 95 Neutron-S NPU. Three points are particularly important for practical use: Ensure that the Neutron SDK and the target runtime versions are matched. Inconsistencies between the Driver, Firmware, Delegate, and Compiler will result in Microcode version mismatch . First, use Flow A to check the correspondence between quantization and operators. Profiling with a representative dataset will make it easier to adjust accuracy and mapping to the NPU. Check the results of benchmark_model on an operator-by-operator basis. If there are many operations other than NeutronDelegate , unsupported operators or data conversions may be causing performance bottlenecks. Model accuracy, NPU offload rate, and inference latency vary depending on the model structure, quantization settings, input data, and SDK version. It is recommended to start with a small model, go through the conversion and evaluation on a real device, and then gradually apply it to the target model if there are no problems. The command examples and corresponding information in this article may vary depending on the version of the Neutron SDK you are using. For the latest official specifications, please refer to the documentation and release notes included with your SDK. ========================= 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 an inquiry. (If you are already an NXP distributor or have a relationship with NXP, you may ask your representative directly.) This is a practical guide for running AI models on the i.MX 95 's eIQ Neutron NPU. This document explains the process from converting an ONNX/TensorFlow model to TFLite, quantizing it to INT8, compiling it for Neutron NPUs, deploying it to the target, and evaluating its performance using benchmark_model. (Reading time: 20 minutes) *Actual compilation time will vary depending on the model. i.MX Processors Technology Focus Japanese Blog
記事全体を表示