Multi Source Translation Content

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

Multi Source Translation Content

Discussions

Sort by:
Re: i.MX RT1064 - PEmicro Connection Assistantエラー こんにちは、 これは、以前に提起された質問に対するフォローアップです。リンクは前回の問い合わせに添付されており、そのリンクには要求された必要な詳細情報が含まれています。ご返信いただき、この問題の早期解決にご協力をお願いいたします。 よろしくお願いいたします。 スバスリ https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs/i-MX-RT1064-PEmicro-Connection-Assistant-Error-and-Boot/m-p/2412530#M37152 i.MXRT 106x Re: i.MX RT1064 - PEmicro Connection Assistant Error こんにちは、 @Subhasri_S さん。 あなたが共有してくれた測定結果では、POR_Bが解放される前にプルアップ電圧が供給されていますか? あなたのアプリケーションでは、MCUが低消費電力状態に入るポイントはありますか? 問題が発生する前に、何らかの不具合やエラーは発生していますか? よろしくお願いします、 パブロ Re: i.MX RT1064 - PEmicro Connection Assistant Error こんにちは、 @Pablo_Ramos さん、ご返信ありがとうございます。 POR_Bが解放されるまでは、プルアップ電圧は供給されません。プルアップのシグナル。POR_Bの動作については、以下に添付します。 私たちのアプリケーションでは、MCUが低消費電力モードに入ることはありません。 また、この問題が発生する前に、不具合やエラーは発生していません。 また、この問題が発生した際にソフトウェアでボードを復元する方法があるのかも知りたいです。 よろしくお願いいたします。 スバスリ Re: i.MX RT1064 - PEmicro Connection Assistant Error こんにちは、 @Pablo_Ramos さん。 これは、その件に関するちょっとしたフォローアップです。 ありがとうございます。 敬具 スバスリ Re: i.MX RT1064 - PEmicro Connection Assistant Error ハイ この現象が発生すると、デバイスのフラッシュやデバッグができなくなるとおっしゃっていましたね。デバッガーを接続しようとしたら、それはできますか? デバッガーを接続できる場合、最後に実行された命令は何ですか? 考えられる説明の一つは、以下のナレッジベース記事に記載されています。 ナレッジベース:デバッガー接続の問題に対するRTボードの復旧 「フラッシュに異常なアプリケーション(例えば、存在しないメモリへのアクセス、メモリ破損、クロックの誤設定など)が含まれている場合、基板は未知の状態に入り、デバッガがコアの制御を奪えなくなります。しかし、デバイスがシリアルダウンローダーモードになると、コアは既知の状態に強制的に移行され、デバッガーが制御できるようになります。 したがって、RTボードでデバッガー接続の問題が発生した場合は、デバイスがシリアルダウンローダーモードになっている状態で、外部フラッシュの一括消去を実行してみてください。これにより、デバッガーの正常な動作が回復するはずです。 この問題はカスタムボードとEVKの両方で発生するとのことでしたね。標準的なSDKの例を実行したときも同じ問題が起きますか? この現象が確認されているEVKにおいて、ハードウェアの変更は行われていますか? よろしくお願いいたします。 パブロ Re: i.MX RT1064 - PEmicro Connection Assistant Error こんにちは、ご返信ありがとうございます。 いいえ、デバッガー(PE Micro)を使用してデバイスにファームウェアを書き込むことはできません。 最後に実行された命令を示すスクリーンショットを以下に添付しました。何らかのコードによってハードフォルト/バスフォルトが発生した場合、ビルド後、ボードにアクセスできなくなります。ボードがこの状態に入ると、NXPのサンプルコードを含む他のコードをフラッシュすることができなくなります。また、内部起動モードでフラッシュを消去できず、ハードウェア上で手動で起動モードをシリアルダウンロードに変えてフラッシュを消去しない限り、ボードにアクセスできません。 EVKでも同様の挙動が観察されました。EVKでは物理的なスイッチで起動モードを変更するため、リカバリーは比較的簡単でした。しかし、当社のカスタム基板にはこれらのスイッチがないため、基板の復旧にはかなり手間のかかる作業が必要です。 そのため、ファームウェアの故障によりボードがアクセス不能になり、実用的でない手動復旧手順が必要になる可能性があるため、本番生産を進めるのはリスクが高まります。 この状態でデバッガーやPEmicroを使って、シリアルダウンロードモードに切り替えずにボードを復元する方法はありますか?また、問題はハードウェアによるものなのかソフトウェアなのか、どちらが原因でしょうか? MCUがこの回復不可能な状態に陥り、私たちが意識的に回避できる状態に陥っている原因は何でしょうか? よろしくお願いいたします。 スバスリ
View full article
消費電力マネジメント 現在、エネルギー価格は非常に高騰しており、今後数か月で太陽への到達を目指しているため、その影響を最小限に抑えるために何ができるかという疑問が生じています。 多くの方が私と同じ立場にあることでしょう。会社内での「方針」、いやむしろ慣習は、システムの保守やリモートアクセス、その他の理由で常にすべてをオンにしておくものでした。 今朝、「多くの企業がエネルギー価格のため生き残れないかもしれない」という記事を読んで、会社全体で厳格なパワーマネージメントポリシーを導入することで、積極的に対策を講じることができると思いました。 そこで皆さんはこの問題にどう対処していますか?もし以前にうまくやっていたなら、どのようにして最善の方法を見つけましたか? 電源設定のグループポリシーについて?サードパーティのアプリケーションやシステム?ユーザーに、帰宅時にすべてをオフにしてほしいと丁寧に頼み、定期的に叩くことで強制する? 既に長年この分野に携わっている方々からのご意見やアドバイスがあればお聞かせください。 電源ソリューション Re: Power consumption management あなたが提起した「エネルギーコスト削減のための全社的なパワーマネージメント方針の実施方法」は一般的なITおよび施設マネジメントのテーマであり、NXPの製品技術サポートの範囲外です。
View full article
S32K2x8EVB-Q289 QSPI 芯片的 S26KL512S 型号错误 您好, 我们目前使用的是 S32K3x8EVB-Q289 板,我们正在尝试让 QSPI 与板载 S26KL512SDABHV030 闪存一起工作。 经过大量的调试,我们遇到了瓶颈,一直搞不清楚到底发生了什么,直到我们发现了一些我们想要澄清的事情。 EVB 用户指南和原理图中显示,S26KL512SDABHV030 焊接在板上。通过检查零件,我们也确认了标记内容: 6KL512SDAHV03 是 03 变体(DCARS 变体)。 阅读 S26K512S 数据手册后发现,DCARS 使用 PSC 信号生成 RWDS(读取所需)。然而,在 EVB 的原理图中,PSC 没有布线到任何地方(除了测试焊盘 TPAD21)。PSC# 在 3V 版本上是 RFU,所以我们不需要它。 从逻辑分析仪上看,我们始终看不到 RWDS 在延迟期后切换(此时我们应该观察到返回的数据),传输最终超时。 我们一直无法让闪光灯正常工作,我们怀疑EVB是否配错了闪光灯型号。 感谢您的帮助。 Michal Re: S32K2x8EVB-Q289 QSPI with wrong S26KL512S variant 以下是最新进展: 将 PSC 连接到 SCK 后,我们现在有了 RWDS 信号。 这证实了以下几点: 03 (DCARS) 变体确实需要 PSC 信号才能指示何时有数据可用。目前这在 Rev C EVB 上尚未连接。 02(非DCARS)型是应该安装的集成电路。 由于PSC信号没有延迟,RWDS切换非常接近数据变化边沿,导致读数不一致(目前我们正在使用设备ID读取进行测试)。 使用 S32K358 的内部 DQS 也无法提供可靠的数据读取方法,因为它可能无法与数据变化正确对齐。 请指教 Michal Re: S32K2x8EVB-Q289 QSPI with wrong S26KL512S variant 我们有一块 Rev C 板。 因此,该勘误不适用于我们的情况,而且,即使原理图将它们互换了,PSC 引脚仍然会断开,因为只有 SCK 引脚是连接的。 阅读 S26KL5152S 数据手册可知,我们可以将 SCK 引脚连接到 PSC,然后存储器将像 02(非 DCARS)变体一样工作。我们将重新设计板,添加此连接,看看是否能解决问题。 如果您有其他解决方案,请与我们联系。 Michal Re: S32K2x8EVB-Q289 QSPI with wrong S26KL512S variant 能否具体说明一下所用板的版本?板用户手册中列出了以下勘误: Re: S32K2x8EVB-Q289 QSPI with wrong S26KL512S variant 嗨,米哈尔, 感谢您的建议。我已经仔细核对了设备标识和英飞凌的相关文档,我同意你的结论。已安装的 S26KL512SDABHV030 DCARS 变体需要 PSC 信号,而 Rev. C 板上没有连接该信号。 我会将此问题报告给我们的应用工程团队,以便他们进一步调查。 此致, 大卫
View full article
S32K2x8EVB-Q289 QSPI with wrong S26KL512S variant Hi, We currently have the S32K3x8EVB-Q289 board and  we are trying to make the QSPI work with the onboard S26KL512SDABHV030 flash. After extensive debugging, we have hit a wall and we couldn't figure out what was going on until we found something that we want to clear up. In the EVB user guide and schematics, it indicates that the S26KL512SDABHV030 is soldered on the board. By inspecting the part, we also confirmed that the markings are: 6KL512SDAHV03 which is the 03 variant (DCARS variant). After reading the S26K512S datasheet, it states that the DCARS uses the PSC signal to generate the RWDS (needed for reading). However, in the schematics of the EVB, the PSC is not routed anywhere (except to test pad TPAD21). PSC# is RFU on the 3V variant so we don't need it. Looking at the logic analyzer, we never see the RWDS toggling after the latency period (when we should observe the returned data) and the transfer eventually times out. We have not been able to get the flash working and we are wondering whether the EVB is shipped with the wrong flash variant. Thanks for your help. Michal Re: S32K2x8EVB-Q289 QSPI with wrong S26KL512S variant Here is another update: After connecting PSC to SCK, we now have have a RWDS signal. This confirms the following: The 03 (DCARS) variant does need a PSC signal to be able to indicate when data is available. This is currently not connected on the Rev C EVB. The 02 (non-DCARS) variant is the IC that should have been installed Since the PSC signal is not delayed, the RWDS toggle is very close to the data change edges giving us inconsistent readings (we are testing with the device ID reads for now).     Using the internal DQS of the S32K358 also does not provide a reliable method of reading the data as it may not be aligned correctly with data changes. Please advise Michal Re: S32K2x8EVB-Q289 QSPI with wrong S26KL512S variant We have a Rev C board. So that erratum does not apply to our case, and furthermore, that would still leave the PSC pin disconnected (even if the schematics had them swapped since only the SCK pin is connected). Reading the S26KL5152S datasheet, it says that we can connect the SCK pin to PSC and the memory would then behave like a 02 (non-DCARS) variant. We will re-work the board to add this connection and see if that fixes the issue. If you have another solution, please let us know. Michal Re: S32K2x8EVB-Q289 QSPI with wrong S26KL512S variant Could you specify used board revision? In the board user manual following erratum is specified: Re: S32K2x8EVB-Q289 QSPI with wrong S26KL512S variant Hi Michal, Thanks for your inputs. I have double-checked the device identification and the relevant Infineon documentation, and I agree with your conclusion. The populated S26KL512SDABHV030 DCARS variant requires the PSC signal, which is not connected on the Rev. C board. I will report this issue to our application engineering team for further investigation. Best regards, David
View full article
S32G3 EB AUTOCORE ライセンス こんにちは、チームの皆さん、 EB Client License Administrator 内のアクティベーション コード 7FCB-75DF-0F6E-4E7A (有効期限 2026 年 12 月 30 日) が期限切れであると表示され、EB tresos AutoCore を起動する際に問題が発生しています。 下記の添付ファイルをご覧ください。 Re: S32G3 EB AUTOCORE LICENSE こんにちは、 過去にライセンスにアクセスしていない同僚のアカウントでサインインしてみてください。これにより、最新のライセンスを入手できるはずです。 コミュニティ投稿では、パスワード、ライセンス、その他の機密情報を共有しないでください。
View full article
i.MX9 ELEの既知の問題 2025年のこの議論によると、i.MX 9では、セキュアワールドと非セキュアワールドの両方が同時にMUを使用してELEと通信していた際に問題が発生したとのことです。議論の中で、2025年Q3に修正が計画されていると言われました。この修正プログラムは既にリリースされていますか?修正はELEファームウェアに実装されているのか、それともCortex A55コードの修正が必要だったのでしょうか?ELEファームウェアに実装された場合、その修正が最初に含まれたファームウェアバージョンはどれですか? i.MX Linuxリリースノート(RN00210)によると、電圧変化に関する既知のELE問題があります。この問題の影響は何ですか?ELE_VOLT_CHANGE_START_REQが送信された場合でも、電圧グリッチ検出器は作動しますか?あるいは、電圧の変化は乱数発生器に影響を与えるだろうか?RN00210では、i.MX 93のみに問題が記載されています。非常によく似たi.MX 91も影響を受けているのでしょうか? 背景:OP-TEE内部からELEへの信頼性の高いアクセスが必要で、Linuxがうまく振る舞うとは信頼できません。 Security Re: Known issues with i.MX9 ELE 私が最初の質問でリンクした議論によると、セキュアワールドには独自のMUがあるにもかかわらず、同時ELEリクエストに問題があったようです。議論からの引用: >>>>>> I'm aware that the >>>>>> i.MX93 has two MUs one for the secure and one for the non-secure >>>>>> world. But I'm really concerned about the fact that both MUs can't >>>>>> be used at the same time from both world: >>>>> >>>>> Yes, you are correct. >>>>> >>>>> Fix is still work in progress. マルコ・フェルシュは、GitHub上のNXPエンジニアによるこのコメントへのリンクを投稿した。 問題は、RNGに特有のものではなく、カーネルとOP-TEEからELEへの同時リクエストを行う際に発生します。現在、解決策に取り組んでおり、まもなく提供開始予定です。 では、この解決策はすでに提供されていますか? セキュアでない世界がELE_VOLT_CHANGE_START_REQを悪用してセキュアな世界での乱数生成を停止させた場合にSoCをリセットするのは妥当な措置と言えるでしょう。 Re: Known issues with i.MX9 ELE こんにちは、 特定のi.MX9をお探しですか? これはファミリー内の異なるプロセッサに影響を及ぼします。例えばi.MX91/93では、OPTEEは通信に専用のTrusted MU(信頼管理ユニット)を使用しているため、これらのプロセッサには影響がありません。 ELE電圧変化の問題に関してですが、これはランダムデータの破損ではなく、コマンドシーケンスの問題です。ELE_VOLT_CHANGE_START_REQが受け入れられた後、ELEは一時的に電圧グリッチセンサーを無効化し、すぐにELE_VOLT_CHANGE_FINISH_REQを期待します。同時進行のHRNG要求は失敗またはハングする可能性があります。完了要求がタイムアウトを超えて遅延した場合、ELEはシーケンスを中止しSoCをリセットすることがあります。 最後に、i.MX 91は通常、標準電圧と低電圧の間だけスイッチし、約50 mVの差があり、GDETが起こるとは思われないため、同じ問題の影響を受けないと考えられます。 よろしくお願いいたします。 アルド。
View full article
Coupon not valid FRDM-MCXN236 Is anyone else having trouble with the free board coupon code? NXP is advertising a free board to get started, but the coupon code is showing as invalid during checkout, even though the product is clearly in stock. Is this a system glitch? Is anyone else experiencing this issue? 开发板 FRDM 培训 Re: Coupon not valid FRDM-MCXN236 Unfortunately, our marketing team has informed us that this coupon has already reached its usage limit and will not be extended further. The coupon will be removed within the next couple of days. We apologize for any inconvenience this may cause and thank you for your understanding.
View full article
MCUの選択とディスプレイサイズは? 皆さんこんにちは。私は、地元の駅の公開APIを通じて、私の住む都市のリアルタイム列車データを取得する小さなプロジェクトに取り組んでいます。最終的にはこれをマイクロコントローラーで画面に表示し、壁に看板を貼りたいと思っています。おすすめのMCUやディスプレイはありますか?ディスプレイは大きめのものが欲しいです(できれば幅30cm以上)。これまでmBedや小型液晶ディスプレイ付きのArduinoしか扱ったことがないので、どんなご提案でも歓迎します。
View full article
クーポンは無効です FRDM-MCXN236 無料ボードのクーポンコードで問題が発生している方はいらっしゃいますか? NXPは無料ボードを宣伝していますが、製品の在庫があるのにチェックアウト時にクーポンコードが無効と表示されます。これはシステム上の不具合でしょうか?他にも同じ問題が発生している方はいらっしゃいますか? 公開板 FRDM培训 Re: Coupon not valid FRDM-MCXN236 残念ながら、弊社のマーケティングチームから、このクーポンは既に利用期限に達しており、これ以上の延長はできないとの連絡を受けました。 このクーポンは今後数日以内に削除されます。ご迷惑をおかけして申し訳ございませんが、ご理解いただけますようお願い申し上げます。
View full article
MCU choice and Display size? Hello all, I'm working on a small project that gets my local station's real time train data for my city via their public API. I want to ultimately display this on a screen, via a micro controller and attach the sign to my wall. Do you have any MCU/display recommendations? I'm wanting the display to be on the larger side (maybe at least 30cm in width if possible). Open to any suggestions, as I've only worked with mBeds and Arduinos with rather small lcd displays before.
View full article
智能卡读卡器有哪些好用途? 我的 Thinkpad T15 笔记本电脑配备了智能卡读卡器,而我竟然一年后才知道。 它有什么很棒的用途吗?在工作中,我们用它们来加密邮件,但这并不是用于私人用途的。我相信它肯定有很多好玩的用途。 Smart Card Re: Good uses for Smartcard Reader? 您好,先生, 我是客服部的 Fabian。 您可能已经看到,智能卡读卡器支持多种应用,其中身份验证和访问控制是最常见的应用之一。但是请注意,该读卡器本身仅提供符合 ISO/IEC 7816-4 标准的通信。要开发完整的解决方案并运行智能卡,您需要联想提供的相应中间件或启用软件,以及来自合格卡提供商的智能卡。 如需更多指导,请参阅我们的合作伙伴目录,了解推荐的供应商和解决方案提供商。
View full article
i.MX9 ELE 的已知问题 根据 2025 年的讨论,i.MX 9 存在一个问题,即安全世界和非安全世界同时使用其 MU 与 ELE 通信。讨论中提到,计划在 2025 年第三季度修复该问题。这个修复程序发布了吗?该修复是在 ELE 固件中实现的,还是需要修改 Cortex A55 代码?如果该修复程序已在 ELE 固件中实现,那么哪个固件版本是第一个包含该修复程序的? 根据i.MX Linux 发行说明 (RN00210),电压变化会导致已知的 ELE 问题。这个问题会造成什么影响?即使发送了 ELE_VOLT_CHANGE_START_REQ 请求,电压故障检测器也会触发吗?电压变化会对随机数生成器产生影响吗?RN00210 仅针对 i.MX 93 提到了该问题。与 i.MX 91 非常相似的机型是否也受到影响? 背景:我们需要从 OP-TEE 内部可靠地访问 ELE,但我们不能指望 Linux 能够正常运行。 安全 Re: Known issues with i.MX9 ELE 你好, 您是在寻找特定型号的 i.MX9 吗? 这会影响该系列中的不同处理器,例如,在 i.MX91/93 上,OPTEE 使用专用的 Trusted MU 进行通信,因此这些处理器不受影响。 关于 ELE 电压变化问题,这是一个命令排序问题,而不是随机数据损坏问题。在接受 ELE_VOLT_CHANGE_START_REQ 后,ELE 会暂时禁用其电压故障传感器,并立即期望收到 ELE_VOLT_CHANGE_FINISH_REQ。因此,并发的 HRNG 请求可能会失败或挂起;如果完成请求延迟超过超时时间,ELE 可能会中止序列并 RESET SoC。 最后,i.MX 91 通常只在标称驱动电压和低驱动电压之间切换,两者之间的差异约为 50 mV,预计不会触发 GDET,因此它不受此问题的影响。 此致敬礼/Saludos, 阿尔多。 Re: Known issues with i.MX9 ELE 我在最初的问题中链接的讨论听起来像是并发 ELE 请求存在问题,尽管安全世界有自己的 MU。引用讨论中的内容: >>>>>> I'm aware that the >>>>>> i.MX93 has two MUs one for the secure and one for the non-secure >>>>>> world. But I'm really concerned about the fact that both MUs can't >>>>>> be used at the same time from both world: >>>>> >>>>> Yes, you are correct. >>>>> >>>>> Fix is still work in progress. Marco Felsch 在 GitHub 上链接到了 NXP 一位工程师的这条评论: 当内核和 OP-TEE 同时向 ELE 发出请求时,就会出现问题,而这并非 RNG 特有的问题。我们正在努力解决这个问题,很快就会有解决方案。 那么,这个解决方案已经发布了吗? 当非安全世界滥用 ELE_VOLT_CHANGE_START_REQ 来停止安全世界中的随机数生成时,重置 SoC 听起来是可以接受的。
View full article
MCU选择和显示屏尺寸? 大家好,我正在做一个小项目,通过公共 API 获取我所在城市的本地车站的实时列车数据。我最终想通过微控制器将此内容显示在屏幕上,并将标牌固定在墙上。您对MCU/显示器有什么推荐吗?我希望显示屏尺寸大一些(如果可能的话,宽度至少要30厘米)。欢迎提出任何建议,因为我之前只使用过带小型液晶显示屏的mBed和Arduino。
View full article
优惠券无效 FRDM-MCXN236 还有其他人遇到免费板优惠券代码无法使用的问题吗? NXP 正在宣传赠送一块免费电路板供用户入门,但结账时优惠券代码显示无效,即使该产品显然有库存。这是系统故障吗?还有其他人遇到这个问题吗? 开发板 FRDM培训 Re: Coupon not valid FRDM-MCXN236 很遗憾,我们的市场营销团队通知我们,此优惠券已达到使用上限,不会再延长有效期。 优惠券将在未来几天内失效。由此给您带来的不便,我们深表歉意,并感谢您的理解。
View full article
Known issues with i.MX9 ELE According to this discussion from 2025 there was an issue on i.MX 9 when both the secure and non-secure world were using their MUs at the same time to communicate with the ELE. In the discussion it was said that a fix was planned for Q3 2025. Has this fix been released? Is the fix implemented in the ELE firmware or did it need modifications to the Cortex A55 code? If it was implemented in the ELE firmware, which firmware version was the first one to contain the fix? According to the i.MX Linux Release Notes (RN00210) there is a known ELE problem with voltage changes. What is the impact of this problem? Will the voltage glitch detector trigger even if ELE_VOLT_CHANGE_START_REQ was sent? Or will the voltage change impact the random number generator? RN00210 mentions the problem only for i.MX 93. Is the very similar i.MX 91 affected as well? Background: We need reliable access to the ELE from within OP-TEE and can't trust Linux to behave nicely. Security Re: Known issues with i.MX9 ELE Hello, Are you looking for an specific i.MX9? This impact different processors in the familly, for example on the i.MX91/93 OPTEE uses a dedicated Trusted MU for the communication so this processors are no impacted. Regarding ELE voltage change issue, the issue is a command-sequencing problem, not corruption of random data. After ELE_VOLT_CHANGE_START_REQ is accepted, ELE temporarily disables its voltage-glitch sensors and expects ELE_VOLT_CHANGE_FINISH_REQ immediately. A concurrent HRNG request can therefore fail or hang; if the finish request is delayed beyond the timeout, ELE may abort the sequence and reset the SoC. And finally no, i.MX 91 normally switches only between nominal and low-drive voltage, with an approximately 50 mV difference that is not expected to trigger GDET, so it is not considered affected by this same issue. Best regards/Saludos, Aldo. Re: Known issues with i.MX9 ELE The discussion I linked in my initial question sounds like there were problems with concurrent ELE requests although the secure world has its own MU. To quote from the discussion: >>>>>> I'm aware that the >>>>>> i.MX93 has two MUs one for the secure and one for the non-secure >>>>>> world. But I'm really concerned about the fact that both MUs can't >>>>>> be used at the same time from both world: >>>>> >>>>> Yes, you are correct. >>>>> >>>>> Fix is still work in progress. Marco Felsch linked to this comment from an NXP engineer on Github: Problem comes when doing simultaneous request to ELE from Kernel and OP-TEE not specific to RNG, and we are working on the solution, which will be available soon. So, has this solution been made available? Resetting the SoC when the non-secure world abuses ELE_VOLT_CHANGE_START_REQ to stop random number generation in the secure world sounds acceptable.
View full article
Good uses for Smartcard Reader? My Thinkpad T15 has a smartcard reader and I didn’t even know for a year. Is there some cool use for it? At work we use those to encrypt mails but that’s not really something for private use. I’m sure there must be cool things to do with it. Smart Cards Re: Good uses for Smartcard Reader? Hello Sir, This is Fabian from Customer Support. As you may have already seen, smart card readers support a wide range of applications, with authentication and access control being among the most common. However, please note that the reader itself only provides communication compliant with the ISO/IEC 7816-4 standard. To develop a complete solution and operate smart cards, you will need appropriate middleware or enablement software from Lenovo, as well as smart cards from a qualified card provider. For additional guidance, please refer to our Partner Directory for recommended vendors and solution providers.
View full article
スマートカードリーダーの便利な活用法は? 私のThinkPad T15にはスマートカードリーダーが搭載されているのに、1年間もそのことに気づかなかった。 何か面白い使い道はあるの?職場ではメールの暗号化にそれらを使用していますが、それは個人的な用途にはあまり適していません。きっと何か面白い使い道があるはずだ。 スマート・カード Re: Good uses for Smartcard Reader? お世話になります。 こちらはカスタマーサポートのファビアンです。 すでにご覧の通り、スマートカードリーダーは幅広い用途に対応しており、認証やアクセス制御はその中でも最も一般的なものです。ただし、リーダー自体はISO/IEC 7816-4規格に準拠した通信のみを提供する点にご注意ください。完全なソリューションを開発しスマートカードを運用するには、Lenovoの適切なミドルウェアやイネーブルメントソフトウェア、そして資格を持つカードプロバイダーのスマートカードが必要です。 追加のガイダンスについては、推奨ベンダーやソリューションプロバイダーについてはパートナー一覧をご参照ください。
View full article
GPIO 简介:如何读取微控制器 (MCX A153) 的引脚并控制 LED(日语博客) 目录 介绍 了解MCX A153微控制器的引脚配置 GPIO 使用设置 检查引脚与电路板(FRDM-MCXA153)之间的关系。 演示:执行 GPIO 设置并体验 LED 控制。 额外知识点:了解LED灯的“开/关”原理 附加题——如果将两个LED并联会发生什么?   介绍 作为嵌入式系统开发的初学者,我是在接到撰写一篇关于GPIO文章的邀请后开始学习它的。本文记录了我尝试点亮单个LED灯的过程中,通过反复试验所学到的知识和心得体会。 本文解释了如何使用 GPIO(通用输入/输出),它是微控制器开发中最基本的外部设备之一。 GPIO 是嵌入式系统的基础,用于将微控制器连接到外部电路,实现诸如打开 LED、读取开关状态和接收来自传感器的信号等功能。 另一方面,在实际的微控制器开发中,“使用GPIO”并不仅仅意味着编写程序。微控制器有许多引脚,每个引脚除了GPIO之外还被分配了其他功能,例如定时器和通信接口。 所以, 要使用 GPIO,您需要了解数据手册中的引脚分配和功能。 PinMUX(引脚复用)设置,用于将GPIO分配给引脚 输入/输出方向设置 这件事必须妥善处理。 这次,我们将以FRDM-MCXA153为例,研究 MCX A153 的引脚配置和 PinMUX 机制,使用 Pins Tool 配置 GPIO 设置,最后演示连接到面包板上的 LED 闪烁。   了解MCX A153微控制器的引脚配置 FRDM-MCXA153搭载了一颗型号为 MCXA153VLH 的微控制器。该微控制器采用 LQFP 64 封装,共有 64 个引脚。其中 52 个引脚可用作 GPIO。其余引脚包括电源引脚 (VDD/VSS)、USB 引脚和模拟输入引脚,这些引脚不能用作 GPIO。 然而,即使它标有“52个GPIO”,这并不意味着这52个引脚都专用于GPIO。许多可用于GPIO的引脚也与其他外设功能(例如UART、SPI、I²C和定时器)共享。因此,要真正将它们用作GPIO,您需要使用PinMUX函数将这些引脚配置为GPIO。 让我们从数据手册中查看MCX A153的引脚配置。从第54页开始列出了每个引脚可以分配的功能。 例如,查看引脚名称为 P1_8 的“引脚复用分配”信息,可以看到有六种可能的功能。GPIO 被分配到“ALT0 - P1_8”。其他分配包括“ALT2 - LPUART1_RXD”,表示它将被用作 UART 接收端 (RXD);以及“ALT3 - LPI2C0_SDA”,表示它将被用作 I²C 数据线 (SDA)。 如您所见,一个引脚可以分配给多个功能,不仅包括 GPIO,还包括 UART、I²C 和定时器。   GPIO 使用设置 1. 选择引脚功能(PinMUX) 如前文所述,P1_8 引脚有多种潜在功能,包括 GPIO、UART 和 I²C。但是,同一个引脚不能同时用作 GPIO 和 UART。 因此,典型的微控制器都配备了一种称为 PinMUX 的机制。 PinMUX 就像一个拨动开关,用于将单个物理引脚连接到内部外设。 例如,P1_8 有六个潜在的连接目标。通过使用 PinMUX 选择 GPIO,P1_8 即可用作 GPIO 引脚。 2. 设置引脚的电气特性。 引脚不仅可以配置其功能,还可以配置其电气特性。典型设置包括: • 引体向上 • 下拉 驱动力 明渠 以下是一些示例。例如,开关输入通常会启用上拉电阻,驱动 LED 或高速信号时可以调整驱动强度。即使用作 GPIO,也必须根据应用进行适当的电气设置。 本文将省略对这些电气特性的详细解释。 3. 设置 GPIO 的输入/输出方向。 最后一步是确定信号流的方向。GPIO 有两种主要的工作模式。 • 输入 – 接收来自外部的信号 • 输出 – 向外部发送信号 微控制器内部在输入输出方面究竟发生了什么? MCX A153 是一款工作电压为 3.3V 的微控制器。因此,其 GPIO 引脚基本上处理两种状态:低电平(约 0V)和高电平(约 3.3V)。A153 的工作电压范围为 1.71V 至 3.6V,FRDM 板使用 3.3V。 GPIO输出值 引脚电压 低(0) 大约 0V 高(1) 约3.3伏 例如,如果您将某个 GPIO 引脚设置为输出并连接一个外部 LED,将其设置为高电平(约 3.3V)会在 GPIO 引脚和 GND 之间产生电位差,从而允许电流流过 LED。将其设置为低电平(约 0V)会消除与 GND 之间的电位差,因此没有电流流过。换句话说,LED 的“闪烁”是由于 GPIO 引脚的电压在高电平 (1) 和低电平 (0) 之间反复切换,从而导致 LED 闪烁和熄灭交替发生。 另一方面,在输入模式下,微控制器会监控GPIO引脚的状态。例如,如果从外部电路输入约3.3V电压,则识别为高电平(1);如果输入约0V电压,则识别为低电平(0)。 上述引脚功能选择、电气特性设置和输入/输出设置均可通过 GUI 使用引脚工具(NXP 的免费配置工具中包含)进行配置。   检查引脚与电路板(FRDM-MCXA153)之间的关系。 到目前为止,我们已经了解到,要使用 GPIO,需要配置 PinMUX 设置和输入/输出方向设置。 接下来,让我们确认 FRDM-MCXA153 板上 MCU 引脚的连接位置,同时牢记我们将要进行的演示。 检查原理图,确认上一章中作为示例使用的引脚“P1_8”的布线位置。 查看电路图第 8 页,我们可以看到 P1_8 连接到 FRDM-MCXA153 上的Arduino 接头 J2 的 D18 。 FRDM-MCXA153原理图 那么,Arduino 接头 J2 上的 D18 在哪里呢? 接下来,我们来查阅一下电路板用户手册。 FRDM-MCXA153 开发板用户手册 第 6 页包含板上安装的连接器的示意图,这使我能够确定 Arduino 接头 J2 上的 D18 的位置。 在本练习中,我们将使用面包板上的 D18 引脚连接一个外部 LED。但是,如果您没有面包板或 LED,也可以使用 FRDM-MCXA153 开发板上自带的 RGB LED。 然而,有一点需要注意。当使用板载 RGB LED 时,LED 的阳极 (+) 连接到 VDD_BOARD (3.3V),阴极 (-) 连接到 GPIO。因此,与前面提到的外接 LED 不同,将 GPIO 设置为高电平 (1) 也会使 GPIO 电压达到约 3.3V,LED 两端的电位差几乎消失,导致 LED 熄灭。 另一方面,将 GPIO 设置为低电平 (0) 会在 LED 两端产生电位差,从而导致电流流动并使 LED 点亮。 当你检查电路图中的每个引脚时…… P3_12 是一个红色 LED P3_13 是一个绿色 LED P3_0 是一个蓝色 LED 它支持这些功能。通过配置引脚复用器 (PinMUX) 设置和输入/输出设置,您还可以使用板上的 LED 指示灯来验证其运行情况。 这样,您就可以使用电路图和电路板用户手册来检查微控制器内部的物理引脚在电路板上的连接位置。   演示:执行 GPIO 设置并体验 LED 控制。 在本章中,我们将使用 MCUXpresso 配置工具中的引脚工具来配置 GPIO 并控制面包板上外部连接的 LED。 演示中使用的设备: FRDM-MCXA153 面包板 LED • 电阻器和跳线 本演示将假设您已在 VS Code 环境中安装了 MCUXpresso SDK 和配置工具。 *如果您尚未安装 MCUXpresso SDK 和配置工具,请参阅此博客文章。 MCUXpresso 配置工具:引脚工具的使用方法(日语博客) 注意:虽然博客文章描述了 FRDM-MCXN947 的 SDK 安装,但本文中请安装 FRDM-MCXA153 的 SDK。 我手头有一个红色LED和一个绿色LED,但我不知道它们的型号,所以我先尝试点亮红色LED。我有一个390Ω的电阻。红色LED的正向电压(Vf)通常在1.8~2.2V之间,所以我假设它是2.0V,并计算流过LED的电流。 微控制器的工作电压为3.3V。Vf使用 2.0V 电压和 390Ω 电阻,可以根据欧姆定律计算电流值,如下所示。请注意,LED 具有规定的最大正向电流 (Ifmax),许多通用 LED 的 Ifmax 为 20mA。务必谨慎选择电阻值,因为超过 20mA 的电流可能会损坏 LED。 此外,GPIO引脚的输出电流也有限制。根据数据手册,MCX A153在正常工作状态下的电气特性是基于4mA电流(高驱动引脚为6mA)设定的。因此,当使用GPIO引脚直接点亮LED时,需要选择一个合适的电阻值,该电阻值不仅要考虑LED的电流限制,还要考虑GPIO引脚的电流限制。 电路板和面包板接线 首先,我们要进行线路连接。 在 FRDM 板上,我们将使用之前确定的 Arduino 接头 J2 上的“D18”和“14 GND” 。 下图是根据电路板用户手册绘制的。 FRDM-MCXA153 开发板用户手册 请参考以下视频了解接线说明。 (function() { var wrapper = document.getElementById('lia-vid-6405195304112w960h540r888'); var videoEl = wrapper ? wrapper.querySelector('video-js') : null; if (videoEl) { if (window.videojs) { window.videojs(videoEl).ready(function() { this.on('loadedmetadata', function() { this.el().querySelectorAll('.vjs-load-progress div[data-start]').forEach(function(bar) { bar.setAttribute('role', 'presentation'); bar.setAttribute('aria-hidden', 'true'); }); }); }); } }})(); (显示我的视频) 导入示例代码 接下来,我们将从 FRDM-MCXA153 SDK 导入示例代码。 点击左侧面板中的“从存储库导入示例”。 在右侧显示的选项卡中,选择“存储库”下的导入的 FRDM-MCXA153 SDK,然后选择“板”下的 FRDM-MCXA153。 使用的模板是“driver_examples/gpio/gpio_led_output”。 选择所需的工具链,然后单击“导入”。 导入完成后,它将被添加到左侧面板的“项目”部分。 查看源代码 gpio_led_output.c。 这次,我们要使用引脚工具配置 GPIO 输入/输出设置,因此我们将从源代码中删除红色方框内包含的 GPIO 输出设置代码。 使用引脚工具配置GPIO设置。 接下来,打开配置工具。右键单击项目,然后选择“使用 MCUXpresso 配置工具打开”。稍等片刻,配置工具将启动。 打开配置工具后,首先在右侧面板的“概览”中选择“引脚”。 图钉工具现已打开。 启用引脚 P1_8。 点击 P1_8 将打开另一个窗口,如下图所示。在此窗口中找到“GPIO1:GPIO,8(P1_8)”,并勾选其旁边的复选框。 选中该复选框后,将出现以下窗口,但您可以单击“否”将其关闭。 完成这些步骤后,P1_8 将添加到引脚工具底部的布线详细信息中。 接下来,按如下方式更改 GPIO 输入/输出设置。 将输出端的引脚 #38 (P3_12) 连接到未指定端,将未指定端的引脚 #2 (P1_8) 连接到输出端。 GPIO #38 的初始状态将出现错误,请将其从逻辑 0 更改为 n/a。 完成这些步骤后,您就可以重写示例代码了。首先,点击“配置工具”屏幕左上角的“更新代码”。 此时会弹出一个窗口。您可以在这里根据需要查看代码更改。已修改的文件旁边会显示“更改”字样。 返回 VS Code 后,您会在屏幕顶部看到三个复选框。请确保选中它们,然后单击“确定”。 不久之后,源代码的修改就会完成。 接下来,我们将修改源代码 gpio_led_output.c 中的 GPIO 控制目标。 打开 gpio_led_output.c 文件时, 内容如下:   while (1) { delay(); GPIO_PortToggle(BOARD_LED_GPIO, 1u << BOARD_LED_GPIO_PIN); } 按如下方式修改 GPIO_PinInit() 和 GPIO_PortToggle() 的内容: 这里,P1_8 被指定为控制目标,每次调用该函数时,P1_8 的状态都会在高 (1) 和低 (0) 之间切换。 while (1) { delay(); GPIO_PortToggle(GPIO1, 1u << 8); } 更多详情:GPIO 引脚以 Px_y 格式表示,其中x为 GPIO 端口号, y为该端口内的位位置。例如, P1_8表示“GPIO 端口 1 的第 8 位”。 在代码中 GPIO_PortToggle(GPIO1, 1U << 8); 在, GPIO1 1U << 8 表示 GPIO 端口 1, 是一个位掩码,其中只有第 8 位设置为 1。 1U << 8 ↓ 0000 0001 0000 0000 (2進数) 这样就可以只反转(在高电平和低电平之间切换)GPIO 端口 1 中的第 8 位。 将 PC 连接到 FRDM-MCXA153。 调试(构建、编写和运行应用程序)。 调试过程完成后,程序将在断点处停止,因此请点击屏幕顶部的“|▶”图标。 LED灯将开始闪烁。 (function() { var wrapper = document.getElementById('lia-vid-6404528566112w304h540r105'); var videoEl = wrapper ? wrapper.querySelector('video-js') : null; if (videoEl) { if (window.videojs) { window.videojs(videoEl).ready(function() { this.on('loadedmetadata', function() { this.el().querySelectorAll('.vjs-load-progress div[data-start]').forEach(function(bar) { bar.setAttribute('role', 'presentation'); bar.setAttribute('aria-hidden', 'true'); }); }); }); } }})(); (显示我的视频) 额外知识——了解 LED 的“开/关”状态 顺便问一下,这个LED灯何时亮起,取决于GPIO输出是高电平(1)还是低电平(0)?我之前提到过,当输出高电平(1)时它会亮起,但我们来验证一下是否正确。 以下是我们之前使用的代码。 `while(1)` 语句表示一个无限循环,重复执行花括号 {} 内的代码。 此外,delay() 函数用于等待特定时间段。GPIO_PortToggle() 是一个 GPIO 控制函数,用于反转高电平 (1) 和低电平 (0)。 while (1) { delay(); GPIO_PortToggle(GPIO1, 1u<<8); } } 但是,这段代码并没有告诉我们,当 LED 为高电平 (1) 或低电平 (0) 时,LED 是亮起还是熄灭。 因此,我们使用不同的函数 GPIO_PinWrite() 来显式控制 GPIO 的状态。 具体来说,代码将修改为在高电平 (1) 状态下等待一次 delay() 调用,然后在低电平 (0) 状态下等待五次 delay() 调用。这样应该能让 LED 保持熄灭状态更长时间。 while (1) { GPIO_PinWrite (GPIO1,8U ,1); delay(); GPIO_PinWrite(GPIO1,8U ,0); delay(); delay(); delay(); delay(); delay(); } 运行调试程序,然后点击屏幕顶部的“|▶”图标。 (function() { var wrapper = document.getElementById('lia-vid-6404528052112w304h540r114'); var videoEl = wrapper ? wrapper.querySelector('video-js') : null; if (videoEl) { if (window.videojs) { window.videojs(videoEl).ready(function() { this.on('loadedmetadata', function() { this.el().querySelectorAll('.vjs-load-progress div[data-start]').forEach(function(bar) { bar.setAttribute('role', 'presentation'); bar.setAttribute('aria-hidden', 'true'); }); }); }); } }})(); (显示我的视频) 正如预期的那样,LED灯关闭了更长时间。 这使我们能够验证 LED 在点亮时输出高电平 (1),在熄灭时输出低电平 (0)。 总结一下,当 GPIO 为高电平 (1) 时,设置为 GPIO 引脚的 P1_8 处的电压约为 3.3V。该电压与 GND 之间形成电位差,导致电流流过电阻和 LED。此时,LED 两端施加正向电压(约 2.0V),剩余的约 1.3V 电压施加在电阻两端。因此,LED 点亮。 另一方面,当 GPIO 为低电平 (0) 时,P1_8 端的电压接近 0V。由于 GPIO 引脚与 GND 之间没有电位差,因此没有电流流过,LED 熄灭。 如果你觉得使用大量的 `delay()` 函数看起来很丑陋,你也可以使用循环函数。 while (1) { GPIO_PinWrite(GPIO1, 8U, 1); delay(); GPIO_PinWrite(GPIO1, 8U, 0); for (int i = 0; i < 5; i++) { delay(); } } 附加题——如果将两个LED并联会发生什么? 我尝试将手边的一个绿色LED与一个红色LED并联起来。 由于绿色 LED 的正向电压 (Vf) 一般为 2.0 至 2.2V,我假设它与红色 LED 类似,为 2.0V,并搭建了以下电路。 由于无需更改引脚设置,我使用之前的代码进行调试,红色 LED 闪烁,但绿色 LED 没有闪烁。这是为什么呢? (function() { var wrapper = document.getElementById('lia-vid-6404530194112w304h540r514'); var videoEl = wrapper ? wrapper.querySelector('video-js') : null; if (videoEl) { if (window.videojs) { window.videojs(videoEl).ready(function() { this.on('loadedmetadata', function() { this.el().querySelectorAll('.vjs-load-progress div[data-start]').forEach(function(bar) { bar.setAttribute('role', 'presentation'); bar.setAttribute('aria-hidden', 'true'); }); }); }); } }})(); (显示我的视频) LED的特性是,当正向电压(Vf)超过其值时,电流会迅速增加。因此,如果将一个红色LED和一个绿色LED简单地并联,电流会集中在Vf较低的LED上,而另一个LED可能几乎不会发光。在这种情况下,红色LED的Vf低于绿色LED,因此电流集中在红色LED上。 当我用测试仪实际测量 LED 两端的电压时,红色 LED 的电压为 1.765V,绿色 LED 的电压为 1.766V。 在这个电压下,红色LED可以点亮,但绿色LED接收到的电压不足以产生足够的电流。因此,红色LED会亮,而绿色LED不会亮,因为几乎没有电流流过它。 如上图所示,简单地将不同类型的LED并联,即使正向电压(Vf)存在微小差异,也会导致电流出现显著偏差。因此,并联LED时,通常的做法是为每个LED串联一个限流电阻。 添加电阻时,需要考虑 GPIO 的电流限制。如果我们像之前那样直接添加一个 390Ω 的电阻并计算电流,那么施加到 GPIO 上的电流将超过 6mA。因此,为了确保总电流不超过 4mA,我们连接了两个 680Ω 的电阻,并搭建了以下电路。 当我再次调试同一段代码时,红色和绿色 LED 都亮了起来。 (function() { var wrapper = document.getElementById('lia-vid-6405719291112w304h540r698'); var videoEl = wrapper ? wrapper.querySelector('video-js') : null; if (videoEl) { if (window.videojs) { window.videojs(videoEl).ready(function() { this.on('loadedmetadata', function() { this.el().querySelectorAll('.vjs-load-progress div[data-start]').forEach(function(bar) { bar.setAttribute('role', 'presentation'); bar.setAttribute('aria-hidden', 'true'); }); }); }); } }})(); (显示我的视频) 测量LED两端的电压时,红色LED的电压为1.750V,绿色LED的电压为1.906V。通过在每个LED上串联一个电阻,可以使合适的电流流过每个LED。 本文解释了嵌入式开发初学者会遇到的“问题”和“障碍”,内容涵盖如何解读各种文档、使用配置工具以及LED的工作原理等。我们希望本文能对那些首次尝试使用NXP微控制器实现LED闪烁的用户有所帮助。 =========================​ 我们目前无法 回复 此帖子“ 评论”部分留下的评论。 对于由此造成的不便,我们深表歉意,但 在进行咨询时, 请 参考“ NXP 技术问题 - 如何联系我们 ( 日语博客 ) ” 。 (如果您已经是 恩智浦的 分销商或 与 恩智浦 有合作关系 ,您可以直接咨询您的代表。) 本文以 LED 闪烁为例,解释了如何使用 GPIO(通用输入/输出),这是微控制器开发中最基本的外部设备之一。 GPIO 是许多微控制器开发人员最先接触的外设之一。很多人想用 GPIO 来点亮 LED,但他们可能不知道如何阅读数据手册或如何配置引脚。本文以 FRDM-MCXA153 为例,讲解 GPIO 的基础知识,面向微控制器开发初学者。我们将学习如何从数据手册和电路图中读取引脚信息,如何使用引脚工具配置设置,并最终体验如何控制外部 LED。 (预计时间:15 分钟)*假设开发环境已安装。 MCUXpresso MCUXpresso 配置工具 MCUXpresso IDE MCUXpresso SDK MCX 日本博客
View full article
GPIO入門:マイコン(MCX A153)のピンを読み解き、LEDを制御する方法(日本語ブログ) 目次 はじめに MCX A153マイコンのピン構成を理解する GPIOを使用するための設定 ピンとボード(FRDM-MCXA153)の関係を確認する デモンストレーション:GPIO設定を行いLED制御を体感する おまけ LEDの「点・滅」について理解する おまけ – 2つのLEDを並列に接続したら?   はじめに 組み込み開発初心者である筆者は、「GPIOについて記事を書いてほしい」という依頼をきっかけにGPIOの学習を始めました。本記事は、LEDを一つ点灯させるために試行錯誤する中で学んだ内容や気づきを、備忘録としてまとめたものです。 本記事では、マイコンを使った開発において最も基本的なペリフェラルの一つであるGPIO(General Purpose Input/Output)の使い方を解説します。 GPIOは、LEDを点灯したり、スイッチの状態を読み取ったり、センサからの信号を受け取ったりと、マイコンと外部回路をつなぐための組み込みシステムの基盤となっています。 一方で、実際のマイコン開発において、「GPIOを使う」と言っても、単にプログラムを書くだけではありません。マイコンには多数のピンが存在し、それぞれのピンにはGPIO以外にもタイマや通信インターフェースなどの機能が割り当てられています。 そのため、 GPIOを利用するには、データシートからピンの配置や機能を理解すること GPIOをピンに割り当てるためのPinMUX(ピン・マルチプレックス)設定 入出力方向の設定 を適切に行う必要があります。 今回はFRDM-MCXA153を題材に、MCX A153のピン構成やPinMUXの仕組みを確認しながら、Pins Tool上でGPIO設定を行い、最終的にはブレッドボード上に接続したLED点滅のデモンストレーションを紹介します。   MCX A153マイコンのピン構成を理解する FRDM-MCXA153にはMCXA153VLHという型番のマイコンが搭載されています。このマイコンはLQFP 64パッケージを採用しており、全部で64本のピンが存在します。そのうち52本がGPIOとして利用可能です。残りは電源端子(VDD/VSS)やUSB端子、アナログ専用端子などGPIOとして利用できない端子で構成されています。 ただし、「52本のGPIOがある」といっても、52本のGPIO専用ピンが用意されているわけではありません。GPIOとして利用可能なピンの多くは、UARTやSPI、I²C、タイマなどの周辺機能と共有されています。そのため、実際にGPIOとして利用する際には、PinMUX機能を使い、そのピンをGPIOとして動作させるための設定が必要になります。 MCX A153のピン構成をデータシートから確認してみます。54ページ以降に各ピンに割り当て可能な機能が一覧で記載されています。 例えば、Pin Name :P1_8 の「Pinmux Assignment」を見ると、6つの機能候補があります。GPIOは”ALT0 - P1_8”が該当します。他にも”ALT2 - LPUART1_RXD”はUARTの受信端子(RXD)、”ALT3 - LPI2C0_SDA”はI²Cデータ線(SDA)として使用することを意味します。 このように1本のピンに対してGPIOだけでなく、UARTやI²C、タイマなどの複数の機能が割り振られていることがわかります。   GPIOを使用するための設定 1. ピン機能の選択(PinMUX) 前節で確認したように、P1_8にはGPIO、UART、I²Cなど複数の機能候補が存在します。しかし、同じピンを同時にGPIOとUARTとして利用することはできません。 そこで一般的なマイコンには PinMUXという仕組みが用意されています。 PinMUXは、1本の物理ピンと内部ペリフェラルを接続するための切替スイッチのようなものです。 例えばP1_8には6つの接続先候補がありました。PinMUXによってGPIOを選択すると、P1_8はGPIOとして利用することができるようになります。 2. ピンの電気的特性を設定する ピンには機能だけでなく、電気的な振る舞いも設定できます。 代表的な設定として、 ・Pull-up(プルアップ) ・Pull-down(プルダウン) ・Drive Strength(ドライブ強度) ・Open Drain(オープンドレイン) などがあります。 例えばスイッチ入力ではプルアップ抵抗を有効にすることが多く、LEDや高速信号を駆動する場合にはドライブ強度を調整することがあります。 GPIOとして使用する場合でも、アプリケーションに応じた適切な電気的設定を行うことが重要です。 本記事ではこの電気的特性に関する詳細な説明は割愛します。 3. GPIOの入出力方向を設定する 最後に決めるのが信号の流れる方向です。GPIOには大きく分けて2つの動作モードがあります。 ・Input(入力) – 外部から信号を受け取る ・Output(出力) – 外部へ信号を出力する Input・Outputとはマイコン内部で何が起こっているのでしょうか? MCX A153は3.3Vで動作するマイコンです。そのためGPIOピンは、基本的にLow(約0V)とHigh(約3.3V)の2つの状態を扱います(なお、MCX A153の動作電圧範囲は1.71V〜3.6Vであり、FRDMボードでは3.3Vが採用されています)。 GPIO出力値 ピン電圧 Low (0) 約0V High (1) 約3.3V 例えば特定のGPIOピンをOutputに設定し、外部にLEDを接続した場合、High(約3.3V)にするとGPIOとGNDの間に電位差が生じ、LEDに電流が流れ、Low(約0V)の状態にするとGNDとの電位差がなくなるので電流が流れなくなります。つまり、LEDの”点滅”はGPIOピンの電圧をHigh(1)とLow(0)の間で切り替えることで点滅と消灯という動作を繰り返していることになります。 一方、InputではGPIOピンの状態をマイコンが監視します。例えば外部回路から約3.3Vが入力されればHigh(1)、約0Vが入力されればLow(0)として認識します。 ここまで説明したピンの機能選択・電気的特性の設定・入出力設定はPins Tool(Pins ToolはNXPが無償提供しているConfig Toolsに含まれます)を用いてGUI上で設定することが可能です。   ピンとボード(FRDM-MCXA153)の関係を確認する ここまでで、GPIOを利用するためにはPinMUX設定や入出力方向の設定が必要であることが分かりました。 続いて今回のデモンストレーションを想定し、MCUのピンがFRDM-MCXA153ボード上のどこに接続されているのかを確認しておきましょう。 Schematics(回路図)を確認し、前章で例として取り上げたピン "P1_8"はどこに引き出されているのかを確認します。 回路図の8ページを見てみると、P1_8はFRDM-MCXA153上にあるArduinoヘッダー: J2のD18に接続されていることがわかります。 FRDM-MCXA153 Schematics では、Arduinoヘッダー J2のD18とはどこでしょうか? 続いてBoard User Manualを確認します。 FRDM-MCXA153 Board User Manual 6ページ目にボードに搭載されているコネクタの外観図が載っており、ArduinoヘッダーJ2のD18はどこかを特定することができました。 今回は勉強のため、D18ピンからブレッドボードを経由してLEDを外部接続しますが、ブレッドボードやLEDをお持ちでない場合は、FRDM-MCXA153のボード上に搭載されているRGB LEDを活用することができます。 ただし一点注意があります。ボード上のRGB LEDを使用する場合はLEDのアノード側(+)がVDD_BOARD(3.3V)に接続されており、カソード側(-)がGPIOに接続されています。そのため、先ほどの外部接続したLEDとは逆でGPIOをHigh(1)にするとGPIO側も約3.3Vとなり、LED両端の電位差がほとんどなくなるためLEDは消灯します。 一方、GPIOをLow(0)にするとLED両端に電位差が生じて電流が流れ、LEDは点灯します。 回路図でそれぞれのピンを確認すると P3_12は赤色LED P3_13は緑色のLED P3_0は青色LED に対応しています。これらのPinMUX設定や入出力設定を行うことでボードに搭載されているLEDを使った動作を確認することもできます。 このように回路図やBoard User Manualを使って、マイコン内部の物理ピンがボード上のどこに接続されているかを確認することができます。   デモンストレーション:GPIO設定を行いLED制御を体感する この章では、MCUXpresso Config Toolsの Pins Tool を使用してGPIOの設定を行い、ブレッドボード上に外部接続したLEDを制御してみます。 デモンストレーションで使用した備品 ・FRDM-MCXA153 ・ブレッドボード ・LED ・抵抗 ・ジャンパ線 また今回はVS Code環境にてMCUXpresso SDKとConfig Toolsをインストール済みという前提でデモンストレーションを進めます。 ※MCUXpresso SDKとConfig Toolsのインストールがお済みでない方はこちらのブログをご参照ください。 MCUXpresso Config Tools : Pins Toolの使い方 (日本語ブログ) 注意:ブログ内ではFRDM-MCXN947のSDKをインストールしていますが本記事においてはFRDM-MCXA153のSDKをインストールしてください。 手元に品番不明の赤色LEDと緑色LEDがあったので、まずは赤色LEDの点灯から試してみます。抵抗は390Ωのものがありました。赤色LEDの順方向電圧(Vf)は一般的に1.8~2.2Vのため、仮に2.0VとしてLEDに流れる電流値を求めます。 マイコンの動作電圧は3.3Vです。Vf 2.0Vと抵抗390Ωを用いると、オームの法則から以下のように電流値が求められます。なおLEDには最大順方向電流(Ifmax)が規定されており、多くの汎用LEDでは20mAと言われています。20mAを超える電流が流れると破損する可能性があるので抵抗値にはご注意ください。 また、GPIOにも出力可能な電流に制限があります。データシートを参照するとMCX A153の通常動作時の電気特性は4mA(High Drive対応ピンでは6mA)を基準として規定されています。このため、GPIOからLEDを直接点灯する場合は、LEDだけでなくGPIO側の電流制限も考慮して抵抗値を選定する必要があります。 ボードとブレッドボードの配線 はじめに配線を行います FRDMボード上では、先ほど特定した ArduinoヘッダーJ2の"D18"と"14 GND"を使用します。 以下の図はBoard User Manualを参照しています。 FRDM-MCXA153 Board User Manual 以下の動画を参考に配線してください。 (function() { var wrapper = document.getElementById('lia-vid-6405195304112w960h540r888'); var videoEl = wrapper ? wrapper.querySelector('video-js') : null; if (videoEl) { if (window.videojs) { window.videojs(videoEl).ready(function() { this.on('loadedmetadata', function() { this.el().querySelectorAll('.vjs-load-progress div[data-start]').forEach(function(bar) { bar.setAttribute('role', 'presentation'); bar.setAttribute('aria-hidden', 'true'); }); }); }); } }})(); (マイビデオを表示) サンプルコードのインポート 続いて、FRDM-MCXA153のSDKからサンプルコードのインポートへ進みます。 左側のパネルから「Import Example From Repository」をクリックしてください。 右側に表示された各タブ内で、「Repository」ではインポートしたFRDM-MCXA153のSDKを選択、「Board」はFRDM-MCXA153を選択してください。 「Template」は、「driver_examples/gpio/gpio_led_output」を使用します。 任意のToolchainを選択して、「Import」をクリックしてください。 Importが完了すると左側のパネルのProjectsに追加されます。 ソースコード gpio_led_output.cを確認します。 今回は、Pins Toolを用いてGPIOの入出力設定を行いたいので、ソースコード側から赤枠で囲んだGPIO出力設定に関する記述を削除します。 Pins ToolでGPIOの設定を行う 続いてConfig Toolsを開きます。Project上で右クリックして「Open with MCUXpresso Config Tools」を選択してください。少し待つとConfig Toolsが立ち上がります。 Config Toolsが開いたらまずは右側のパネルにあるOverviewよりPinsを選択します。 これでPins Toolが開いた状態になりました。 ピンP1_8を有効にします。 P1_8をクリックすると、下記画像のように別のWindowが開くので、ここから「GPIO1:GPIO,8(P1_8)」を探して✓を入れてください。 ✓を入れると同時に下記のWindowが表示されますがNoで閉じていただいて問題ありません。 ここまで完了するとPins Tool下部のRouting DetailsにP1_8が追加されます。 続いてGPIOの入出力設定を以下のように変更します。 #38(P3_12)のピンをOutput → Not Specifiedへ、#2(P1_8)のピンをNot Specified → Output へ。 #38のGPIO initial stateにエラーが出ますので、Logical 0→n/aへ変更してください。 ここまで完了したらサンプルコードを書き換えます。まずはConfig Toolsの画面左上にあるUpdate Codeをクリックしてください。 その後Windowが表示されます。ここで必要に応じてコードの変更点を確認することができます。変更が生じたファイルには「change」の記載があります。 VS Codeに戻ると、画面上部に3つのチェックボックスが表示されているので✓が入った状態でOKをクリックします。 少し時間が経つと、ソースコードへの変更が完了します。 続いてソースコード gpio_led_output.cよりGPIOの制御対象を変更します。 gpio_led_output.cを開くと、 以下の記述があります。   while (1) { delay(); GPIO_PortToggle(BOARD_LED_GPIO, 1u << BOARD_LED_GPIO_PIN); } GPIO_PinInit()およびGPIO_PortToggle()の中身を以下のように変更します。 ここではP1_8を制御対象として指定しており、関数が呼ばれるたびにP1_8の状態がHigh(1)とLow(0)の間で切り替わります。 while (1) { delay(); GPIO_PortToggle(GPIO1, 1u << 8); } さらに詳しく:GPIOピンは Px_y という形式で表記されます。ここで x はGPIOポート番号、y はそのポート内のビット位置を表します。例えば P1_8 は「GPIOポート1の8ビット目」を意味します。 コード中の GPIO_PortToggle(GPIO1, 1U << 8); において、 GPIO1 はGPIOポート1を表し、 1U << 8 は8ビット目だけを1にしたビットマスクです。 1U << 8 ↓ 0000 0001 0000 0000 (2進数) となり、GPIOポート1の中の8ビット目のみを反転(HighとLowを切り替える)させることができます。 PCとFRDM-MCXA153を接続します。 デバッグ(ビルド&書き込み&アプリケーションの実行)します。 デバッグのプロセスが完了したら、プログラムがブレイクポイントで止まっているので、画面上部のアイコン内の"|▶"をクリックします。 LEDが点滅を開始します。 (function() { var wrapper = document.getElementById('lia-vid-6404528566112w304h540r105'); var videoEl = wrapper ? wrapper.querySelector('video-js') : null; if (videoEl) { if (window.videojs) { window.videojs(videoEl).ready(function() { this.on('loadedmetadata', function() { this.el().querySelectorAll('.vjs-load-progress div[data-start]').forEach(function(bar) { bar.setAttribute('role', 'presentation'); bar.setAttribute('aria-hidden', 'true'); }); }); }); } }})(); (マイビデオを表示) おまけ – LEDの「点・滅」について理解する  ところで、このLEDはGPIOからHigh(1) , Low(0) どちらを出力したときに点灯しているのでしょうか?先ほどはHigh(1)を出力したときに点灯していると言及しましたが、本当か検証してみます。 以下が先ほど使用したコードです。 while(1)は無限ループを意味し、波括弧{}の中の処理を繰り返し実行します。 また、delay()は一定時間待機するための関数です。GPIO_PortToggle()はGPIO制御関数なので、High(1)とLow(0)を反転します。 while (1) { delay(); GPIO_PortToggle(GPIO1, 1u<<8); } } しかしながら、このコードではLEDがHigh(1)のときに点灯しているのか、Low(0)のときに点灯しているのかがわかりません。 そこで異なる関数GPIO_PinWrite() を使用して、GPIOの状態を明示的に制御します。 具体的には以下のようにHigh(1)の状態でdelay()1回分待機し、その後Low(0)の状態でdelay()5回分待機するコードへ変更します。これでLEDの消灯時間のほうが長くなるはずです。 while (1) { GPIO_PinWrite (GPIO1,8U ,1); delay(); GPIO_PinWrite(GPIO1,8U ,0); delay(); delay(); delay(); delay(); delay(); } デバッグを実行し、画面上部のアイコン内の"|▶"をクリックします。 (function() { var wrapper = document.getElementById('lia-vid-6404528052112w304h540r114'); var videoEl = wrapper ? wrapper.querySelector('video-js') : null; if (videoEl) { if (window.videojs) { window.videojs(videoEl).ready(function() { this.on('loadedmetadata', function() { this.el().querySelectorAll('.vjs-load-progress div[data-start]').forEach(function(bar) { bar.setAttribute('role', 'presentation'); bar.setAttribute('aria-hidden', 'true'); }); }); }); } }})(); (マイビデオを表示) 狙い通り、LEDの消灯時間のほうが長くなりました。 これによりLEDが点灯しているときにはHigh(1)を出力し、消灯しているときにはLow(0)を出力していることが検証できました。 おさらいすると、GPIOがHigh(1)になると、GPIOピンとして設定したP1_8は約3.3Vになります。GNDとの間に電位差が生じるため、抵抗とLEDを通して電流が流れます。このときLEDの両端には順方向電圧(約2.0V)がかかり、残りの約1.3Vが抵抗にかかります。その結果、LEDが発光します。 一方、GPIOがLow(0)になるとP1_8の電圧は約0Vになります。GPIOピンとGNDの間に電位差がなくなるため電流は流れず、LEDは消灯します。 delay()がたくさん並ぶのはかっこ悪いという方はループ関数も使えます。 while (1) { GPIO_PinWrite(GPIO1, 8U, 1); delay(); GPIO_PinWrite(GPIO1, 8U, 0); for (int i = 0; i < 5; i++) { delay(); } } おまけ – 2つのLEDを並列に接続したら? 手元にあった緑色のLEDを赤色LEDと並列接続しようと試みました。 緑色の順方向電圧(Vf)は一般的に2.0~2.2Vのため、赤色LEDと同様に仮に2.0Vとして以下のような回路を組みました。 ピンの設定は変える必要がないため、そのまま先ほど使ったコードでデバッグを行ったところ、赤色LEDは点滅しますが緑色LEDは点滅しません。なぜでしょうか? (function() { var wrapper = document.getElementById('lia-vid-6404530194112w304h540r514'); var videoEl = wrapper ? wrapper.querySelector('video-js') : null; if (videoEl) { if (window.videojs) { window.videojs(videoEl).ready(function() { this.on('loadedmetadata', function() { this.el().querySelectorAll('.vjs-load-progress div[data-start]').forEach(function(bar) { bar.setAttribute('role', 'presentation'); bar.setAttribute('aria-hidden', 'true'); }); }); }); } }})(); (マイビデオを表示) LEDには、順方向電圧(Vf)を超えると急激に電流が流れ始めるという特性があります。そのため赤色LEDと緑色LEDを単純に並列接続すると、Vfの低いLEDに電流が集中し、もう一方はほとんど点灯しないことがあります。つまり今回の場合は赤色LEDのVfが緑色LEDに比べて低いので、赤色LEDに電流が集中したという状態となっています。 実際にテスターでLED両端の電圧を測定したところ、赤色LEDは1.765V , 緑色LEDは1.766Vでした。 この電圧では赤色LEDは発光できるものの、緑色LEDは十分な電流が流れるほどの電圧に達していません。その結果、赤色LEDには電流が流れて点灯しますが、緑色LEDにはほとんど電流が流れず点灯しませんでした。 このように、LEDを異なる種類のまま単純に並列接続すると、わずかなVfの差によって電流の流れ方が大きく偏ることがあります。そのためLEDを並列接続する場合は、LEDごとに電流制限抵抗を設けるのが一般的です。 抵抗を追加する際にはGPIOの電流制限を考慮する必要があります。単純にこれまで使ってきた390Ωをひとつ追加して電流値を計算すると計算上では6mAを超える電流がGPIOに掛かってしまいます。したがって、総電流が4mA超えないよう680Ωの抵抗を2つ接続し、以下のような回路を組みました。 再度同じコードでデバッグを行ったところ、赤色LED、緑色LEDともに点灯しました。 (function() { var wrapper = document.getElementById('lia-vid-6405719291112w304h540r698'); var videoEl = wrapper ? wrapper.querySelector('video-js') : null; if (videoEl) { if (window.videojs) { window.videojs(videoEl).ready(function() { this.on('loadedmetadata', function() { this.el().querySelectorAll('.vjs-load-progress div[data-start]').forEach(function(bar) { bar.setAttribute('role', 'presentation'); bar.setAttribute('aria-hidden', 'true'); }); }); }); } }})(); (マイビデオを表示) LED両端の電圧を測定したところ、赤色LEDは1.750V , 緑色LEDは1.906Vでした。抵抗をそれぞれのLEDに追加したことで、各LEDに適切な電流が流れるようになりました。 以上、今回は各種ドキュメントの読み解き方、Config Toolsの使い方からLEDの動作原理にいたるまで組み込み開発初心者の目線から「困った」「詰まった」点を解説しました。NXPマイコンを使って初めてLチカにチャレンジするという方のご参考になれば幸いです。 =========================​ 本投稿の「Comment」欄にコメントをいただいても、現在返信に対応しておりません。​ お手数をおかけしますが、お問い合わせの際には「NXPへの技術質問 - 問い合わせ方法 (日本語ブログ)」をご参照ください。​ (既に弊社NXP代理店、もしくはNXPとお付き合いのある方は、直接担当者へご質問いただいてもかまいません。) マイコンを使った開発において最も基本的なペリフェラルの一つであるGPIO(General Purpose Input/Output)をLEDの点滅を例に使い方を解説します。 GPIOは多くのマイコン開発者が最初に学ぶペリフェラルです。GPIOを使ってLEDを光らせてみたいけれど、「データシートの見方がわからない」「ピンの設定方法がわからない」という方も多いのではないでしょうか。本記事ではマイコン開発初心者向けに、FRDM-MCXA153を使ったGPIO入門を解説します。データシートや回路図からピン情報を読み解き、Pins Toolを使った設定を行いながら、最終的に外部LEDの制御を体験します。 (作業時間:15分) ※開発環境をインストール済みの前提 MCUXpresso MCUXpresso Conig Tools MCUXpresso IDE MCUXpresso SDK MCX 日本語ブログ
View full article
GPIO Introduction: How to Read the Pins of a Microcontroller (MCX A153) and Control an LED (Japanese Blog) table of contents Introduction Understanding the pin configuration of the MCX A153 microcontroller Settings for using GPIO Check the relationship between the pins and the board (FRDM-MCXA153). Demonstration: Perform GPIO settings and experience LED control. Bonus: Understanding the "on/off" of LEDs Bonus – What happens if you connect two LEDs in parallel?   Introduction As a beginner in embedded systems development, I began learning about GPIO after receiving a request to write an article about it. This article is a record of what I learned and the insights I gained through trial and error while trying to light up a single LED. This article explains how to use GPIO (General Purpose Input/Output), one of the most basic peripherals in microcontroller development. GPIO is the foundation of embedded systems for connecting microcontrollers to external circuits, enabling functions such as turning on LEDs, reading the state of switches, and receiving signals from sensors. On the other hand, in actual microcontroller development, "using GPIO" doesn't simply mean writing a program. Microcontrollers have numerous pins, and each pin is assigned functions other than GPIO, such as timers and communication interfaces. Therefore, To use GPIO, you need to understand the pin assignments and functions from the datasheet. PinMUX (pin multiplex) settings for assigning GPIO to pins Input/Output Direction Settings This needs to be done properly. This time, using the FRDM-MCXA153 as an example, we will examine the pin configuration of the MCX A153 and the mechanism of PinMUX, configure GPIO settings using Pins Tool, and finally demonstrate blinking LEDs connected to a breadboard.   Understanding the pin configuration of the MCX A153 microcontroller The FRDM-MCXA153 is equipped with a microcontroller with the model number MCXA153VLH. This microcontroller uses an LQFP 64 package and has a total of 64 pins. Of these, 52 are available as GPIOs. The remaining pins consist of power terminals (VDD/VSS), USB terminals, and analog-only terminals, which cannot be used as GPIOs. However, even though it has "52 GPIOs," this doesn't mean that 52 pins are dedicated to GPIO. Many of the pins available for GPIO use are shared with peripheral functions such as UART, SPI, I²C, and timers. Therefore, to actually use them as GPIOs, you need to use the PinMUX function to configure those pins to function as GPIOs. Let's check the pin configuration of the MCX A153 from the datasheet . A list of functions that can be assigned to each pin is provided starting on page 54. For example, looking at the "Pinmux Assignment" for Pin Name: P1_8, there are six possible functions. GPIO is assigned to "ALT0 - P1_8". Other assignments include "ALT2 - LPUART1_RXD" which means it will be used as the UART receive terminal (RXD), and "ALT3 - LPI2C0_SDA" which means it will be used as the I²C data line (SDA). As you can see, a single pin can be assigned to multiple functions, including not only GPIO but also UART, I²C, and timers.   Settings for using GPIO 1. Select pin function (PinMUX) As confirmed in the previous section, P1_8 has several potential functions, including GPIO, UART, and I²C. However, the same pin cannot be used as both GPIO and UART simultaneously. Therefore, typical microcontrollers are equipped with a mechanism called PinMUX. PinMUX is like a toggle switch for connecting a single physical pin to an internal peripheral. For example, P1_8 had six potential connection destinations. By selecting GPIO using PinMUX, P1_8 becomes available for use as a GPIO pin. 2. Set the electrical characteristics of the pins. Pins can be configured not only for their function but also for their electrical behavior. Typical settings include: • Pull-up • Pull-down Drive Strength Open Drain These are some examples. For instance, pull-up resistors are often enabled for switch inputs, and the drive strength may be adjusted when driving LEDs or high-speed signals. Even when used as GPIO, it is important to make appropriate electrical settings according to the application. This article will omit a detailed explanation of these electrical characteristics. 3. Set the input/output direction of the GPIO. The final step is determining the direction in which the signal flows. GPIO has two main operating modes. • Input – Receives signals from the outside • Output – Sends signals to the outside What exactly is happening inside the microcontroller when it comes to Input and Output? The MCX A153 is a microcontroller that operates at 3.3V. Therefore, the GPIO pins basically handle two states: Low (approximately 0V) and High (approximately 3.3V).The A153 has an operating voltage range of 1.71V to 3.6V, and 3.3V is used for the FRDM board. GPIO output values Pin voltage Low (0) Approximately 0V High (1) Approximately 3.3V For example, if you set a specific GPIO pin to Output and connect an external LED, setting it to High (approximately 3.3V) creates a potential difference between the GPIO and GND, allowing current to flow through the LED. Setting it to Low (approximately 0V) eliminates the potential difference with GND, so no current flows. In other words, the "blinking" of the LED is caused by repeatedly switching the voltage of the GPIO pin between High (1) and Low (0), alternating between blinking and being off. On the other hand, in Input mode, the microcontroller monitors the state of the GPIO pins. For example, if approximately 3.3V is input from an external circuit, it is recognized as High (1), and if approximately 0V is input, it is recognized as Low (0). The pin function selection, electrical characteristic settings, and input/output settings described above can all be configured via a GUI using the Pins Tool (which is included in NXP's free Config Tools).   Check the relationship between the pins and the board (FRDM-MCXA153). So far, we've learned that in order to use GPIO, you need to configure PinMUX settings and input/output direction settings. Next, let's confirm where the MCU pins are connected on the FRDM-MCXA153 board, keeping in mind the demonstration we'll be performing. Check the schematics and confirm where pin "P1_8", which was used as an example in the previous chapter, is routed. Looking at page 8 of the circuit diagram, we can see that P1_8 is connected to D18 of Arduino header J2 on the FRDM-MCXA153. FRDM-MCXA153 Schematics So, where is D18 on the Arduino header J2? Next, let's check the Board User Manual. FRDM-MCXA153 Board User Manual Page 6 contains a diagram of the connectors mounted on the board, which allowed me to identify the location of D18 on the Arduino header J2. For this learning exercise, we will connect an external LED via a breadboard using the D18 pin. However, if you do not have a breadboard or LED, you can use the RGB LED mounted on the FRDM-MCXA153 board. However, there is one point to note. When using the RGB LED on the board, the anode (+) of the LED is connected to VDD_BOARD (3.3V), and the cathode (-) is connected to GPIO. Therefore, unlike the externally connected LED mentioned earlier, setting GPIO to High (1) will also bring the GPIO voltage to approximately 3.3V, and the potential difference across the LED will almost disappear, causing the LED to turn off. On the other hand, setting GPIO to Low (0) creates a potential difference across the LED, causing current to flow and the LED to light up. When you check each pin in the circuit diagram... P3_12 is a red LED P3_13 is a green LED P3_0 is a blue LED It supports these features. By configuring these PinMUX settings and input/output settings, you can also verify the operation using the LEDs on the board. In this way, you can use the circuit diagram and the Board User Manual to check where the physical pins inside the microcontroller are connected on the board.   Demonstration: Perform GPIO settings and experience LED control. In this chapter, we will use the Pins Tool in MCUXpresso Config Tools to configure GPIO and control an externally connected LED on a breadboard. Equipment used in the demonstration: FRDM-MCXA153 Breadboard LED • Resistors and jumper wires This demonstration will assume that you have already installed the MCUXpresso SDK and Config Tools in your VS Code environment. *If you have not yet installed the MCUXpresso SDK and Config Tools, please refer to this blog post. MCUXpresso Config Tools: How to Use the Pins Tool (Japanese Blog) Note: While the blog post describes installing the SDK for FRDM-MCXN947, please install the SDK for FRDM-MCXA153 in this article. I had a red LED and a green LED on hand, but I didn't know the part numbers, so I'll start by trying to light up the red LED. I had a 390Ω resistor. The forward voltage (Vf) of a red LED is generally 1.8~2.2V, so I'll assume it's 2.0V and calculate the current flowing through the LED. The microcontroller's operating voltage is 3.3V. VfUsing 2.0V and a 390Ω resistor, the current value can be calculated using Ohm's law as follows. Note that LEDs have a specified maximum forward current (Ifmax), which is said to be 20mA for many general-purpose LEDs. Be careful with the resistance value, as currents exceeding 20mA may cause damage. Furthermore, GPIO pins also have limitations on the current they can output. According to the datasheet, the MCX A153's electrical characteristics during normal operation are specified based on 4mA (6mA for High Drive pins). Therefore, when directly lighting an LED using a GPIO pin, you need to select a resistor value that takes into account not only the LED's current limit but also the GPIO's current limit. Board and breadboard wiring First, we'll do the wiring. On the FRDM board, we will use "D18" and "14 GND" on the Arduino header J2 that we identified earlier . The following diagram is based on the Board User Manual. FRDM-MCXA153 Board User Manual Please refer to the following video for wiring instructions. (function() { var wrapper = document.getElementById('lia-vid-6405195304112w960h540r888'); var videoEl = wrapper ? wrapper.querySelector('video-js') : null; if (videoEl) { if (window.videojs) { window.videojs(videoEl).ready(function() { this.on('loadedmetadata', function() { this.el().querySelectorAll('.vjs-load-progress div[data-start]').forEach(function(bar) { bar.setAttribute('role', 'presentation'); bar.setAttribute('aria-hidden', 'true'); }); }); }); } }})(); (Show My Videos) Importing sample code Next, we will proceed to import the sample code from the FRDM-MCXA153 SDK. Click "Import Example From Repository" in the panel on the left. In the tabs displayed on the right, select the imported FRDM-MCXA153 SDK under "Repository" and select FRDM-MCXA153 under "Board". The template used is "driver_examples/gpio/gpio_led_output". Select your desired Toolchain and click "Import". Once the import is complete, it will be added to the Projects section in the left-hand panel. Check the source code gpio_led_output.c. This time, we want to configure GPIO input/output settings using Pins Tool, so we will remove the GPIO output setting code enclosed in the red box from the source code. Configure GPIO settings using Pins Tool. Next, open Config Tools. Right-click on the Project and select "Open with MCUXpresso Config Tools". After a short wait, Config Tools will launch. Once Config Tools opens, first select Pins from Overview in the right-hand panel. The Pins Tool is now open. Enable pin P1_8. Clicking on P1_8 will open another window as shown in the image below. Find "GPIO1:GPIO,8(P1_8)" in this window and check the box next to it. When you check the box, the following window will appear, but you can close it by clicking No. Once you've completed these steps, P1_8 will be added to the Routing Details at the bottom of the Pins Tool. Next, change the GPIO input/output settings as follows. Connect pin #38 (P3_12) from Output to Not Specified, and pin #2 (P1_8) from Not Specified to Output. An error will occur in the GPIO initial state of #38, so please change it from Logical 0 to n/a. Once you've completed these steps, you can rewrite the sample code. First, click Update Code in the upper left corner of the Config Tools screen. A window will then appear. Here you can review the code changes as needed. Files that have been modified will have "change" written next to them. When you return to VS Code, you will see three checkboxes at the top of the screen. Make sure they are checked and click OK. After a short while, the changes to the source code will be completed. Next, we will change the target of GPIO control in the source code gpio_led_output.c. When you open gpio_led_output.c, The following is stated:   while (1) { delay(); GPIO_PortToggle(BOARD_LED_GPIO, 1u << BOARD_LED_GPIO_PIN); } Modify the contents of GPIO_PinInit() and GPIO_PortToggle() as follows: Here, P1_8 is specified as the control target, and each time the function is called, the state of P1_8 switches between High (1) and Low (0). while (1) { delay(); GPIO_PortToggle(GPIO1, 1u << 8); } Further details: GPIO pins are represented in the format Px_y, where x is the GPIO port number and y represents the bit position within that port. For example, P1_8 means "bit 8 of GPIO port 1". In the code GPIO_PortToggle(GPIO1, 1U << 8); In, GPIO1 1U << 8 represents GPIO port 1, is a bitmask where only the 8th bit is set to 1. 1U << 8 ↓ 0000 0001 0000 0000 (2進数) This allows you to invert (switch between High and Low) only the 8th bit in GPIO port 1. Connect the PC to the FRDM-MCXA153. Debugging (build, write, and run the application). Once the debugging process is complete, the program will have stopped at the breakpoint, so click the "|▶" icon at the top of the screen. The LED will start blinking. (function() { var wrapper = document.getElementById('lia-vid-6404528566112w304h540r105'); var videoEl = wrapper ? wrapper.querySelector('video-js') : null; if (videoEl) { if (window.videojs) { window.videojs(videoEl).ready(function() { this.on('loadedmetadata', function() { this.el().querySelectorAll('.vjs-load-progress div[data-start]').forEach(function(bar) { bar.setAttribute('role', 'presentation'); bar.setAttribute('aria-hidden', 'true'); }); }); }); } }})(); (Show My Videos) Bonus – Understanding LED "on/off" By the way, when does this LED light up, based on whether the GPIO outputs High (1) or Low (0)? Earlier I mentioned that it lights up when High (1) is output, but let's verify if that's true. The following is the code we used earlier. The `while(1)` statement implies an infinite loop, repeatedly executing the code within the curly braces {}. Additionally, delay() is a function for waiting for a certain period of time. GPIO_PortToggle() is a GPIO control function, so it inverts High (1) and Low (0). while (1) { delay(); GPIO_PortToggle(GPIO1, 1u<<8); } } However, this code doesn't tell us whether the LED is lit when it's High (1) or Low (0). Therefore, we use a different function, GPIO_PinWrite(), to explicitly control the state of the GPIO. Specifically, the code will be changed to wait for one delay() call while in a High (1) state, and then wait for five delay() calls while in a Low (0) state. This should make the LED stay off for a longer period of time. while (1) { GPIO_PinWrite (GPIO1,8U ,1); delay(); GPIO_PinWrite(GPIO1,8U ,0); delay(); delay(); delay(); delay(); delay(); } Run the debug and click the "|▶" icon at the top of the screen. (function() { var wrapper = document.getElementById('lia-vid-6404528052112w304h540r114'); var videoEl = wrapper ? wrapper.querySelector('video-js') : null; if (videoEl) { if (window.videojs) { window.videojs(videoEl).ready(function() { this.on('loadedmetadata', function() { this.el().querySelectorAll('.vjs-load-progress div[data-start]').forEach(function(bar) { bar.setAttribute('role', 'presentation'); bar.setAttribute('aria-hidden', 'true'); }); }); }); } }})(); (Show My Videos) As intended, the LEDs were turned off for a longer period. This allowed us to verify that the LED outputs High (1) when it is lit and Low (0) when it is off. To recap, when the GPIO goes high (1), the voltage at P1_8, which is set as the GPIO pin, becomes approximately 3.3V. A potential difference is created between this voltage and GND, causing current to flow through the resistor and the LED. At this time, a forward voltage (approximately 2.0V) is applied across the LED, and the remaining approximately 1.3V is applied across the resistor. As a result, the LED lights up. On the other hand, when GPIO goes low (0), the voltage at P1_8 becomes approximately 0V. Since there is no potential difference between the GPIO pin and GND, no current flows, and the LED turns off. If you think having a lot of `delay()` functions looks ugly, you can also use loop functions. while (1) { GPIO_PinWrite(GPIO1, 8U, 1); delay(); GPIO_PinWrite(GPIO1, 8U, 0); for (int i = 0; i < 5; i++) { delay(); } } Bonus – What happens if you connect two LEDs in parallel? I tried connecting a green LED I had on hand in parallel with a red LED. Since the forward voltage (Vf) of a green LED is generally 2.0 to 2.2V, I assumed it to be 2.0V, similar to the red LED, and built the following circuit. Since there was no need to change the pin settings, I debugged using the same code as before, and the red LED blinked, but the green LED did not. Why is that? (function() { var wrapper = document.getElementById('lia-vid-6404530194112w304h540r514'); var videoEl = wrapper ? wrapper.querySelector('video-js') : null; if (videoEl) { if (window.videojs) { window.videojs(videoEl).ready(function() { this.on('loadedmetadata', function() { this.el().querySelectorAll('.vjs-load-progress div[data-start]').forEach(function(bar) { bar.setAttribute('role', 'presentation'); bar.setAttribute('aria-hidden', 'true'); }); }); }); } }})(); (Show My Videos) LEDs have the characteristic that current starts flowing rapidly when the forward voltage (Vf) is exceeded. Therefore, if a red LED and a green LED are simply connected in parallel, the current will concentrate on the LED with the lower Vf, and the other LED may hardly light up at all. In this case, the Vf of the red LED is lower than that of the green LED, so the current is concentrated on the red LED. When I actually measured the voltage across the LEDs with a tester, the red LED was 1.765V and the green LED was 1.766V. At this voltage, the red LED can light up, but the green LED does not receive enough voltage to generate sufficient current. As a result, the red LED lights up, but the green LED does not light up because almost no current flows through it. As shown above, simply connecting different types of LEDs in parallel can cause significant bias in current flow due to even small differences in forward voltage (Vf). Therefore, when connecting LEDs in parallel, it is common practice to install a current-limiting resistor for each LED. When adding resistors, you need to consider the GPIO current limit. If you simply add one more 390Ω resistor as we've been using and calculate the current, the calculated current applied to the GPIO will exceed 6mA. Therefore, to ensure the total current does not exceed 4mA, we connected two 680Ω resistors and built the following circuit. When I debugged the same code again, both the red and green LEDs lit up. (function() { var wrapper = document.getElementById('lia-vid-6405719291112w304h540r698'); var videoEl = wrapper ? wrapper.querySelector('video-js') : null; if (videoEl) { if (window.videojs) { window.videojs(videoEl).ready(function() { this.on('loadedmetadata', function() { this.el().querySelectorAll('.vjs-load-progress div[data-start]').forEach(function(bar) { bar.setAttribute('role', 'presentation'); bar.setAttribute('aria-hidden', 'true'); }); }); }); } }})(); (Show My Videos) When the voltage across the LEDs was measured, the red LED was 1.750V and the green LED was 1.906V. By adding a resistor to each LED, the appropriate current was able to flow through each LED. In this article, we've explained the "problems" and "stumbling blocks" encountered by a beginner in embedded development, from how to interpret various documents and use Config Tools to the operating principles of LEDs. We hope this will be helpful for those attempting to blink an LED for the first time using an NXP microcontroller. =========================​ 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 explains how to use GPIO (General Purpose Input/Output), one of the most basic peripherals in microcontroller development, using the blinking of an LED as an example. GPIO is one of the first peripherals that many microcontroller developers learn about. Many people want to use GPIO to light up an LED, but they may not know how to read the datasheet or how to configure the pins. This article explains the basics of GPIO using the FRDM-MCXA153, aimed at beginners in microcontroller development. We will learn to read pin information from the datasheet and circuit diagram, configure settings using Pins Tool, and finally experience controlling an external LED. (Estimated time: 15 minutes) *Assuming the development environment is already installed. MCUXpresso MCUXpresso Configuration Tools MCUXpresso IDE MCUXpresso SDK MCX Japanese Blog
View full article