Multi Source Translation Content

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

Multi Source Translation Content

Discussions

Sort by:
[FRDM-MCXA153] LPI2C 新手指南(日语博客) 介绍 本文面向微控制器初学者,讲解了恩智浦半导体 (NXP) MCX A153微控制器的外设功能和使用方法。您将通过实际修改恩智浦提供的 SDK 示例程序来学习基本概念和实现方法。 目录   1. 应用中的常见用法示例(I²C 版) 1.1 主要用途 1.2 使用示例 2. I²C 基础知识 2.1 首先,I²C 是什么? 2.2 微控制器 I²C 模块 3. MCX A153 I²C 模块 (LPI2C) 的主要功能和框图 3.1 概述 3.2 方框图 3.3 功能 4. 使用的设备和开发工具 4.1 评估委员会 (FRDM-MCXA153) 4.2 开发工具(适用于 VS Code 和 IDE 的 MCUXpresso) 5. 编程 5.1 检查基础示例代码的内容 5.2 引脚配置 5.3 程序代码的更改 6. 实践训练 6.1 实践培训内容 6.2 实践练习程序 6.3 在评估板上添加上拉电阻 6.4 编码更改 6.5 使用引脚配置器更改引脚设置 6.6 构建与调试、测试功能   1. 应用中的常见用法示例(I²C 版)   本章要点:我们将研究 I²C 的应用场景。   1.1 主要用途 I²C 是一种通过指定设备内部寄存器地址来读写数据的通信方式。由于它使用的信号线较少,因此适合控制单个电路板上的多个集成电路。然而,它容易受到线路电容和噪声的影响,因此通常用于短距离通信。 连接各种传感器,例如温度传感器、加速度传感器和磁传感器。 数字电位器 IO扩展器 EEPROM 实时控制器 显示设备(LCD、LED 等)的输入/输出扩展 微控制器之间的通信(包含在 FRDM-MCXA153 评估板上的示例程序中) 1.2 使用示例 实际应用包括计算机主板、嵌入式系统和移动电话。   2. I²C 基础知识   本章要点:我们将阐明 I²C 的基本术语,包括 SDA、SCL、地址、ACK/NACK 和上拉电阻。   2.1 首先,I²C 是什么? I²C是由飞利浦半导体(现为恩智浦半导体)开发的一种串行总线通信标准。目前,它被广泛用作连接电路板上传感器和外围集成电路的代表性方法。 I²C 是一种同步串行通信方法,它通过时钟信号同步发送数据。数据线称为 SDA,时钟线称为 SCL。通信通过控制 SDA 和 SCL 的时序来实现。 每个从设备都有一个唯一的地址,主设备通过指定该地址进行通信。通信开始时发送地址后,目标从设备会返回一个 ACK(确认)。如果无法收到 ACK,则不返回 ACK,这称为 NACK(非确认)。 通信采用由起始条件、地址、读/写位、ACK/NACK 和停止条件组成的协议进行。 地址可以采用 7 位模式或 10 位模式。 I²C 是一种开漏协议。上拉电阻使 SDA 和 SCL 通常保持高电平,各个器件在需要时将其拉低。因此,通信线路上必须有上拉电阻。 通常使用微控制器作为主设备。有两种方法可以确定通信是否完成:一种是使用从设备的中断,另一种是轮询方法,即主设备反复检查完成标志。使用中断时,每个从设备都必须有一个中断输出,而主设备必须有一个中断输入。使用中断可以加快响应速度,但会增加硬件资源消耗。 有关 I²C 的更多详细信息,请参阅以下文章。 I²C 总线概述(日本博客) 这次,我们将采用轮询方法来匹配评估板的接线情况。 标准模式下的典型传输速度为 100kbps,快速模式下为 400kbps。MCX A153 还支持快速模式增强版,最高通信速度可达 1Mbps。 主设备向从设备发送数据的步骤如下: 主控端发起通信。 主设备指定从设备地址。 从主站向从站发送数据 主控端终止了通信。 相反,主设备从从设备接收数据的过程如下: 主控端发起通信。 主设备指定从设备地址。 主设备从从设备接收数据。 主控端终止了通信。   2.2 微控制器 I²C 模块 下图显示了微控制器中常见的 I²C 模块的框图。 组件数量并不多。主要组件包括用于发送缓冲区的命令/TX FIFO、用于接收缓冲区的RXFIFO、配置寄存器以及控制通信的控制电路。此外,现在大多数微控制器都内置了噪声滤波器。 3. MCX A153 I²C 模块 (LPI2C) 的主要功能和框图   本章要点:我们将研究通用 I²C 和 MCX A153 的 LPI2C 模块之间的区别。   3.1 概述 到目前为止,我们已经介绍了通用 I²C 的基本原理,但本章将重点介绍 MCX A153 的 LPI2C I²C 模块。LPI2C 的功能远比上述基本 I²C 模块强大。LPI2C 支持以主设备(控制器)和从设备(目标设备)两种身份高效地与 I²C 总线连接。 主要功能如下。 支持标准、高速、高速+、HS模式(仅限目标)和超高速运行模式的逻辑。 通过 DMA 将对 FIFO 的访问卸载到 CPU,从而最大限度地减少了 CPU 开销。 LPI2C 也符合系统管理总线 (SMBus) 规范版本 3。 *注1 MCX A153 参考手册中“主站和控制器”以及“从站和目标站”这两个术语交替使用。虽然现在推荐使用“控制器”和“目标站”,但本文档将统一使用“主站和从站”。 3.2 方框图 MCX A153 的 LPI2C 模块上半部分为主控部分,下半部分为从控部分。SDA 和 SCL 模块也分为主控版和从控版,从控版型号后加“S”,因此分别为 SDAS 和 SCLS。通信也可以通过外部 HREQ 端子或内部触发信号启动。 3.3 功能 LPI2C的功能如下: 标准模式、高速模式、高速+模式、超高速模式 多控制器(包括同步和仲裁) 时钟拉伸 仲裁(当系统有多个控制器时) 7位寻址,10位寻址 软件重置、起始字节、设备 ID(还需要软件支持)。 命令和发送 FIFO(4 个字,8 位发送数据 + 3 位命令) 接收到的 FIFO(4 个字,8 位接收数据) 主机请求输入以控制 I²C 总线传输的启动时间 根据接收到的数据匹配情况生成中断,并拒绝不需要的数据。 用于重复启动条件、停止条件、仲裁丢失、意外 NACK 和命令字错误的标志和可选中断信号。 可配置总线空闲超时和引脚堆栈低电平超时。 独立的I²C目标寄存器 7位或10位寻址 支持中断或DMA请求的发送/接收数据寄存器 ACK 或 NACK 可以通过软件控制。 可以配置时钟拉伸来避免发送 FIFO 欠载和接收 FIFO 过载错误。 数据包终止标志和可选的中断、停止条件或位错误检测。 4. 使用的设备和开发工具   4.1 评估委员会 (FRDM-MCXA153) 本次实践练习将使用 Windows PC 和 MCX A153 的FRDM-MCXA153评估套件(使用 MCUXpresso 的 FRDM-MCXA153 开发板 | NXP Semiconductors)。 FRDM-MCXA153 随附一根 USB Type-C 数据线。点击网站上的“设计文件”即可获取 FRDM-MCXA153 的电路板信息和电路图。(需注册账号) FRDM-MCXA153 配备了P3T1755温度传感器。初始状态下,P3T1755 连接到 I3C0,因此这次我们将更改引脚设置,将其连接到 LPI2C,并使用 LPI2C 读取温度。 由于 P3T1755 和 LPI2C 之间没有连接中断线,因此 LPI2C 将用作轮询主控端。此外,由于 MCX A153 和 P3T1755 的信号线上没有上拉电阻,因此需要添加外部电阻。 4.2 开发工具(适用于 VS Code 和 IDE 的 MCUXpresso) 本文将指导您如何使用 MCUXpresso for VS Code 或 MCUXpresso IDE 编辑和运行 SDK 示例。开发工具是创建项目、编辑代码、配置设置和运行应用程序的环境。本文不涉及工具安装或初始设置;请参阅 NXP 官方指南,获取适用于您环境的具体说明。 5. 编程   本章的关键在于首先理解示例代码的工作原理,然后对其进行修改以使其适用于 P3T1755。   5.1 检查基础示例代码的内容 本文提供了几个 I²C 示例程序。 这次,我们将使用示例程序“lpi2c_edma_b2b_polling_master”,该程序采用轮询作为主控端。我们将修改此示例程序,使其能够通过 I²C 接口读取安装在 FRDM-MCXA153 中的 P3T1755 温度传感器的温度数据。 默认情况下,P3T1755 连接到 I3C 模块 I3C0,但我们将修改程序以切换到 LPI2C 模块,并创建一个使用 LPI2C 读取 P3T1755 温度的程序。 在 FRDM-MCXA153 中,P3T1755 和 LPI2C 之间没有连接中断线,因此必须使用 LPI2C 作为轮询主控端。此外,MCX A153 和 P3T1755 之间的连接线没有上拉电阻,因此必须添加一个上拉电阻。 在这个例子中,LPI2C 实例在一个电路板上作为主设备,在另一个电路板上作为从设备。主设备向从设备发送数据,并从从设备接收数据。本示例验证从从设备接收到的数据是否正确。 沟通流程的总体概要如下: 主控单元发送信号开始通信(启动条件)。 主控端发送从控端地址。 从设备向主设备发送信号(确认),表明它已准备好进行通信。 执行数据通信(根据要发送的数据重复执行) 主控单元发出信号结束通信(停止条件)。 进一步分析发现,控制方式有两种:写控制,用于向从设备写入信息;读控制,用于从从设备读取信息。首先执行写控制,然后执行读控制来读取温度数据。 这是使用轮询方式控制主设备的基本步骤。无论从设备是微控制器的 I²C 模块还是温度传感器等传感器 IC,步骤都相同。 [写入控制] 控制写入操作的步骤如下。所使用的函数及其说明列于下方。 ① 发送起始条件 + 从机地址 + 写位: LPI2C_MasterStart:スタート信号とスレーブアドレスを送信。 此功能启动新的主模式传输。 ② 发送目标设备的注册地址和数据: LPI2C_MasterSend:I²Cバスにデータを送信。 该函数会等待缓冲区中的数据发送完毕。 ③ 发送停止条件: LPI2C_MasterStop:I²Cバスにストップ信号を送信。 此函数会等待直到收到停止信号,然后交易才会结束。 等它完成。 [读取控件] 读取控制的步骤如下。所使用的函数及其说明也列于此处。 ① 发送起始条件 + 从机地址 + 写位: LPI2C_MasterStart:スタート信号とスレーブアドレスを送信。 此功能启动新的主模式传输。 ② 发送目标设备的注册地址: LPI2C_MasterRepeatedStart:LPI2C_MasterStart を再度実行する。 该函数通常发送一个寄存器地址。 ③ 发送起始条件 + 从机地址 + 读取位: LPI2C_MasterReceive:I²Cバスからデータを受信。 该函数会等待缓冲区中的数据传输完毕。 ④ 从目标设备接收数据: LPI2C_MasterSend:I²Cバスにデータを送信。 该函数会等待缓冲区中的数据发送完毕。 ⑤ 发送停止条件: LPI2C_MasterStop:I²Cバスにストップ信号を送信。 该函数会一直等待,直到收到停止信号并完成交易。 示例程序“lpi2c_edma_b2b_polling_master”的流程图包含在最后一章末尾的补充说明中,请参考该说明。 此外,虽然MCX A153 API 参考文档中提供了所用函数的解释,但我们已将本示例中使用的函数的解释提取到最后一章末尾的补充说明中。请同时参考该补充说明。 5.2 引脚配置 默认情况下,P3T1755 连接到 I3C 模块的 I3C0 引脚,因此您需要将其更改为 LPI2C 引脚。要更改引脚连接,您可以使用配置工具中的便捷引脚配置器功能。引脚配置器允许您通过图形用户界面 (GUI) 更改引脚分配,甚至可以自动为您生成 C 语言代码。具体操作将在实践练习章节中详细说明。 5.3 程序代码的更改 基本通信流程与示例相同,但从机地址、寄存器地址和数据长度已更改为与 P3T1755 匹配。此外,接收到的 16 位值被转换为温度值。 首先,将从地址更改为 P3T1755 的 0x48U。 示例程序处理 33 字节的数据,但 P3T1755 使用 16 位温度数据,因此我们将数据长度更改为 16 位。 我们定义一个常量来存储从 P3T1755 读取的 16 位温度数据。在这里,我们称之为“温度”。 寄存器地址由 deviceAddress 定义,其值为 0x01U,但在 P3T1755 的情况下,其值为 0x00U。 要传输的数据点数由 txCount 定义,在示例程序中为 0xFFU,但由于从 P3T1755 读取的温度数据为 2 字节(16 位),因此我们将其减少到 0x01U。 在示例程序中,主设备发送数据,从设备发送相同的数据,然后对发送的数据和接收的数据进行比较,但这个过程是不必要的。 相反,需要将从 P3T1755 接收到的数据处理成温度数据。从 P3T1755 接收到的数据为 2 字节(16 位)。接收缓冲区定义为 g_master_rxBuff[1] 和 g_master_rxBuff[0],每个缓冲区包含 1 个字节,因此 g_master_rxBuff[0] 用作高字节,g_master_rxBuff[1] 用作低字节,它们组合成 16 位。组合后的结果存储在 temp 中。 组合温度数据的每一位对应 0.0625°C,因此乘以 0.0625 即可得到温度值。幸运的是,乘以 0.0625 可以通过右移 4 位轻松计算,无需使用浮点运算。计算结果输入到“温度”字段中。 最后,使用 printf 显示主机名。     6. 实践训练   本章重点介绍必要的硬件准备工作以及需要修改 P3T1755 代码的地方,而不是详细介绍工具安装或屏幕操作。   6.1 实践培训内容 此方法使用 LPI2C 读取安装在 FRDM-MCXA153 上的 P3T1755 温度传感器。由于 P3T1755 初始连接到 I3C0,因此需要进行引脚配置才能将其连接到 LPI2C。此外,还必须在 I3C 信号线上添加一个上拉电阻。 该软件基于 LPI2C SDK 示例,对 P3T1755 的从机地址、寄存器地址、数据长度和温度数据的计算过程进行了修改。 6.2 实践培训程序(概述) 将 4.7kΩ 上拉电阻连接到评估板的 SDA 和 SCL 引脚。 在 MCUXpresso 环境下准备一个 LPI2C 示例项目。省略具体的安装和导入步骤。 将引脚设置更改为 P3T1755 所连接的 LPI2C 引脚。 将按照第 6.7 节所示进行以下代码更改。 运行程序并验证是否输出温度值。   6.3 在评估板上添加上拉电阻 P3T1755 的 I²C 总线上有两个结功率放大器 (J20, J21)。将 4.7kΩ 电阻连接到 J20 和 J21,并将 SDA 和 SCL 上拉。 重要的! 内置上拉电阻可能无法提供稳定的通信,具体取决于电路板。为确保通信可靠,请使用外部上拉电阻。 6.4 编码更改 现在我们将把编程章节中解释的概念编写成一个实际的 .c 文件。 现在我们将把“5.3 程序代码的变更”中描述的变更应用到代码中。 (1)将从地址更改为 P3T1755 的 0x48U。 [変更前]#define LPI2C_MASTER_SLAVE_ADDR_7BIT 0x7EU [変更後]#define LPI2C_MASTER_SLAVE_ADDR_7BIT 0x48U (2)将数据长度改为 16 位。 [変更前]#define LPI2C_DATA_LENGTH 33U [変更後]#define LPI2C_DATA_LENGTH 2U (3)定义一个常量“温度”来存储从 P3T1755 读取的 16 位温度数据。 [追加]uint16_t temperature; (4)将寄存器地址 deviceAddress 更改为 0x00U。 [変更前]uint8_t deviceAddress = 0x01U; [変更後]uint8_t deviceAddress = 0x00U; (5)将要传输的数据量 txCount 更改为 0x01U。 [変更前]size_t txCount = 0xFFU; [変更後]size_t txCount = 0x01U; (6)接收数据数量的调整 [変更前]reVal = LPI2C_MasterReceive(EXAMPLE_I2C_MASTER, g_master_rxBuff, LPI2C_DATA_LENGTH - 1); [変更後]reVal = LPI2C_MasterReceive(EXAMPLE_I2C_MASTER, g_master_rxBuff, LPI2C_DATA_LENGTH); (7)删除比较发送数据和接收数据的部分。 [削除] /* Transfer completed. Check the data.*/以下のコード (8)从 P3T1755 接收的数据被合并成温度数据。g_master_rxBuff[0] 的高字节和 g_master_rxBuff[1] 的低字节被合并成一个 16 位数组,合并后的结果存储在 temp 中。 [追加] temp = (((uint16_t) g_master_rxBuff[0] << 8U) | (uint16_t) g_master_rxBuff[1]) >> 4U; (9)将温度值向右移动 4 位,并将其放入温度变量中。 [追加]temperature = temp >> 4; (10)使用 printf 显示温度。 [追加] PRINTF("Temperature=%d", temperature); PRINTF("Celsius"); (11)最后,我们将添加一个无限循环。 [追加]while (1) {} 下面列出了目前为止所做的更改的完整代码,供您参考。   [全部代码] /* * Copyright 2017 NXP * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ /* Standard C Included Files */ #include #include #include "board.h" #include "fsl_debug_console.h" #include "fsl_lpi2c.h" #include "app.h" /******************************************************************************* * Definitions ******************************************************************************/ #define EXAMPLE_I2C_MASTER ((LPI2C_Type *)EXAMPLE_I2C_MASTER_BASE) #define LPI2C_MASTER_SLAVE_ADDR_7BIT 0x48U #define LPI2C_BAUDRATE 100000U #define LPI2C_DATA_LENGTH 2U /******************************************************************************* * Prototypes ******************************************************************************/ /******************************************************************************* * Variables ******************************************************************************/ uint8_t g_master_txBuff[LPI2C_DATA_LENGTH]; uint8_t g_master_rxBuff[LPI2C_DATA_LENGTH]; uint16_t temp; /* 追加 */ uint16_t temperature; /* 追加 */ /******************************************************************************* * Code ******************************************************************************/ /*! * @brief Main function */ int main(void) { lpi2c_master_config_t masterConfig; status_t reVal = kStatus_Fail; uint8_t deviceAddress = 0x00U; size_t txCount = 0x01U; BOARD_InitHardware(); /* Set up i2c master to send data to slave*/ /* First data in txBuff is data length of the transmiting data. */ g_master_txBuff[0] = LPI2C_DATA_LENGTH - 1U; for (uint32_t i = 1U; i < LPI2C_DATA_LENGTH; i++) { g_master_txBuff[i] = i - 1; } for (uint32_t i = 0U; i < LPI2C_DATA_LENGTH - 1U; i++) { if (i % 8 == 0) { } } /* * masterConfig.debugEnable = false; * masterConfig.ignoreAck = false; * masterConfig.pinConfig = kLPI2C_2PinOpenDrain; * masterConfig.baudRate_Hz = 100000U; * masterConfig.busIdleTimeout_ns = 0; * masterConfig.pinLowTimeout_ns = 0; * masterConfig.sdaGlitchFilterWidth_ns = 0; * masterConfig.sclGlitchFilterWidth_ns = 0; */ LPI2C_MasterGetDefaultConfig(&masterConfig); /* Change the default baudrate configuration */ masterConfig.baudRate_Hz = LPI2C_BAUDRATE; /* Initialize the LPI2C master peripheral */ LPI2C_MasterInit(EXAMPLE_I2C_MASTER, &masterConfig, LPI2C_MASTER_CLOCK_FREQUENCY); /* Send master start bit &Slave Address + Write Bit */ if (kStatus_Success == LPI2C_MasterStart(EXAMPLE_I2C_MASTER, LPI2C_MASTER_SLAVE_ADDR_7BIT, kLPI2C_Write)) { LPI2C_MasterGetFifoCounts(EXAMPLE_I2C_MASTER, NULL, &txCount); while (txCount) { LPI2C_MasterGetFifoCounts(EXAMPLE_I2C_MASTER, NULL, &txCount); } if (LPI2C_MasterGetStatusFlags(EXAMPLE_I2C_MASTER) & kLPI2C_MasterNackDetectFlag) { return kStatus_LPI2C_Nak; } reVal = LPI2C_MasterSend(EXAMPLE_I2C_MASTER, &deviceAddress, 1); if (reVal != kStatus_Success) { if (reVal == kStatus_LPI2C_Nak) { LPI2C_MasterStop(EXAMPLE_I2C_MASTER); } return -1; } reVal = LPI2C_MasterSend(EXAMPLE_I2C_MASTER, g_master_txBuff, LPI2C_DATA_LENGTH); if (reVal != kStatus_Success) { if (reVal == kStatus_LPI2C_Nak) { LPI2C_MasterStop(EXAMPLE_I2C_MASTER); } return -1; } reVal = LPI2C_MasterStop(EXAMPLE_I2C_MASTER); if (reVal != kStatus_Success) { return -1; } } for (uint32_t i = 0U; i < WAIT_TIME; i++) { __NOP(); } if (kStatus_Success == LPI2C_MasterStart(EXAMPLE_I2C_MASTER, LPI2C_MASTER_SLAVE_ADDR_7BIT, kLPI2C_Write)) { /* Check master tx FIFO empty or not */ LPI2C_MasterGetFifoCounts(EXAMPLE_I2C_MASTER, NULL, &txCount); while (txCount) { LPI2C_MasterGetFifoCounts(EXAMPLE_I2C_MASTER, NULL, &txCount); } /* Check communicate with slave successful or not */ if (LPI2C_MasterGetStatusFlags(EXAMPLE_I2C_MASTER) & kLPI2C_MasterNackDetectFlag) { return kStatus_LPI2C_Nak; } reVal = LPI2C_MasterSend(EXAMPLE_I2C_MASTER, &deviceAddress, 1); if (reVal != kStatus_Success) { if (reVal == kStatus_LPI2C_Nak) { LPI2C_MasterStop(EXAMPLE_I2C_MASTER); } return -1; } reVal = LPI2C_MasterRepeatedStart(EXAMPLE_I2C_MASTER, LPI2C_MASTER_SLAVE_ADDR_7BIT, kLPI2C_Read); if (reVal != kStatus_Success) { return -1; } reVal = LPI2C_MasterReceive(EXAMPLE_I2C_MASTER, g_master_rxBuff, LPI2C_DATA_LENGTH); if (reVal != kStatus_Success) { if (reVal == kStatus_LPI2C_Nak) { LPI2C_MasterStop(EXAMPLE_I2C_MASTER); } return -1; } reVal = LPI2C_MasterStop(EXAMPLE_I2C_MASTER); if (reVal != kStatus_Success) { return -1; } } for (uint32_t i = 0U; i < LPI2C_DATA_LENGTH; i++) { if (i % 8 == 0) { } } temp = (((uint16_t) g_master_rxBuff[0] << 8U) | (uint16_t) g_master_rxBuff[1]) >> 4U; temperature = temp >> 4; PRINTF("Temperature=%d", temperature); PRINTF("Celsius"); while (1) { } }   6.5 使用引脚配置器更改引脚设置   我们将把目前连接到 P3T1755 的I3C端口重新连接到LPI2C 端口。这是通过MCUXpresso 配置工具中的引脚配置器工具完成的,而不是修改程序代码。 首先,我们将禁用引脚33和34的默认设置,即LPI2C0_SDA和LPI2C0_SCL 。在“引脚”选项卡中,向下滚动以显示引脚33和34。然后,向右滚动以显示LPI2C列。单击LPI2C列中显示的引脚33和34对应的LPI2C0_SDA和LPI2C0_SCL ,即可禁用引脚33和34 。 接下来,在“引脚”选项卡中,将引脚54分配给LPI2C0_SDA 。选中引脚54的复选框将显示分配给该引脚的所有功能。从列表中选择LPI2C0:SDA 。 “引脚”选项卡中的引脚54将变为绿色。单击“完成”以完成分配。 同样,在“引脚”选项卡中,将引脚55分配给LPI2C0_SCL 。选中引脚55的复选框,然后选择LPI2C0:SCL 。“引脚”选项卡中的引脚55将变为绿色。单击“完成”以完成分配。 接下来,我们将配置引脚54和55的功能。要配置这些功能,请使用底部的“布线详情… ”选项。 在“路由详细信息”中,将引脚54 ( LPI2C0_SDA ) 和55 ( LPI2C0_SCL ) 的上拉选择 (Pull Select)设置为Pullup ,并将上拉使能 (Pull Enable)设置为Enabled 。如果将标签设置为I2C_SDA和I2C_SCL ,则需要在 board/pin_mux.h 文件中进行相应设置。它给它增加了一个定义。 引脚配置现已完成。 要反映代码中目前所做的更改,请单击“更新代码”按钮。 6.6 构建与调试、测试功能 代码修改完成后,进行编译。 将鼠标悬停在“项目”上时,会出现一个构建按钮。点击该按钮即可构建项目。 如果看到“构建成功完成”的消息,那就没问题了。 在构建按钮旁边,有一个调试按钮。点击此按钮将进入调试模式。 进入调试模式后,程序会在断点处停止,因此请点击屏幕顶部的“ |▶ ”图标。程序随后会继续运行。 温度将显示在 Tera Term 屏幕上。 总结 本文介绍了I²C通信的基本原理以及MCX A153中安装的LPI2C模块的主要功能。文章还以FRDM-MCXA153中安装的P3T1755温度传感器为例,演示了如何添加上拉电阻、使用引脚配置器配置引脚以及修改LPI2C SDK示例代码。在I²C通信中,根据连接设备的规格配置从机地址、寄存器地址和数据长度至关重要。本文中的信息可用于与各种I²C设备(例如传感器和EEPROM)进行通信。 =========================​ 我们目前无法 回复 此帖子“ 评论”部分留下的评论。 对于由此造成的不便,我们深表歉意,但 在进行咨询时, 请 参考“ NXP 技术问题 - 如何联系我们 ( 日语博客 ) ” 。 (如果您已经是 恩智浦的 分销商或 与 恩智浦 有合作关系 ,您可以直接咨询您的代表。 ) 本文重点介绍恩智浦半导体 (NXP) 微控制器 MCX A153 中包含的 LPI2C(低功耗集成电路间)控制器。在回顾 I²C 的基础知识之后,我们将解释 I²C 和 LPI2C 之间的区别,然后了解 MCX A153 上 LPI2C 的规格和用途。 (阅读时间:30分钟) MCUXpresso IDE MCUXpresso SDK MCX 日本博客
View full article
[FRDM-MCXA153] LPI2C Beginner's Guide (Japanese Blog) Introduction This article is aimed at beginners in microcontrollers and explains the peripheral functions and usage of the NXP MCX A153 microcontroller. You will learn the basic concepts and implementation methods by actually modifying the SDK sample programs provided by NXP. table of contents   1. Common Usage Examples in Applications (I²C Edition) 1.1 Main Uses 1.2 Usage example 2. Fundamentals of I²C 2.1 What is I²C in the first place? 2.2 Microcontroller I²C Module 3. Main functions and block diagram of the MCX A153 I²C module (LPI2C) 3.1 Overview 3.2 Block Diagram 3.3 Functions 4. Equipment and Development Tools Used 4.1 Evaluation Board (FRDM-MCXA153) 4.2 Development Tools (MCUXpresso for VS Code and IDE) 5. Programming 5.1 Check the contents of the base sample code 5.2 Pin Configuration 5.3 Changes in the program code 6. Practical Training 6.1 Practical Training Content 6.2 Practical Exercise Procedure 6.3 Add pull-up resistors to the evaluation board 6.4 Coding the changes 6.5 Change the pin settings using the PIN configurator 6.6 Build & Debug, Test Functionality   1. Common Usage Examples in Applications (I²C Edition)   Key points of this chapter: We will examine the situations in which I²C is used.   1.1 Main Uses I²C is a communication method that reads and writes data by specifying the register address within a device. Because it uses fewer signal lines, it is suitable for controlling multiple ICs on a single circuit board. However, it is susceptible to wiring capacitance and noise, so it is generally used for short-distance communication. Connection of various sensors such as temperature, acceleration, and magnetic sensors. Digital potentiometer IO Expander EEPROM RTC Input/output expansion for display devices (LCD, LED, etc.) Microcontroller-to-microcontroller communication (included in the sample program on the FRDM-MCXA153 evaluation board) 1.2 Usage example Actual applications include computer motherboards, embedded systems, and mobile phones.   2. Fundamentals of I²C   Key points of this chapter: We will clarify the basic I²C terminology, including SDA, SCL, address, ACK/NACK, and pull-up resistor.   2.1 What is I²C in the first place? I²C is a serial bus communication standard developed by Philips Semiconductors (now NXP Semiconductors). It is now widely used as a representative method for connecting sensors and peripheral ICs on circuit boards. I²C is a synchronous serial communication method that sends data synchronized with a clock. The data line is called SDA, and the clock line is called SCL. Communication is performed by timing SDA to SCL. Each slave has a unique address, and the master communicates by specifying that address. When the address is sent at the start of communication, the target slave returns an ACK (acknowledgment). If an ACK cannot be received, no ACK is returned, which is called a NACK (non-acknowledgment). Communication is performed using a protocol consisting of start condition, address, R/W bits, ACK/NACK, and stop condition. Addresses can be in 7-bit mode or 10-bit mode. I²C is an open-drain protocol. Pull-up resistors keep SDA and SCL normally high, and each device pulls them low when needed. Therefore, pull-up resistors are required on communication lines. A microcontroller is typically used as the master. There are two ways to determine communication completion: using interrupts from the slaves, and a polling method where the master repeatedly checks a completion flag. When using interrupts, each slave must have an interrupt output and the master must have an interrupt input. Using interrupts results in faster response times, but the hardware becomes more resource-intensive. For more detailed information about I²C, please refer to the following article. Overview of the I²C Bus (Japanese Blog) This time, we will use a polling method to match the wiring conditions of the evaluation board. Typical transfer speeds are 100kbps in standard mode and 400kbps in fast mode. The MCX A153 also supports Fast Mode Plus, allowing for communication at a maximum speed of 1Mbps. The procedure for sending data from the master to the slave is as follows: Master initiated communication. The master specifies the slave address. Sending data from master to slave The master terminated the communication. Conversely, the procedure for a master receiving data from a slave is as follows: Master initiated communication. The master specifies the slave address. The master receives data from the slave. The master terminated the communication.   2.2 Microcontroller I²C Module The diagram below shows a block diagram of an I²C module typically found in microcontrollers. The number of components is not that large. The main components are the Command/TX FIFO for the transmit buffer, the RXFIFO for the receive buffer, configuration registers, and the control circuit that controls communication. Furthermore, most microcontrollers nowadays have a built-in noise filter. 3. Main functions and block diagram of the MCX A153 I²C module (LPI2C)   Key points of this chapter: We will examine the differences between general I²C and the LPI2C module of the MCX A153.   3.1 Overview Up to this point, we have explained the basics of general I²C, but in this chapter we will explain the LPI2C I²C module of the MCX A153. LPI2C is far more functional than the basic I²C mentioned above. LPI2C supports efficient interfacing to the I²C bus as both a master (controller) and a slave (target). The main features are listed below. Supports logic for Standard, High Speed, High Speed+, HS Mode (Target Only), and Ultra High Speed operating modes. CPU overhead is minimized by DMA offloading access to the FIFO. LPI2C also complies with the System Management Bus (SMBus) specification version 3. *Note 1 The MCX A153 reference manual uses the terms "master and controller" and "slave and target" interchangeably. While "controller" and "target" are now recommended, we will use "master and slave" consistently in this document. 3.2 Block Diagram The MCX A153's LPI2C module has a master section in the upper half and a slave section in the lower half. The SDA and SCL modules are also divided into master and slave versions, with the slave versions having an "S" appended to them, hence SDAS and SCLS. Communication can also be started using the external HREQ terminal or the internal Trigger signal. 3.3 Functions The functions of LPI2C are as follows: Standard, High Speed, High Speed+, Ultra High Speed Mode Multi-controller (including synchronization and arbitration) Clock stretching Arbitration (when a system has multiple controllers) 7-bit addressing, 10-bit addressing Software reset, start byte, device ID (software support is also required). Command and transmit FIFO (4 words, 8-bit transmit data + 3-bit command) Received FIFO (4 words, 8-bit received data) Host request input for controlling the start time of I²C bus transfer Interrupt generation upon data match and rejection of unwanted data based on received data matching. Flags and optional interrupt signals for repeat start conditions, stop conditions, loss of arbitration, unexpected NACK, and command word errors. configurable bus idle timeout and pin stack low timeout. Independent I²C target registers 7-bit or 10-bit addressing Send/receive data registers that support interrupts or DMA requests ACK or NACK can be controlled by software. Clock stretching can be configured to avoid transmit FIFO underrun and receive FIFO overrun errors. Packet termination flags and optional interrupt, stop condition, or bit error detection. 4. Equipment and Development Tools Used   4.1 Evaluation Board (FRDM-MCXA153) The equipment used for this practical exercise will be a Windows PC and the FRDM-MCXA153 evaluation kit for the MCX A153 (FRDM-MCXA153 Development Board using MCUXpresso | NXP Semiconductors). A USB Type-C cable is included with the FRDM-MCXA153. Board information and circuit diagrams for the FRDM-MCXA153 can be obtained by clicking "Design Files" on the website. (Account registration required) The FRDM-MCXA153 is equipped with a P3T1755 temperature sensor. In its initial state, the P3T1755 is connected to I3C0, so this time we will change the pin settings to connect it to LPI2C and read the temperature using LPI2C. Since there is no interrupt line wired from the P3T1755 to the LPI2C, the LPI2C will be used as a polling master. Also, since there are no pull-up resistors on the signal lines of the MCX A153 and P3T1755, external resistors will be added. 4.2 Development Tools (MCUXpresso for VS Code and IDE) This article will guide you through editing and running SDK samples using MCUXpresso for VS Code or the MCUXpresso IDE. Development tools are the environment for creating projects, editing code, configuring settings, and running applications. This article does not cover tool installation or initial setup; please refer to NXP's official guides for instructions specific to your environment. 5. Programming   The key point of this chapter is to first understand how the sample code works, and then modify it for the P3T1755.   5.1 Check the contents of the base sample code Several sample programs for I²C are provided. This time, we will use the sample program "lpi2c_edma_b2b_polling_master" which uses polling as the master. We will modify this sample program to create a program that reads temperature data from the P3T1755 temperature sensor installed in the FRDM-MCXA153 using I²C. By default, the P3T1755 is connected to the I3C module I3C0, but we will modify the program to switch to the LPI2C module and create a program that uses the LPI2C to read the temperature of the P3T1755. In the FRDM-MCXA153, there is no interrupt line wired from the P3T1755 to the LPI2C, so the LPI2C must be used as the polling master. Also, the wiring connecting the MCX A153 and the P3T1755 does not have a pull-up resistor, so a pull-up resistor must be added. In this example, an LPI2C instance is implemented as a master on one board and as a slave on the other board. The master sends data to the slave and receives data from the slave. This example verifies whether the data received from the slave is correct. The general outline of the communication procedure is as follows: The master unit sends a signal to begin communication (start condition). The master sends the slave address. The slave sends a signal (acknowledgment) to the master indicating that it is ready to communicate. Perform data communication (repeated depending on the data to be sent) The master unit issues a signal to end communication (stop condition). Further breakdown reveals two types of control: Write control, which writes information to the slave, and Read control, which reads information from the slave. First, Write control is performed, followed by Read control to read the temperature data. This is the basic procedure for controlling the master side using polling. It's the same whether the slave is a microcontroller's I²C module or a sensor IC such as a temperature sensor. [Write control] The procedure for controlling the write operation is as follows. The functions used and their explanations are listed below. ① Send Start condition + slave address + write bit: LPI2C_MasterStart:スタート信号とスレーブアドレスを送信。 This function initiates a new master mode transfer. ② Send the register address and data of the target device: LPI2C_MasterSend:I²Cバスにデータを送信。 This function waits until the data in the buffer is sent. ③ Send Stop condition: LPI2C_MasterStop:I²Cバスにストップ信号を送信。 This function waits until a stop signal is sent, and the transaction Wait until it finishes. [Read control] The procedure for Read control is as follows. The functions used and their explanations are also listed here. ① Send Start condition + slave address + write bit: LPI2C_MasterStart:スタート信号とスレーブアドレスを送信。 This function initiates a new master mode transfer. ② Send the register address of the target device: LPI2C_MasterRepeatedStart:LPI2C_MasterStart を再度実行する。 This function typically sends a register address. ③ Send Start condition + slave address + read bit: LPI2C_MasterReceive:I²Cバスからデータを受信。 This function waits until the data in the buffer has been transferred. ④ Receive data from the target device: LPI2C_MasterSend:I²Cバスにデータを送信。 This function waits until the data in the buffer is sent. ⑤ Send Stop condition: LPI2C_MasterStop:I²Cバスにストップ信号を送信。 This function waits until a stop signal is sent and until the transaction is completed. A flowchart for the sample program "lpi2c_edma_b2b_polling_master" is included in the supplementary explanation at the end of the last chapter. Please refer to it. Furthermore, while explanations of the functions used can be found in the MCX A153 API Reference , we have extracted the explanations of the functions used in this example into the supplementary explanations at the end of the last chapter. Please refer to this as well. 5.2 Pin Configuration By default, the P3T1755 is connected to the I3C0 pin of the I3C module, so you need to change this to the LPI2C pin. To change the pin connections, you can use the convenient Pin Configurator function within the Config Tools tool. The Pin Configurator allows you to change pin assignments via a GUI and even automatically generates C language code for you. The specific operation will be explained in detail in the practical exercises chapter. 5.3 Changes in the program code The basic communication flow is the same as the sample, but the slave address, register address, and data length are changed to match the P3T1755. Furthermore, the received 16-bit value is converted to temperature. First, change the slave address to 0x48U of P3T1755. The sample program handles 33 bytes of data, but the P3T1755 uses 16-bit temperature data, so we will change the data length to 16 bits. We define a constant to store the 16-bit temperature data read from the P3T1755. Here, we'll call it "temperature". The register address is defined by deviceAddress, which is 0x01U, but in the case of P3T1755 it is 0x00U. The number of data points to transfer is defined by txCount, which is 0xFFU in the sample program, but since the temperature data read from the P3T1755 is 2 bytes (16 bits), we reduce it to 0x01U. In the sample program, the master sends data and the slave sends the same data back, and then a comparison of the transmitted and received data is performed, but this process is unnecessary. Instead, it is necessary to process the data received from the P3T1755 into temperature data. The data received from the P3T1755 is 2 bytes (16 bits). The receive buffer is defined as g_master_rxBuff[1] and g_master_rxBuff[0], each containing 1 byte, so g_master_rxBuff[0] is used as the upper byte and g_master_rxBuff[1] as the lower byte, and they are combined into 16 bits. The combined result is stored in temp. Each bit of the combined temperature data corresponds to 0.0625°C, so multiplying by 0.0625 gives the temperature. Fortunately, multiplying by 0.0625 can be easily calculated by shifting 4 bits to the right, without using floating-point arithmetic. The calculation result is entered into the 'temperature' field. Finally, display the host using printf.     6. Practical Training   This chapter focuses on the necessary hardware preparations and the points where you need to modify the code for the P3T1755, rather than detailing tool installation or screen operations.   6.1 Practical Training Content This method reads the P3T1755 temperature sensor mounted on the FRDM-MCXA153 using LPI2C. Since the P3T1755 is initially connected to I3C0, pin configuration is required to connect it to LPI2C. Additionally, a pull-up resistor must be added to the I3C signal line. The software is based on the LPI2C SDK sample, with modifications to the calculation process for the P3T1755's slave address, register address, data length, and temperature data. 6.2 Practical Training Procedure (Overview) Connect 4.7kΩ pull-up resistors to the SDA and SCL pins of the evaluation board. Prepare a sample LPI2C project in the MCUXpresso environment. Specific installation and import procedures are omitted. Change the pin settings to the LPI2C pins to which the P3T1755 is connected. The following code changes will be made as shown in Section 6.7. Run the program and verify that a temperature value is output.   6.3 Add pull-up resistors to the evaluation board The P3T1755 has Junction PAs (J20, J21) on its I²C line. Connect 4.7kΩ resistors to J20 and J21, and pull up SDA and SCL. important! The built-in pull-up resistor may not provide stable communication depending on the board. To ensure reliable communication, please use an external pull-up resistor. 6.4 Coding the changes We will now code the concepts explained in the programming chapter into an actual .c file. We will now implement the changes described in "5.3 Changes to the Program Code" into the code. (1) Change the slave address to 0x48U of P3T1755. [変更前]#define LPI2C_MASTER_SLAVE_ADDR_7BIT 0x7EU [変更後]#define LPI2C_MASTER_SLAVE_ADDR_7BIT 0x48U (2) Change the data length to 16 bits. [変更前]#define LPI2C_DATA_LENGTH 33U [変更後]#define LPI2C_DATA_LENGTH 2U (3) Define a constant `temperature` to store the 16 bits of temperature data read from the P3T1755. [追加]uint16_t temperature; (4) Change the register address deviceAddress to 0x00U. [変更前]uint8_t deviceAddress = 0x01U; [変更後]uint8_t deviceAddress = 0x00U; (5) Change the number of data to be transferred, txCount, to 0x01U. [変更前]size_t txCount = 0xFFU; [変更後]size_t txCount = 0x01U; (6) Adjustment of the number of received data [変更前]reVal = LPI2C_MasterReceive(EXAMPLE_I2C_MASTER, g_master_rxBuff, LPI2C_DATA_LENGTH - 1); [変更後]reVal = LPI2C_MasterReceive(EXAMPLE_I2C_MASTER, g_master_rxBuff, LPI2C_DATA_LENGTH); (7) Remove the section comparing the transmitted data and the received data. [削除] /* Transfer completed. Check the data.*/以下のコード (8) The data received from P3T1755 is combined into temperature data. The upper byte of g_master_rxBuff[0] and the lower byte of g_master_rxBuff[1] are combined into a 16-bit array, and the combined result is stored in temp. [追加] temp = (((uint16_t) g_master_rxBuff[0] << 8U) | (uint16_t) g_master_rxBuff[1]) >> 4U; (9) Shift temp to the right by 4 bits and put it into temperature. [追加]temperature = temp >> 4; (10) Display the temperature using printf. [追加] PRINTF("Temperature=%d", temperature); PRINTF("Celsius"); (11) Finally, we'll add an infinite loop. [追加]while (1) {} The complete code reflecting the changes made so far is shown below for reference.   [All Code] /* * Copyright 2017 NXP * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ /* Standard C Included Files */ #include #include #include "board.h" #include "fsl_debug_console.h" #include "fsl_lpi2c.h" #include "app.h" /******************************************************************************* * Definitions ******************************************************************************/ #define EXAMPLE_I2C_MASTER ((LPI2C_Type *)EXAMPLE_I2C_MASTER_BASE) #define LPI2C_MASTER_SLAVE_ADDR_7BIT 0x48U #define LPI2C_BAUDRATE 100000U #define LPI2C_DATA_LENGTH 2U /******************************************************************************* * Prototypes ******************************************************************************/ /******************************************************************************* * Variables ******************************************************************************/ uint8_t g_master_txBuff[LPI2C_DATA_LENGTH]; uint8_t g_master_rxBuff[LPI2C_DATA_LENGTH]; uint16_t temp; /* 追加 */ uint16_t temperature; /* 追加 */ /******************************************************************************* * Code ******************************************************************************/ /*! * @brief Main function */ int main(void) { lpi2c_master_config_t masterConfig; status_t reVal = kStatus_Fail; uint8_t deviceAddress = 0x00U; size_t txCount = 0x01U; BOARD_InitHardware(); /* Set up i2c master to send data to slave*/ /* First data in txBuff is data length of the transmiting data. */ g_master_txBuff[0] = LPI2C_DATA_LENGTH - 1U; for (uint32_t i = 1U; i < LPI2C_DATA_LENGTH; i++) { g_master_txBuff[i] = i - 1; } for (uint32_t i = 0U; i < LPI2C_DATA_LENGTH - 1U; i++) { if (i % 8 == 0) { } } /* * masterConfig.debugEnable = false; * masterConfig.ignoreAck = false; * masterConfig.pinConfig = kLPI2C_2PinOpenDrain; * masterConfig.baudRate_Hz = 100000U; * masterConfig.busIdleTimeout_ns = 0; * masterConfig.pinLowTimeout_ns = 0; * masterConfig.sdaGlitchFilterWidth_ns = 0; * masterConfig.sclGlitchFilterWidth_ns = 0; */ LPI2C_MasterGetDefaultConfig(&masterConfig); /* Change the default baudrate configuration */ masterConfig.baudRate_Hz = LPI2C_BAUDRATE; /* Initialize the LPI2C master peripheral */ LPI2C_MasterInit(EXAMPLE_I2C_MASTER, &masterConfig, LPI2C_MASTER_CLOCK_FREQUENCY); /* Send master start bit &Slave Address + Write Bit */ if (kStatus_Success == LPI2C_MasterStart(EXAMPLE_I2C_MASTER, LPI2C_MASTER_SLAVE_ADDR_7BIT, kLPI2C_Write)) { LPI2C_MasterGetFifoCounts(EXAMPLE_I2C_MASTER, NULL, &txCount); while (txCount) { LPI2C_MasterGetFifoCounts(EXAMPLE_I2C_MASTER, NULL, &txCount); } if (LPI2C_MasterGetStatusFlags(EXAMPLE_I2C_MASTER) & kLPI2C_MasterNackDetectFlag) { return kStatus_LPI2C_Nak; } reVal = LPI2C_MasterSend(EXAMPLE_I2C_MASTER, &deviceAddress, 1); if (reVal != kStatus_Success) { if (reVal == kStatus_LPI2C_Nak) { LPI2C_MasterStop(EXAMPLE_I2C_MASTER); } return -1; } reVal = LPI2C_MasterSend(EXAMPLE_I2C_MASTER, g_master_txBuff, LPI2C_DATA_LENGTH); if (reVal != kStatus_Success) { if (reVal == kStatus_LPI2C_Nak) { LPI2C_MasterStop(EXAMPLE_I2C_MASTER); } return -1; } reVal = LPI2C_MasterStop(EXAMPLE_I2C_MASTER); if (reVal != kStatus_Success) { return -1; } } for (uint32_t i = 0U; i < WAIT_TIME; i++) { __NOP(); } if (kStatus_Success == LPI2C_MasterStart(EXAMPLE_I2C_MASTER, LPI2C_MASTER_SLAVE_ADDR_7BIT, kLPI2C_Write)) { /* Check master tx FIFO empty or not */ LPI2C_MasterGetFifoCounts(EXAMPLE_I2C_MASTER, NULL, &txCount); while (txCount) { LPI2C_MasterGetFifoCounts(EXAMPLE_I2C_MASTER, NULL, &txCount); } /* Check communicate with slave successful or not */ if (LPI2C_MasterGetStatusFlags(EXAMPLE_I2C_MASTER) & kLPI2C_MasterNackDetectFlag) { return kStatus_LPI2C_Nak; } reVal = LPI2C_MasterSend(EXAMPLE_I2C_MASTER, &deviceAddress, 1); if (reVal != kStatus_Success) { if (reVal == kStatus_LPI2C_Nak) { LPI2C_MasterStop(EXAMPLE_I2C_MASTER); } return -1; } reVal = LPI2C_MasterRepeatedStart(EXAMPLE_I2C_MASTER, LPI2C_MASTER_SLAVE_ADDR_7BIT, kLPI2C_Read); if (reVal != kStatus_Success) { return -1; } reVal = LPI2C_MasterReceive(EXAMPLE_I2C_MASTER, g_master_rxBuff, LPI2C_DATA_LENGTH); if (reVal != kStatus_Success) { if (reVal == kStatus_LPI2C_Nak) { LPI2C_MasterStop(EXAMPLE_I2C_MASTER); } return -1; } reVal = LPI2C_MasterStop(EXAMPLE_I2C_MASTER); if (reVal != kStatus_Success) { return -1; } } for (uint32_t i = 0U; i < LPI2C_DATA_LENGTH; i++) { if (i % 8 == 0) { } } temp = (((uint16_t) g_master_rxBuff[0] << 8U) | (uint16_t) g_master_rxBuff[1]) >> 4U; temperature = temp >> 4; PRINTF("Temperature=%d", temperature); PRINTF("Celsius"); while (1) { } }   6.5 Change the pin settings using the PIN Configurator   We will reconnect the I3C port currently connected to the P3T1755 to the LPI2C port . This is done using the Pin Configurator tool within MCUXpresso Config Tools , rather than modifying the program code. First, we will disable the default settings of pins 33 and 34 , which are LPI2C0_SDA and LPI2C0_SCL . In the Pins tab, scroll down to display pins 33 and 34. Then, scroll to the right to display the LPI2C column. Clicking on LPI2C0_SDA and LPI2C0_SCL , respectively, displayed in the LPI2C column for pins 33 and 34 will disable pins 33 and 34 . Next, in the Pins tab, assign pin 54 to LPI2C0_SDA . Clicking the checkbox for pin 54 will display all the functions assigned to that pin. Select LPI2C0:SDA from the list. Pin 54 in the Pins tab will then turn green. Click " Done " to complete the assignment. Similarly, in the Pins tab, assign pin 55 to LPI2C0_SCL . Click the checkbox for pin 55 and select LPI2C0:SCL . Pin 55 in the Pins tab will then turn green. Click " Done " to complete the assignment. Next, we will configure the functions of pins 54 and 55. To configure the functions, use " Routing Details for… " located at the bottom. In Routing Details for…, change the Pull Select for pins 54 ( LPI2C0_SDA ) and 55 ( LPI2C0_SCL ) to Pullup , and change Pull enable to Enabled . If you set the Label to I2C_SDA and I2C_SCL , then in board/pin_mux.hIt adds a definition to it. The pin configuration is now complete. To reflect the changes made so far in the code, click the Update Code button. 6.6 Build & Debug, Test Functionality Once you've finished changing the code, build it. When you hover your cursor over "Projects," a build button will appear. Clicking it will build the project. If you see the message " build finished successfully, " then it's OK . Next to the build button, there's a debug button. Clicking this will enter debug mode. When you enter debug mode, the program stops at the breakpoint, so click the " |▶ " icon at the top of the screen. The program will then run. The temperature will be displayed on the Tera Term screen. summary This article explained the basic I²C communication method and the main functions of the LPI2C module installed in the MCX A153. It also demonstrated how to add pull-up resistors, configure pins using the Pin Configurator, and modify the LPI2C SDK sample code, using the P3T1755 temperature sensor installed in the FRDM-MCXA153 as an example. In I²C communication, it is crucial to configure the slave address, register address, and data length according to the specifications of the connected device. Please use the information in this article to apply it to communication with various I²C devices such as sensors and EEPROMs. =========================​ We are currently unable to respond to comments left in the " Comment " section of this post . We apologize for the inconvenience, but please refer to " Technical Questions to NXP - How to Contact Us( Japanese Blog) " when making inquiries.(If you are already an NXP distributor or have a relationship with NXP, you may ask your representative directly.) This article focuses on the LPI2C (Low Power Inter-Integrated Circuit) controller included in the NXP microcontroller MCX A153. After reviewing the basics of I²C, we will explain the differences between I²C and LPI2C, and then learn about the specifications and usage of the LPI2C on the MCX A153. (Reading time: 30 minutes) MCUXpresso IDE MCUXpresso SDK MCX Japanese Blog
View full article
[FRDM-MCXA153] LPI2C入門ガイド (日本語ブログ) はじめに 本記事はマイコン初心者を対象に、NXPマイコン MCX A153の周辺機能と使い方を解説し、NXPが提供するSDKサンプルプログラムを実際に変更しながら、基本的な考え方と実装方法を学びます。 目次   1. アプリケーション上のよくある使い方の例(I²C編) 1.1 主な用途 1.2 使用例 2. I²Cの基礎 2.1 そもそもI²Cとは 2.2 マイコンのI²Cモジュール 3. MCX A153 I²Cモジュール(LPI2C)の主な機能とブロック図 3.1 概要 3.2 ブロック図 3.3 機能 4. 使用機材と開発ツール 4.1 評価ボード(FRDM-MCXA153) 4.2 開発ツール(MCUXpresso for VS CodeとIDE) 5. プログラミング 5.1 ベースとなるサンプルコードの内容を確認する 5.2 ピン設定 5.3 プログラムコードの変更点 6. 実習 6.1 実習内容 6.2 実習手順 6.3 評価ボードにプルアップ抵抗を付ける 6.4 変更点のコーディング 6.5 PIN configuratorを使ってピン設定を変更 6.6 ビルド&デバッグ、動作確認   1. アプリケーション上のよくある使い方の例(I²C編)   この章のポイント:I²Cがどのような場面で使われるかを確認します。   1.1 主な用途 I²Cは、デバイス内のレジスタアドレスを指定してデータを読み書きする通信方式です。信号線が少ないため、1枚の基板上で複数のICを制御する用途に向いています。一方、配線容量やノイズの影響を受けやすいため、一般には短距離の通信に使います。 温度・加速度・磁気センサーなどの各種センサー接続 デジタルポテンショメータ IOエキスパンダ EEPROM RTC 表示用デバイス(LCD、LEDなど)の入出力拡張 マイコン間通信(FRDM-MCXA153評価ボードのサンプルプログラムにあります) 1.2 使用例 実際の使用例は、パソコンのマザーボード、組み込みシステム、携帯電話などです。   2. I²Cの基礎   この章のポイント:SDA、SCL、アドレス、ACK/NACK、プルアップ抵抗というI²Cの基本用語を整理します。   2.1 そもそもI²Cとは I²Cは、Philips Semiconductors社(現在のNXP Semiconductors社)が開発したシリアルバス通信規格です。現在では、基板上のセンサーや周辺ICを接続する代表的な方式として広く使われています。 I²Cは、クロックに同期してデータを送る同期式シリアル通信です。データ線をSDA、クロック線をSCLと呼び、SDAをSCLのタイミングに合わせて通信します。 各スレーブは固有のアドレスを持ち、マスターはそのアドレスを指定して通信します。通信開始時にアドレスを送ると、対象のスレーブがACK(アクノリッジ)を返します。受信できない場合はACKを返さず、これをNACK(ナック)と呼びます。 スタートコンディション、アドレス、R/Wビット、ACK/NACK、ストップコンディションというプロトコルで通信します。 アドレスには7ビットモードと10ビットモードがあります。 I²Cはオープンドレイン方式です。プルアップ抵抗によってSDAとSCLを通常Highに保ち、各デバイスが必要なタイミングでLowに引き下げます。そのため、通信ラインにはプルアップ抵抗が必要です。 マスターには通常マイコンを使います。通信完了を知る方法には、スレーブからの割り込みを使う方法と、マスターが完了フラグを繰り返し確認するポーリング方式があります。割り込みを使う時には、各スレーブに割り込み出力、マスターに割り込み入力を設けなければなりません。割り込みを使う場合の方が、レスポンスが速いですが、ハードウェアが重くなります。 I²Cについて、より詳しく知りたい方は以下の記事をご参考ください。 I²Cバスの概要 (日本語ブログ) 今回は、評価ボードの配線条件に合わせてポーリング方式を使います。 代表的な転送速度は、標準モードが100kbps、ファストモードが400kbpsです。MCX A153はファストモードプラスにも対応し、最大1Mbpsで通信できます。 マスターからスレーブにデータを送信する場合の手順は次のようになります。 マスターが通信を開始 マスターがスレーブアドレスを指定 マスターからスレーブにデータを送信 マスターが通信を終了 逆に、マスターがスレーブからデータを受信する場合の手順は次のようになります。 マスターが通信を開始 マスターがスレーブアドレスを指定 マスターがスレーブからデータを受信する マスターが通信を終了   2.2 マイコンのI²Cモジュール 下図に一般的なマイコンに搭載されているI²Cモジュールのブロック図を示します。 構成ブロックはそんなに多くありません。送信バッファのCommand/TX FIFO、受信バッファのRXFIFO、設定用レジスタと、通信を制御する制御回路が主なブロックです。さらに、最近では、ほとんどのマイコンでノイズフィルタが内蔵されています。 3. MCX A153 I²Cモジュール(LPI2C)の主な機能とブロック図   この章のポイント:一般的なI²Cと、MCX A153のLPI2Cモジュールの違いを確認します。   3.1 概要 ここまで、一般的なI²Cの基礎知識を説明しましたが、この章では、MCX A153のI²CモジュールLPI2Cについて説明します。LPI2Cは前述した基本的なI²Cよりはるかに高機能です。LPI2Cは、マスター(コントローラ)およびスレーブ(ターゲット)としてI²Cバスへの効率的なインターフェースをサポートします。 以下に、主な特長を挙げます。 標準、高速、高速+、HSモード(ターゲットのみ)、超高速の各動作モードのロジックをサポート。 FIFOへのアクセスをDMAオフロードすることで、CPUオーバーヘッドを最小限に抑える。 LPI2Cは、システム管理バス(SMBus)仕様バージョン3にも準拠。 ※注1 MCX A153のリファレンスマニュアルの中では、「マスターとコントローラ」、「スレーブとターゲット」という言葉が混在して使われています。現在では「コントローラ」「ターゲット」が推奨されていますが、今回は、マスターとスレーブで統一します。 3.2 ブロック図 MCX A153のLPI2Cモジュールは、上半分がマスター、下半分がスレーブになっています。SDAとSCLもマスター用とスレーブ用に分かれており、スレーブ用には添え字にSが付いているので、SDASとSCLSになります。また、外部端子HREQや内部信号Triggerで通信をスタートすることができます。 3.3 機能 LPI2Cの機能は以下の通りです。 標準、高速、高速+、超高速モード マルチコントローラ(同期およびアービトレーションを含む) クロックストレッチング アービトレーション(システムに複数のコントローラが存在する場合) 7ビットアドレッシング、10ビットアドレッシング ソフトウェアリセット、スタートバイト、デバイスID(ソフトウェアサポートも必要) コマンドおよび送信FIFO(4ワード、8ビット送信データ+3ビットコマンド) 受信FIFO(4ワード、8ビット受信データ) I²Cバス転送の開始時間を制御するためのホスト要求入力 受信データマッチングによる、データ一致時および不要なデータ拒否時の割り込み生成 繰り返し開始条件、停止条件、アービトレーションの喪失、予期しないNACK、およびコマンドワードエラー時のフラグとオプションの割り込み信号 設定可能なバスアイドルタイムアウトおよびピンスタックロータイムアウト 独立したI²Cターゲットレジスタ 7ビットまたは10ビットのアドレス指定 割り込みまたはDMA要求をサポートする送/受信データレジスタ ACKまたはNACKをソフトウェアで制御可能 送信FIFOアンダーランおよび受信FIFOオーバーランエラーを回避するためのクロックストレッチング設定可能 パケット終了時のフラグおよびオプションの割り込み、ストップコンディション、またはビットエラー検出 4. 使用機材と開発ツール   4.1 評価ボード(FRDM-MCXA153) 今回の実習に使用する機材は、Windows PCとMCX A153用の評価キットFRDM-MCXA153(FRDM-MCXA153 Development Board using MCUXpresso | NXP Semiconductors )です。 USB Type-CケーブルはFRDM-MCXA153に同梱されています。FRDM-MCXA153の基板情報や回路については、Webの「デザイン・ファイル」をクリックすると入手できます。(アカウント登録が必要) FRDM-MCXA153には温度センサーP3T1755が搭載されています。初期状態ではP3T1755がI3C0に接続されているため、今回はピン設定を変更してLPI2Cに接続し、LPI2Cで温度を読み出します。 P3T1755からLPI2Cへの割り込みラインは配線されていないため、LPI2Cはポーリング方式のマスターとして使います。また、MCX A153とP3T1755の信号線にはプルアップ抵抗がないため、外付け抵抗を追加します。 4.2 開発ツール(MCUXpresso for VS CodeとIDE) 本記事では、MCUXpresso for VS CodeまたはMCUXpresso IDEを使って、SDKサンプルを編集・実行します。開発ツールは、プロジェクトの作成、コード編集、設定、実行を行うための環境です。ツールのインストール方法や初期設定は、本記事では扱いません。使用する環境に合わせて、NXPの公式ガイドを参照してください。 5. プログラミング   この章のポイント:まずサンプルコードの動きを理解し、その後にP3T1755用へ変更します。   5.1 ベースとなるサンプルコードの内容を確認する I²Cのサンプルプログラムとしていくつかのプログラムが準備されています。 今回は、ポーリングを使ったマスターの「lpi2c_edma_b2b_polling_master」のサンプルプログラムを使います。このサンプルプログラムを変更して、FRDM-MCXA153に搭載されている温度センサーのP3T1755からI²Cを使って温度データを読み取るプログラムを作ります。 デフォルトだと、P3T1755にはI3CモジュールI3C0がつながっていますが、プログラムを変更することでLPI2Cにつなぎ変えて、LPI2Cを使ってP3T1755の温度を読み出すプログラムを作ります。 FRDM-MCXA153では、P3T1755からLPI2Cに割り込みラインは配線されていないため、LPI2Cはポーリングのマスターで使わなければなりません。また、MCX A153とP3T1755をつなぐ配線にはプルアップ抵抗が付いていないため、プルアップ抵抗を追加します。 このサンプルでは、一方のボードに lpi2cインスタンスをマスターとして、もう一方のボードに lpi2cインスタンスをスレーブとして実装します。マスターはスレーブにデータを送信し、スレーブからデータを受信します。このサンプルでは、スレーブから受信したデータが正しいかどうかを確認します。 通信手順の概略は、次のようになります。 マスターから通信開始の合図(スタートコンディション)を送信 マスターからスレーブアドレスを送信 スレーブからマスターに通信可能の合図(アクノリッジ)を返す データの通信を行う (送信データに応じて繰り返す) マスターから通信終了の合図(ストップコンディション)を出す さらに細かく分けると、スレーブに情報を書き込むWrite制御と、スレーブから情報を読み出すRead制御の2つに分けられます。最初にWrite制御を行い、次にRead制御を行い、温度データを読み出します。 ポーリングを使ったマスター側の制御としては、これが基本手順です。スレーブがマイコンのI²Cモジュールだろうが、温度センサーなどのセンサーICだろうが、同じです。 [Write制御] Write制御の手順は、次のようになります。使用する関数と説明を記載します。 ①Start コンディション + スレーブアドレス + ライトビット を送信: LPI2C_MasterStart:スタート信号とスレーブアドレスを送信。 この関数は新しいマスターモード転送を開始する。 ②ターゲットデバイスのレジスタアドレスとデータを送信: LPI2C_MasterSend:I²Cバスにデータを送信。 この関数はバッファのデータを送信するまで待機する。 ③Stop コンディションを送信: LPI2C_MasterStop:I²Cバスにストップ信号を送信。 この関数はストップ信号が送信されるまで待機し、トランザクション が終了するまで待機する。 [Read制御] Read制御の手順は、次のようになります。ここでも使用する関数と説明を記載します。 ①Startコンディション + スレーブアドレス + ライトビットを送信: LPI2C_MasterStart:スタート信号とスレーブアドレスを送信。 この関数は新しいマスターモード転送を開始する。 ②ターゲットデバイスのレジスタアドレスを送信: LPI2C_MasterRepeatedStart:LPI2C_MasterStart を再度実行する。 この関数では通常、レジスタアドレスを送る ③Startコンディション + スレーブアドレス + リードビットを送信: LPI2C_MasterReceive:I²Cバスからデータを受信。 この関数はバッファのデータを転送するまで待機する。 ④ターゲットデバイスのデータを受信: LPI2C_MasterSend:I²Cバスにデータを送信。 この関数はバッファのデータを送信するまで待機する。 ⑤Stop コンディションを送信: LPI2C_MasterStop:I²Cバスにストップ信号を送信。 この関数はストップ信号が送信されるまで待機し、トランザクションが終了するまで待機する。 サンプルプログラム「lpi2c_edma_b2b_polling_master」のフローチャートを、最後の章の補足説明に載せておきました。参考にしてください。 また、使用されている関数の説明は MCX A153 API Reference にありますが、今回使用する関数の説明を最後の章の補足説明に抜き出しました。こちらも参考にしてください。 5.2 ピン設定 P3T1755は、デフォルトだとI3CモジュールのI3C0がつながっていますので、これをLPI2Cにつなぎ変える必要があります。ピン接続の変さらにはConfig Tools というツールの中の、Pin Configuratorという便利な機能を使います。Pin Configuratorを使うと、GUIでピン割り当てを変更できて、さらに自動でC言語コードまで作ってくれます。具体的な操作は実習の章で詳しく説明します。 5.3 プログラムコードの変更点 通信の基本的な流れはサンプルと同じですが、P3T1755に合わせて、スレーブアドレス、レジスタアドレス、データ長を変更します。さらに、受信した16ビット値を温度へ変換します。 まず、スレーブアドレスをP3T1755の0x48Uに変更します サンプルプログラムでは扱うデータが33バイトですが、P3T1755の場合は16ビットの温度データですので、データ長を16ビットに変更します P3T1755から読み出す温度データ16ビットを入れる定数を定義します。ここではtemperatureとします レジスタアドレスは、deviceAddressで定義されていて、0x01Uですが、P3T1755の場合は0x00Uです 転送するデータの数をtxCountで定義していて、サンプルプログラムでは0xFFUですが、P3T1755から読み出す温度データは2バイト(16ビット)なので、0x01Uに減らします サンプルプログラムでは、マスターが送信したデータと同じデータがスレーブから返ってきて、送受信データの比較を行っていますが、ここの処理は不要です その代わりにP3T1755から受信したデータを温度データとしてまとめる処理が必要です。P3T1755から受信するデータは2バイト(16ビット)です。受信バッファはg_master_rxBuff[1]とg_master_rxBuff[0]で定義しており、各々1バイトが入りますので、 g_master_rxBuff[0]を上位バイト、g_master_rxBuff[1]を下位バイトとして 16 ビットに結合します。結合結果をtempに入れます 結合した温度データの1ビットが0.0625℃に相当しますので、0.0625倍すると温度が得られます。幸いにも0.0625倍は、浮動小数点演算など使わずに、右に4ビットシフトすると簡単に計算できます。計算結果はtemperatureに入れます 最後にtemperatureをprintfで表示します     6. 実習   この章では、ツールのインストールや画面操作の詳細ではなく、必要なハードウェア準備と、P3T1755用にコードを変更するポイントに集中します。   6.1 実習内容 FRDM-MCXA153に搭載されたP3T1755温度センサーを、LPI2Cで読み出します。P3T1755は初期状態ではI3C0に接続されているため、LPI2Cへ接続するピン設定が必要です。また、I²C信号線にはプルアップ抵抗を追加します。 ソフトウェアでは、LPI2CのSDKサンプルをベースに、P3T1755のスレーブアドレス、レジスタアドレス、データ長、温度データの計算処理を変更します。 6.2 実習手順(概要) 評価ボードのSDA・SCLに4.7kΩのプルアップ抵抗を接続します。 MCUXpresso環境でLPI2Cのサンプルプロジェクトを準備します。具体的なインストール・インポート手順は省略します。 ピン設定を、P3T1755が接続されているLPI2C用のピンへ変更します。 次の6.7節に示すコード変更を行います。 プログラムを実行し、温度値が出力されることを確認します。   6.3 評価ボードにプルアップ抵抗を付ける P3T1755のI²CラインにはJunction PA(J20、J21)が設けられています。J20とJ21に4.7kΩの抵抗を付け、SDAとSCLをプルアップ接続してください。 重要! 内蔵プルアップだけでは、ボードによって通信が安定しない場合があります。確実に通信するため、外付けのプルアップ抵抗を使用してください。 6.4 変更点のコーディング プログラミングの章で説明した内容を、実際の.cファイルにコーディングします。 「5.3 プログラムコードの変更点」で説明した変更内容を、コードに反映していきます。 (1)スレーブアドレスをP3T1755の0x48Uに変更する。 [変更前]#define LPI2C_MASTER_SLAVE_ADDR_7BIT 0x7EU [変更後]#define LPI2C_MASTER_SLAVE_ADDR_7BIT 0x48U (2)データ長を16ビットに変更する。 [変更前]#define LPI2C_DATA_LENGTH 33U [変更後]#define LPI2C_DATA_LENGTH 2U (3)P3T1755から読み出す温度データ16ビットを入れる定数temperatureを定義する。 [追加]uint16_t temperature; (4)レジスタアドレスdeviceAddressを0x00Uに変更する。 [変更前]uint8_t deviceAddress = 0x01U; [変更後]uint8_t deviceAddress = 0x00U; (5)転送データ数txCountを0x01Uに変更する。 [変更前]size_t txCount = 0xFFU; [変更後]size_t txCount = 0x01U; (6)受信データの数の調整 [変更前]reVal = LPI2C_MasterReceive(EXAMPLE_I2C_MASTER, g_master_rxBuff, LPI2C_DATA_LENGTH - 1); [変更後]reVal = LPI2C_MasterReceive(EXAMPLE_I2C_MASTER, g_master_rxBuff, LPI2C_DATA_LENGTH); (7)送信データと受信データの比較部分を削除。 [削除] /* Transfer completed. Check the data.*/以下のコード (8)P3T1755から受信したデータを温度データとしてまとめる。g_master_rxBuff[0]を上位バイト、g_master_rxBuff[1]を下位バイトとして 16 ビットに結合し、結合結果をtempに入れる。 [追加] temp = (((uint16_t) g_master_rxBuff[0] << 8U) | (uint16_t) g_master_rxBuff[1]) >> 4U; (9)tempを右に4ビットシフトしてtemperatureに入れる。 [追加]temperature = temp >> 4; (10)temperatureをprintfで表示します。 [追加] PRINTF("Temperature=%d", temperature); PRINTF("Celsius"); (11)最後には、無限ループを入れておきます。 [追加]while (1) {} ここまでの変更を反映した全コードを、参考として以下に示します。   [全コード] /* * Copyright 2017 NXP * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ /* Standard C Included Files */ #include #include #include "board.h" #include "fsl_debug_console.h" #include "fsl_lpi2c.h" #include "app.h" /******************************************************************************* * Definitions ******************************************************************************/ #define EXAMPLE_I2C_MASTER ((LPI2C_Type *)EXAMPLE_I2C_MASTER_BASE) #define LPI2C_MASTER_SLAVE_ADDR_7BIT 0x48U #define LPI2C_BAUDRATE 100000U #define LPI2C_DATA_LENGTH 2U /******************************************************************************* * Prototypes ******************************************************************************/ /******************************************************************************* * Variables ******************************************************************************/ uint8_t g_master_txBuff[LPI2C_DATA_LENGTH]; uint8_t g_master_rxBuff[LPI2C_DATA_LENGTH]; uint16_t temp; /* 追加 */ uint16_t temperature; /* 追加 */ /******************************************************************************* * Code ******************************************************************************/ /*! * @brief Main function */ int main(void) { lpi2c_master_config_t masterConfig; status_t reVal = kStatus_Fail; uint8_t deviceAddress = 0x00U; size_t txCount = 0x01U; BOARD_InitHardware(); /* Set up i2c master to send data to slave*/ /* First data in txBuff is data length of the transmiting data. */ g_master_txBuff[0] = LPI2C_DATA_LENGTH - 1U; for (uint32_t i = 1U; i < LPI2C_DATA_LENGTH; i++) { g_master_txBuff[i] = i - 1; } for (uint32_t i = 0U; i < LPI2C_DATA_LENGTH - 1U; i++) { if (i % 8 == 0) { } } /* * masterConfig.debugEnable = false; * masterConfig.ignoreAck = false; * masterConfig.pinConfig = kLPI2C_2PinOpenDrain; * masterConfig.baudRate_Hz = 100000U; * masterConfig.busIdleTimeout_ns = 0; * masterConfig.pinLowTimeout_ns = 0; * masterConfig.sdaGlitchFilterWidth_ns = 0; * masterConfig.sclGlitchFilterWidth_ns = 0; */ LPI2C_MasterGetDefaultConfig(&masterConfig); /* Change the default baudrate configuration */ masterConfig.baudRate_Hz = LPI2C_BAUDRATE; /* Initialize the LPI2C master peripheral */ LPI2C_MasterInit(EXAMPLE_I2C_MASTER, &masterConfig, LPI2C_MASTER_CLOCK_FREQUENCY); /* Send master start bit &Slave Address + Write Bit */ if (kStatus_Success == LPI2C_MasterStart(EXAMPLE_I2C_MASTER, LPI2C_MASTER_SLAVE_ADDR_7BIT, kLPI2C_Write)) { LPI2C_MasterGetFifoCounts(EXAMPLE_I2C_MASTER, NULL, &txCount); while (txCount) { LPI2C_MasterGetFifoCounts(EXAMPLE_I2C_MASTER, NULL, &txCount); } if (LPI2C_MasterGetStatusFlags(EXAMPLE_I2C_MASTER) & kLPI2C_MasterNackDetectFlag) { return kStatus_LPI2C_Nak; } reVal = LPI2C_MasterSend(EXAMPLE_I2C_MASTER, &deviceAddress, 1); if (reVal != kStatus_Success) { if (reVal == kStatus_LPI2C_Nak) { LPI2C_MasterStop(EXAMPLE_I2C_MASTER); } return -1; } reVal = LPI2C_MasterSend(EXAMPLE_I2C_MASTER, g_master_txBuff, LPI2C_DATA_LENGTH); if (reVal != kStatus_Success) { if (reVal == kStatus_LPI2C_Nak) { LPI2C_MasterStop(EXAMPLE_I2C_MASTER); } return -1; } reVal = LPI2C_MasterStop(EXAMPLE_I2C_MASTER); if (reVal != kStatus_Success) { return -1; } } for (uint32_t i = 0U; i < WAIT_TIME; i++) { __NOP(); } if (kStatus_Success == LPI2C_MasterStart(EXAMPLE_I2C_MASTER, LPI2C_MASTER_SLAVE_ADDR_7BIT, kLPI2C_Write)) { /* Check master tx FIFO empty or not */ LPI2C_MasterGetFifoCounts(EXAMPLE_I2C_MASTER, NULL, &txCount); while (txCount) { LPI2C_MasterGetFifoCounts(EXAMPLE_I2C_MASTER, NULL, &txCount); } /* Check communicate with slave successful or not */ if (LPI2C_MasterGetStatusFlags(EXAMPLE_I2C_MASTER) & kLPI2C_MasterNackDetectFlag) { return kStatus_LPI2C_Nak; } reVal = LPI2C_MasterSend(EXAMPLE_I2C_MASTER, &deviceAddress, 1); if (reVal != kStatus_Success) { if (reVal == kStatus_LPI2C_Nak) { LPI2C_MasterStop(EXAMPLE_I2C_MASTER); } return -1; } reVal = LPI2C_MasterRepeatedStart(EXAMPLE_I2C_MASTER, LPI2C_MASTER_SLAVE_ADDR_7BIT, kLPI2C_Read); if (reVal != kStatus_Success) { return -1; } reVal = LPI2C_MasterReceive(EXAMPLE_I2C_MASTER, g_master_rxBuff, LPI2C_DATA_LENGTH); if (reVal != kStatus_Success) { if (reVal == kStatus_LPI2C_Nak) { LPI2C_MasterStop(EXAMPLE_I2C_MASTER); } return -1; } reVal = LPI2C_MasterStop(EXAMPLE_I2C_MASTER); if (reVal != kStatus_Success) { return -1; } } for (uint32_t i = 0U; i < LPI2C_DATA_LENGTH; i++) { if (i % 8 == 0) { } } temp = (((uint16_t) g_master_rxBuff[0] << 8U) | (uint16_t) g_master_rxBuff[1]) >> 4U; temperature = temp >> 4; PRINTF("Temperature=%d", temperature); PRINTF("Celsius"); while (1) { } }   6.5 PIN Configuratorを使ってピン設定を変更   P3T1755につながっているI3CをLPI2Cにつなぎ変えます。これは、プログラムコードを変更するのではなく、MCUXpresso Config Toolsの中のPin Configuratorというツールを使って行います。 まず、デフォルトで33ピンと34ピンがLPI2C0_SDAとLPI2C0_SCLに設定されているのを無効化します。Pinsタグで、下にスクロールして33ピンと34ピンを表示します。そして、右にスクロールしてLPI2C列を表示します。33ピンと34ピンのLPI2C列に表示されているLPI2C0_SDAとLPI2C0_SCLを、それぞれクリックすると、33ピンと34ピンが無効化されます。 次に、Pinsタグで、54ピンをLPI2C0_SDAに割り当てます。54ピンのチェックボックスをクリックすると、ピンに割り当てられている全機能が表示されます。その中からLPI2C0:SDAを選択します。すると、Pinsタグの54ピンが緑色に変わります。「Done」をクリックして割り当て完了です。 同じように、Pinsタグで、 55ピンをLPI2C0_SCLに割り当てます。55ピンのチェックボックスをクリックして、LPI2C0:SCLを選択します。すると、Pinsタグの55ピンが緑色に変わります。「Done」をクリックして割り当て完了です。 次に、54ピンと55ピンの機能設定を行います。機能設定には、下段にある「Routing Details for …」を使います。 Routing Details for …で、54ピン(LPI2C0_SDA)と55ピン( LPI2C0_SCL )のPull SelectをPullupに、Pull enableをEnabledに変更します。LabelをI2C_SDA とI2C_SCLにしておくと、board/pin_mux.h に定義を追加してくれます。 ピン設定は、これで完了です。 今までの変更内容をコードに反映させるには、Update Codeボタンをクリックします。 6.6 ビルド&デバッグ、動作確認 コードの変更が終わったら、ビルドします。 Projectsにカーソルを持っていくと、ビルドボタンが現れます。クリックするとビルドされます。 「build finished successfully.」のメッセージが出ればOKです。 ビルドボタンの隣に、デバッグボタンがあります。これをクリックすると、デバッグモードに入ります。 デバッグモードに入ると、プログラムはブレイクポイントで止まっているので、画面上部のアイコン内の「|▶」をクリックします。するとプログラムが走ります。 Tera Termの画面に、温度が表示されます。 まとめ 本記事では、I²Cの基本的な通信方式と、MCX A153に搭載されているLPI2Cモジュールの主な機能について説明しました。また、FRDM-MCXA153に搭載されたP3T1755温度センサーを例に、プルアップ抵抗の追加、Pin Configuratorによるピン設定、LPI2CのSDKサンプルコードの変更方法を確認しました。I²C通信では、スレーブアドレスやレジスタアドレス、データ長を接続するデバイスの仕様に合わせて設定することが重要です。本記事の内容を参考に、センサーやEEPROMなど、さまざまなI²Cデバイスとの通信に応用してください。 =========================​ 本投稿の「Comment」欄にコメントをいただいても、現在返信に対応しておりません。​ お手数をおかけしますが、お問い合わせの際には「NXPへの技術質問 - 問い合わせ方法 (日本語ブログ)」をご参照ください。​ (既に弊社NXP代理店、もしくはNXPとお付き合いのある方は、直接担当者へご質問いただいてもかまいません。)​ 本記事は、NXPマイコンMCX A153に搭載されているLPI2C(Low Power Inter-Integrated Circuit)コントローラを題材にします。I²Cの基本を確認した後、I²CとLPI2Cの違いについて説明し、MCX A153のLPI2Cの仕様・使い方を学びます。 (読了時間: 30分) MCUXpresso IDE MCUXpresso SDK MCX 日本語ブログ
View full article
Demo EthernetAnalyzer FRDM-A-S32K344 RTD 7.0.1 S32K344 Embedded Ethernet Analyzer Demo with LVGL Overview This article presents an embedded Ethernet Analyzer demo for the S32K344 MCU and the FRDM-A-S32K344 development board.The application captures received and transmitted Ethernet frames and displays them directly on an LCD-PAR-S035 touchscreen. It provides a compact, stand-alone view of Ethernet traffic without requiring the captured frames to be transferred to a host PC.The demo is available in two variants: Bare-metal lwIP application FreeRTOS lwIP application Both variants use the same Ethernet Analyzer, frame parser and graphical application layers.   Figure 1: Complete FRDM-A-S32K344 and LCD-PAR-S035 hardware setup Motivation PC-based packet analyzers remain the preferred solution for detailed network debugging. However, the frames visible to a PC capture application may depend on the Ethernet adapter and its driver configuration.For example, some adapters may process or remove an IEEE 802.1Q VLAN tag before the frame is delivered to the capture application. This can make analysis of VLAN-tagged traffic less straightforward. Automotive Ethernet applications may also use an IEEE 802.1CB redundancy tag, commonly referred to as an R-TAG.The purpose of this demo is to provide a direct view of the Ethernet frames processed by the S32K3 Ethernet interface and to make basic VLAN and R-TAG inspection available directly on the development board.The application is intended as a compact demonstration and debugging aid. It is not intended to replace a full-featured PC packet analyzer.   Main Features The application provides: Capture of received Ethernet frames Capture of transmitted Ethernet frames Configurable RX and TX capture Storage of frame snapshots in a bounded internal buffer Graphical frame list Selection and inspection of individual frames Hexadecimal frame data view Basic decoding of: Source and destination MAC addresses EtherType IEEE 802.1Q VLAN tags IEEE 802.1CB R-TAGs ARP IPv4 ICMP VLAN, R-TAG and multicast display filters RX and TX activity indication Start, pause, resume, stop and clear controls Capacitive touchscreen operation Preserved lwIP TCP/IP connectivity   Figure 2: Frame list with standard Ethernet traffic  Figure 3: Frame list with VLAN and R-TAG traffic  Frame Details A captured frame can be selected from the frame list and opened in the Frame Details screen. This screen provides decoded information about the selected frame together with a hexadecimal data dump. The raw frame data can therefore be compared with the decoded Ethernet, VLAN, R-TAG and higher-layer protocol fields.   Figure 4: Frame Details screen showing decoded fields and hexadecimal data Capture Settings The Capture Settings screen can be used to enable or disable RX and TX capture and to select the types of frames displayed by the application.The available display filters include VLAN-tagged frames, R-TAG frames and multicast frames.   Figure 5: Capture Settings screen Software Architecture The Ethernet capture path is separated from frame decoding and graphical processing. The RX and TX hooks copy a bounded frame snapshot into an application-managed ring buffer. The captured frame is subsequently decoded and displayed from the application context. LVGL functions are not called directly from the Ethernet RX or TX processing context. GUI refresh and activity indication are deferred to the graphical application processing path. The main application-specific software layers are: App.c/.h Application initialization and periodic processing of the LCD, touchscreen, LVGL and Ethernet Analyzer GUI. eth_analyzer.c/.h Frame capture, capture state control, filtering and storage of RX and TX frame snapshots. eth_analyzer_parser.c/.h Parsing and decoding of Ethernet, VLAN, R-TAG and selected higher-layer protocol fields. eth_analyzer_gui.c/.h Connection between the analyzer data model and the LVGL graphical interface.   For a detailed description of the project structure, software components, hardware connections and configuration, refer to the comments in src/main.c. Graphical Application The graphical interface uses LVGL 9.4.0 and was designed using NXP GUI Guider 2.0.1.The GUI Guider-generated screens, widgets and event handlers are stored separately from the custom GUI callbacks and Ethernet Analyzer application logic. This separation allows the graphical screens to be modified in GUI Guider while keeping the custom application layers maintainable. Font Roboto Mono is used for selected frame information and hexadecimal data. The generated LVGL font data retains the original SIL Open Font License 1.1 terms. The original GUI Guider project is included with this article, allowing the graphical application to be modified and regenerated using GUI Guider 2.0.1.   TCP/IP Connectivity The original lwIP TCP/IP functionality is preserved. The example uses the following static IPv4 address 192.168.0.209 Connectivity can be verified from a host configured for the same IPv4 subnet. ping 192.168.0.209 The ping response time may vary while the captured frame list is being refreshed. GUI rendering and blocking LCD transfers temporarily occupy processing time, but the TCP/IP stack remains operational.   Hardware The demo was developed and tested with: S32K344 MCU FRDM-A-S32K344 development board LCD-PAR-S035 display ST7796S LCD controller GT911 capacitive touchscreen controller The display is connected through LPSPI. The touchscreen uses LPI2C together with GPIO signals for interrupt and reset control. Detailed signal connections and hardware configuration are documented in main.c and README.md in the attached projects. Software Requirements NXP S32 Design Studio for S32 Platform 3.6.6 S32K3 RTD 7.0.1 FreeRTOS for S32K3 11.1.0 TCP/IP Stack for S32K3 5.0.0 LVGL 9.4.0 NXP GUI Guider 2.0.1 The attached project packages include README.md, Dependencies.txt, applicable software bill of materials files, license texts and the NXP disclaimer.   Porting to Other Boards The Ethernet Analyzer, parser and GUI layers were intentionally separated from the board-specific LCD, touchscreen and Ethernet initialization.This architecture can be adapted to other S32K3-based FRDM or evaluation boards. Porting requires board-specific changes, including: MCU and board configuration Ethernet controller and PHY setup Pin multiplexing Clock configuration LCD and touchscreen connections RTD and TCP/IP Stack configuration Available flash and RAM resources The project should therefore be treated as a reusable integration reference rather than as a drop-in project for every S32K3 board.   Known Limitations This project is a demonstration application and has several intentional limitations: The internal capture buffer has a finite capacity. Only a bounded portion of each frame is stored. Frame capture and GUI rendering consume MCU processing time. LCD transfers use blocking LPSPI communication. RX and TX indicators are informational and may not visibly represent every individual event. The protocol parser supports selected Ethernet and higher-layer fields only. The analyzer is not intended to provide the capture performance or protocol coverage of a dedicated PC-based packet analyzer. The application has not been designed or qualified as a production monitoring solution.   Attached Projects The following project variants are provided:   Demo_EthernetAnalyzer_BareMetal_FRDM_A_S32K344_v1_0_RTD701 Demo_EthernetAnalyzer_FreeRTOS_FRDM_A_S32K344_v1_0_RTD701 The original GUI Guider project is also included: Demo_EthernetAnalyzer_GUI_Guider_v1_0_GG201 The GUI project can be opened and modified using NXP GUI Guider 2.0.1. It contains the screens, widgets, events, custom callbacks and graphical assets used by the Ethernet Analyzer application. After modifying the graphical application, copy the contents of the GUI Guider generated and custom output directories into the corresponding src/gui_guider directories of the BareMetal or FreeRTOS project. The GUI Guider project package includes the applicable license information and software component documentation. This article presents BareMetal and FreeRTOS variants of an embedded Ethernet Analyzer demo for the S32K344 MCU. The application captures RX and TX Ethernet frames and displays them directly on an LCD-PAR-S035 touchscreen, including basic decoding of VLAN and IEEE 802.1CB R-TAG information and hexadecimal inspection of individual frames. The graphical interface uses LVGL 9.4.0 and was created with NXP GUI Guider 2.0.1.
View full article
能源革命系统评测:它真的有效吗? 如果您正苦于无法预测的停电、不断上涨的每月电费,或者只是想为您的家人建立一个可靠的离网能源备用系统,那么您并不孤单。 最近,能源革命系统在互联网上引起了轰动。这本书被宣传为一本循序渐进的 DIY 指南,教普通人如何在家制造清洁、便携式发电机,这在在线技术论坛和社区留言板上引发了广泛的讨论。 事实上,用户和 DIY 技术爱好者正在NXP 社区论坛和技术问答网站等平台上热烈讨论该系统,询问这些 DIY 磁线圈原理是否真的能转化为现实世界的家庭电力。 在这篇令人震惊的评论中,我们将深入探讨能源革命系统究竟是什么,它是如何运作的,它包含什么,以及它是否真的能在 2026 年兑现其承诺。 产品快速概览 产品名称:能源革命系统 类别:替代能源/DIY家居改造/离网电力 格式:电子蓝图、分步操作手册和高清视频指南 组装时间: 2至4小时(适合初学者) 官方门户网站:点击此处访问官方能源革命系统 退款保证: 60 天(100% 无条件退款) 等级: ⭐⭐⭐⭐⭐ (4.8/5) 什么是能源革命系统? 能源革命系统是一个全面的数字化教学蓝图,旨在指导初学者组装一台静音、轻便且经济高效的能源发电机。 与昂贵、噪音大、耗油的商用发电机不同,该装置专注于使用易于获取的硬件部件(如磁线圈、电线、电池储能组和标准逆变器)来捕获电流。 目标很简单: 大幅降低您的水电费:使用自发电为日常电子产品、照明设备和家用电器供电。 紧急停电保护:在恶劣天气导致电网瘫痪时,准备好安全、适合室内使用的备用电源。 它的工作原理是什么? 其核心机制依赖于基本的电转换和谐振原理。该程序会向您展示如何将磁能捕获装置连接到深循环电池。 能量捕获:线圈结构能够高效地捕获微小的电荷。 存储:能量持续输入到您的电池储能系统中。 逆变器转换:简单的电源逆变器可以将直流电转换为标准的家用交流电。 即插即用:您可以将家用电源插座、充电器、灯具、风扇和小电子产品直接插入本机。 由于它无需内燃即可运行,因此不会产生任何有害烟雾,而且运行完全静音,因此可以在客厅、卧室或公寓内安全使用。 本指南包含哪些内容? 当您从官方网站订购时,即可立即获得以下数字下载权限: 高分辨率蓝图和图表:易于阅读的原理图,显示每个连接和电线规格。 完整的五金材料清单:一份详细的清单,告诉你应该在当地的五金店(如家得宝、劳氏或当地电子产品商店)购买哪些零件,才能获得最优惠的价格。 高清演示视频教程:一步一步的视频说明,展示从开始到结束的组装过程。 维护和扩展手册:延长电池寿命和排除设置故障的指南。 它真的有效吗?(令人震惊的真相) 是的,它确实有效——前提是你的期望值要现实一些。 如果你指望花费 100 美元自制一个工作台就能立即为一栋五居室豪宅或一台工业空调机组供电,那你肯定会失望的。然而,正如成千上万的 DIY 建造者和社区论坛用户所证实的那样,如果按照蓝图建造,它可以提供非常可靠的辅助电源。 它非常适合为普通家用电器、LED 照明、Wi-Fi 路由器、电视屏幕和手机充电器供电,从而大大减轻电表负荷,每年为您节省数百美元的电费。 优点和缺点 优点 大幅降低成本:立即降低您的每月电费支出。 100% 静音安全:无噪音电机或危险的一氧化碳气体。 适合初学者:无需任何电气方面的知识——清晰的视频指南将引导您完成每个步骤。 60 天退款保证:您可以完全无风险地试用本指南两个月。 缺点 需要自行组装:您必须单独购买硬件零件,并花费 2 到 3 个小时进行组装。 仅提供电子版:通过即时 PDF 和视频下载以电子方式交付。 最终结论:2026年还值得购买吗? 由于电网不稳定且电价达到历史新高,掌控家庭能源需求是一个明智之举。能源革命系统提供简单易懂、万无一失的蓝图,将看似复杂的 DIY 建造项目变成一个有趣的周末项目。 我们提供60 天退款保证,您没有任何损失,却能获得真正的能源独立。 立即领取您的专属折扣! 不要等到下一次大风暴或电价飙升才去寻求电力保障。今天就迈出通往能源自由的第一步! 👉 点击这里访问官方能源革命系统网站,立即领取您的 2026 年折扣!
View full article
コードを生成できません コード生成プロセスが停止します。 Re: 无法生成代码 この問題は解決しましたか? Re: 无法生成代码 こんにちは、 @Cui5222 さん。 お使いのGUI Guiderのバージョンは何ですか?本当にインターネットにコネクテッドのですか?GUI Guiderを管理者として実行してみてはどうでしょうか?
View full article
Energy Revolution System Review: Does It Actually Work? If you are struggling with unpredictable power outages, rising monthly electricity bills, or simply want to build a reliable off-grid energy backup for your family, you are not alone. Recently, the Energy Revolution System has taken the internet by storm. Promoted as a step-by-step DIY guide that teaches everyday people how to build a clean, portable power generator at home, it has sparked massive debates across online tech forums and community message boards. In fact, users and DIY tech enthusiasts are heavily discussing this system on platforms like the NXP Community Forum and tech Q&A sites, asking whether these DIY magnetic coil principles genuinely translate into real-world household power. In this shocking review, we take a deep dive into what the Energy Revolution System really is, how it works, what you get inside, and whether it actually delivers on its promises in 2026. Quick Product Overview Product Name: Energy Revolution System Category: Alternative Energy / DIY Home Improvement / Off-Grid Power Format: Digital Blueprints, Step-by-Step Manuals & HD Video Guides Assembly Time: 2 to 4 Hours (Beginner-Friendly) Official Portal: Click Here to Access the Official Energy Revolution System Money-Back Guarantee: 60 Days (100% Unconditional Refund) Rating: ⭐⭐⭐⭐⭐ (4.8/5) What Is the Energy Revolution System? The Energy Revolution System is a comprehensive, digital instructional blueprint designed to guide beginners through assembling a silent, lightweight, and cost-effective energy generator. Unlike expensive, loud, and gas-guzzling commercial generators, this setup focuses on capturing electrical current using easily sourced hardware parts—such as magnetic coils, wiring, a battery storage bank, and a standard inverter. The goal is simple: Slash Your Utility Costs: Use self-generated power to run everyday electronics, light fixtures, and appliances. Emergency Blackout Protection: Have a safe, indoor-friendly power backup ready when the power grid goes down during severe weather. How Does It Work? The core mechanism relies on basic electrical conversion and resonance principles. The program shows you how to connect a magnetic energy capture unit to a deep-cycle battery. Energy Capture: The coil configuration captures small electrical charges efficiently. Storage: Energy feeds continuously into your battery storage bank. Inverter Conversion: A simple power inverter converts the DC charge into standard AC household electricity. Plug & Play: You can plug household power strips, chargers, lamps, fans, and small electronics directly into the unit. Because it operates without internal combustion, it produces zero hazardous fumes and runs completely silent, making it safe to use inside your living room, bedroom, or apartment.  What Do You Get Inside the Guide? When you order from the official website, you gain immediate digital download access to: High-Resolution Blueprints & Diagrams: Easy-to-read schematics showing every connection and wire gauge. Complete Hardware Materials Checklist: A detailed list telling you exactly what parts to buy at local hardware stores (like Home Depot, Lowe's, or local electronics shops) for the best price. HD Walkthrough Video Tutorials: Step-by-step video instructions showing the assembly from start to finish. Maintenance & Expansion Manuals: Guidance on extending battery life and troubleshooting your setup. Does It Actually Work? (The Shocking Truth) Yes, it does work—provided you have realistic expectations. If you expect a $100 DIY bench build to instantly power a whole 5-bedroom mansion or industrial AC unit, you will be disappointed. However, as thousands of DIY builders and community forum users have confirmed, when built according to the blueprints, it delivers a very reliable supplementary power source. It excels at powering regular household electronics, LED lighting, Wi-Fi routers, TV screens, and phone chargers—taking significant load off your electric meter and saving you hundreds of dollars on utility bills each year. Pros and Cons Pros Drastic Cost Reduction: Lower your monthly electricity expenses right away. 100% Silent & Safe: No noisy motors or dangerous carbon monoxide fumes. Beginner Friendly: No prior electrical background required—clear video guides walk you through every step. 60-Day Money-Back Guarantee: Try the guide for two full months completely risk-free. Cons Assembly Required: You must buy the hardware parts separately and dedicate 2 to 3 hours to building it. Digital Format Only: Delivered electronically via instant PDF and video downloads. Final Verdict: Is It Worth Buying in 2026? With power grid instability and electricity prices reaching record highs, taking control of your home's energy needs is a smart move. The Energy Revolution System provides simple, foolproof blueprints that turn a seemingly complex DIY build into a fun weekend project. Backed by a 60-day money-back guarantee, you have nothing to lose and real energy independence to gain. Claim Your Discounted Access Today! Don't wait for the next major storm or price surge to leave you without power. Take the step toward energy freedom today! 👉 CLICK HERE to Visit the Official Energy Revolution System Website & Claim Your 2026 Discount Today!
View full article
无法生成代码 生成代码会卡住 Re: 无法生成代码 请问此问题有解决吗 Re: 无法生成代码 你好@Cui5222 , 你使用的是哪个版本的GUI Guider?你确定你已连接到互联网吗?您能否尝试以管理员身份运行 GUI Guider?
View full article
无法生成c语言代码 当组件超过30个的时候,无法生成代码,软件卡住不动,等好长时间也没用 Re: 无法生成c语言代码 是的,GUI Guider 1.10.0 项目不能在 2.0.0 中直接打开,也不能自动升级。具体请参考:Tutorials — GUI Guider Documentation Re: 无法生成c语言代码 新版本的guiguider导入不了之前旧版本做的界面设计吗?我这点击导入没有反应,我之前用的是1.10.1-GA版本。 Re: 无法生成c语言代码 应该是的,我还没有试,但是我看内部ticket关了。等我空了给你测试下。 Re: 无法生成c语言代码 好的,最新版的不限组件数量吗 Re: 无法生成c语言代码 Hello @J_T @iyutong  这个问题在GUI-Guider的最新版 v2.0.x得到解决,可以在GUI Guider | NXP 半导体下载试用。 BR Celeste Re: 无法生成c语言代码 请问该问题解决了吗? Re: 无法生成c语言代码 好的,了解,我会报告给相关team。 Re: 无法生成c语言代码 最新版1.9.1,也问题依旧,卡这不动,但1.9.1是在50个的时候开住的 最新版1.9.1最新版1.9.1 Re: 无法生成c语言代码 你好,感谢发帖。方便提供更多细节吗?你用的哪个版本的gui-guider。只是添加三十个以上的组件就可以100%复现这个问题吗? 麻烦您帮忙提供更多信息,以便我更好的复现并把情况反映到相关team。感谢理解!
View full article
C言語コードを生成できません コンポーネントが30個を超えると、コードが生成されず、ソフトウェアがフリーズし、長時間経過しても何も起こりません。 Re: 无法生成c语言代码 はい、GUI Guider 1.10.0このプロジェクトはバージョン2.0.0では直接開くことができず、自動アップグレードもできません。詳細は「チュートリアル - GUI Guiderドキュメント」を参照してください。 Re: 无法生成c语言代码 新しいバージョンのGuiGuiderでは、古いバージョンで作成したインターフェースデザインをインポートできないのでしょうか?インポートボタンをクリックしても何も反応がありません。以前はバージョン1.10.1-GAを使用していました。 Re: 无法生成c语言代码 そうであるはずです。まだ試していませんが、内部チケットがクローズされているのを確認しました。時間があるときにテストしてみます。 Re: 无法生成c语言代码 最新バージョンでは、コンポーネントの数に制限はないのでしょうか? Re: 无法生成c语言代码 こんにちは@J_T @iyutong この問題は、GUI-Guiderの最新バージョンであるv2.0.xで解決されています。最新バージョンは、GUI Guider | NXP Semiconductorsからダウンロードして試用できます。 BR セレステ Re: 无法生成c语言代码 この問題は解決しましたか? Re: 无法生成c语言代码 わかりました。担当部署に報告します。 Re: 无法生成c语言代码 最新バージョンの1.9.1でも同じ問題が残っています。フリーズして動かなくなりますが、バージョン1.9.1では50ユニットでロックが解除されます。 最新版1.9.1最新バージョン1.9.1 Re: 无法生成c语言代码 こんにちは、投稿ありがとうございます。もう少し詳しい情報をお聞かせいただけますか?お使いのgui-guiderのバージョンは何ですか?30個以上のコンポーネントを追加するだけで、この問題を100%再現することは可能でしょうか? 問題の再現性を高め、関係部署に報告するために、もう少し詳しい情報をご提供いただけますでしょうか?ご理解いただきありがとうございます。
View full article
Unable to generate code The code generation process gets stuck. Re: 无法生成代码 Has this problem been resolved? Re: 无法生成代码 Hi @Cui5222, What version of GUI Guider are you using? Are you certain you are connected to the internet? Could you try running GUI Guider as administrator? 
View full article
エネルギー革命システムレビュー:本当に効果があるのか? 予測不能な停電や月々の電気料金の高騰、あるいはファミリのために信頼できるオフグリッドのエネルギーバックアップを構築したい方は、一人ではありません。 最近、エネルギー革命システムがインターネット上で爆発的な人気を博している。家庭でクリーンでポータブルな発電機の組み立て方を教えるステップバイステップのDIYガイドとして宣伝されており、オンラインのテックフォーラムやコミュニティの掲示板で大きな議論を巻き起こしています。 実際、ユーザーやDIY技術愛好家はNXPコミュニティフォーラムや技術系プラットフォーム&Aサイトなどでこのシステムについて活発に議論し、これらのDIY磁気コイルの原理が本当に家庭用電力に繋がるかどうかを問い合っています。 この衝撃的なレビューでは、エネルギー革命システムとは一体何なのか、どのように機能するのか、その中身は何なのか、そして2026年に実際にその約束が果たされるのかどうかを徹底的に検証します。 簡単な製品概要 製品名: エネルギー革命システム カテゴリ: オルタナティブエネルギー / DIYホーム改修 / オフグリッド電源 形式:デジタル設計図、ステップバイステップマニュアル、HDビデオガイド 組み立て時間: 2~4時間(初心者向け) 公式ポータル:公式エネルギー革命システムにアクセスするにはこちらをクリックしてください。 返金保証: 60日間(100%無条件返金) 評価: ⭐⭐⭐⭐⭐ (4.8/5) エネルギー革命システムとは何ですか? エネルギー革命システムは、初心者でも静かで軽量、かつ費用対効果の高い発電機を組み立てられるよう設計された、包括的なデジタル設計図です。 高価で騒音が大きく、燃費の悪い業務用発電機とは異なり、このシステムは磁気コイル、配線、バッテリーバンク、標準的なインバーターなど、入手しやすいハードウェア部品を使用して電流を収集することに重点を置いています。 目標は単純だ。 光熱費を大幅に削減:自家発電した電力を使って、日常的に使用する電子機器、照明器具、家電製品を動かしましょう。 停電時の緊急対策:悪天候などで電力網が停止した場合に備え、安全で屋内でも使用できる予備電源を用意しておきましょう。 それはどのように機能しますか? その中核となるメカニズムは、基本的な電気変換と共振の原理に基づいている。このプログラムでは、磁気エネルギー回収ユニットをディープサイクルバッテリーに接続する方法を説明します。 エネルギー捕捉:コイル構造により、微弱な電荷を効率的に捕捉します。 蓄電:エネルギーはバッテリー蓄電バンクに継続的に供給されます。 インバータ変換:シンプルなパワーインバータは、直流(DC)電荷を標準的な家庭用交流(AC)電力に変換します。 プラグ&プレイ: 家庭用の電源タップ、充電器、ランプ、扇風機、小型電子機器を直接ユニットに接続できます。 内燃機関を使用しないため、有害な排気ガスを一切発生させず、完全に静かに作動するため、リビングルーム、寝室、アパートなど、室内での使用も安全です。 ガイドブックには何が含まれていますか? 公式ウェブサイトから注文すると、以下のデジタルダウンロードへのアクセスを即座に得られます: 高解像度設計図と図面:すべての接続箇所と電線サイズを示す、読みやすい回路図。 ハードウェア材料の完全なチェックリスト: ホームデポ、ローズ、地元の家電店などでどの部品を最良の価格で買えばよいかを詳細に示したリストです。 HD高画質ウォークスルービデオチュートリアル:組み立ての最初から最後までを段階的に解説するビデオ説明。 メンテナンスおよび拡張マニュアル:バッテリー寿命の延長方法とセットアップのトラブルシューティングに関するガイダンス。 それは本当に効果があるのか?(衝撃の真実) はい、効果はあります。ただし、現実的な期待を持つことが前提です。 もし100ドルのDIYベンチビルドで5ベッドルームのマンションやインダストリアルエアコンを即座に動かせると期待しているなら、期待がっかりするでしょう。しかし、何千人ものDIYビルダーやコミュニティフォーラムのユーザーが確認しているように、設計図に従って作ると非常に信頼性の高い補助電源を提供します。 通常の家庭用電子機器、LED照明、Wi-Fiルーター、テレビ画面、携帯電話の充電器に優れており、電気メーターの負荷を大幅に軽減し、年間数百ドルの光熱費を節約できます。 長所と短所 メリット 大幅なコスト削減:毎月の電気料金をすぐに削減できます。 100%静かで安全:騒音の出るモーターや危険な一酸化炭素ガスは一切ありません。 初心者向け:電気に関する予備知識は一切不要です。分かりやすいビデオガイドがすべての手順を丁寧に解説します。 60日間返金保証:ガイドを2ヶ月間、完全にリスクなしでお試しください。 短所 組み立て必須: ハードウェア部品は別途購入し、2〜3時間かけて組み立てる必要があります。 デジタル形式のみ: PDFおよびビデオの即時ダウンロードにより電子的に配信されます。 最終結論:2026年に購入する価値はあるのか? 電力網の不安定さや電気料金が過去最高値に達する中、ご自宅のホームのエネルギー需要をコントロールすることは賢明な選択です。エネルギー革命システムは、一見複雑そうなDIY作業を楽しい週末プロジェクトに変えるための、シンプルで確実な設計図を提供します。 60日間の返金保証付きなので、失うものは何もありません。得られるのは、真のエネルギー自立です。 今すぐ割引アクセスを申請しましょう! 次の大きな嵐や価格高騰で停電に見舞われるまで待ってはいけません。今日からエネルギーの自由への第一歩を踏み出しましょう! 👉 こちらをクリックして公式エネルギー革命システムウェブサイトにアクセスし、今すぐ2026年の割引を申請しましょう!
View full article
Unable to generate C language code When there are more than 30 components, code cannot be generated, the software freezes, and nothing happens even after a long time. Re: 无法生成c语言代码 Yes, GUI Guider 1.10.0The project cannot be opened directly in version 2.0.0, nor can it be automatically upgraded. Please refer to: Tutorials — GUI Guider Documentation for details. Re: 无法生成c语言代码 Can't the new version of GuiGuider import interface designs created in the old version? I'm not getting any response when I click import. I was using version 1.10.1-GA before. Re: 无法生成c语言代码 It should be. I haven't tried it yet, but I see the internal ticket is closed. I'll test it for you when I have time. Re: 无法生成c语言代码 Okay, is the latest version unlimited in the number of components? Re: 无法生成c语言代码 Hello @J_T @iyutong This issue has been resolved in the latest version of GUI-Guider, v2.0.x, which can be downloaded and tried from GUI Guider | NXP Semiconductors . BR Celeste Re: 无法生成c语言代码 Has this problem been resolved? Re: 无法生成c语言代码 Okay, I understand. I will report it to the relevant team. Re: 无法生成c语言代码 The latest version, 1.9.1, still has the same problem; it's stuck and won't move, but version 1.9.1 unlocks at 50 units. 最新版1.9.1The latest version 1.9.1 Re: 无法生成c语言代码 Hello, thank you for posting. Could you provide more details? Which version of gui-guider are you using? Is it possible to 100% reproduce this problem simply by adding more than thirty components? Could you please provide more information so I can better reproduce the issue and report it to the relevant team? Thank you for your understanding!
View full article
gAdvertisingStateChanged_cは、どの広告リクエストが完了したかを示していますか? こんにちは、 gAdvertisingStateChanged_cイベントについて質問があります。 Gap_StartAdvertising()またはGap_StopAdvertising()が呼び出されると、アプリケーションはgAdvertisingStateChanged_cイベントを待ってから次の操作に進みます。 しかし、受信したgAdvertisingStateChanged_cイベント情報が過去のGap_StartAdvertising()リクエストに対応しているのか、それとも以前のGap_StopAdvertising()リクエストに対応しているのかを確実に判断する方法はありますか? 例えば、広告状態の変更リクエストがほぼ同時に発行された場合、アプリケーションは特定の gAdvertisingStateChanged_c イベント情報をトリガーした API 呼び出しと関連付けることができるでしょうか? それとも、アプリが独自の州情報を維持して、保留中の広告リクエストを追跡することが推奨されるのでしょうか? ありがとうございます。 プロトコル:Bluetooth Re: Does gAdvertisingStateChanged_c indicate which advertising request completed? こんにちは、 ご説明いただきありがとうございます。 gAdvertisingStateChanged_c自体は、それが広告の開始要求によってトリガーされたのか、停止要求によってトリガーされたのかを示していないことが、今理解できました。ビーコンの例を確認すると、アプリケーションは内部で期待状態(例えばmAdvertisingOnやmAppTargetStateなどの変数を用いて)を追跡し、自身の状態機械に基づいてイベント情報を解釈しているようです。 ご支援ありがとうございます。このThreadは閉じます。 よろしくお願いいたします。 Re: Does gAdvertisingStateChanged_c indicate which advertising request completed? こんにちは、 @hyama さん。お元気でお過ごしでしょうか。 gAdvertisingStateChanged_cイベントには、広告の開始/停止コールによってトリガーされたかどうかを示す情報は含まれていません。推奨されているのは、アプリケーションが独自の状態を維持し、さらなる変更を追跡することです。 開発の参考として、 wireless_examples/bluetooth/beaconのSDK例を参照することをお勧めします。そこにはソフトウェア定義フラグを通じて広告イベント情報を追跡する実装が含まれています。 これが役に立つかどうか教えてください。
View full article
ECU BUS PRO ブートローダーを実装しようとしています。   バイナリファイルからMCUにデータをロードする必要があり、ECU BUS PROがこの機能を果たすことは理解しています。 しかし、最新バージョン(現在ECU BUS PRO 0.8.15を使用)では、バイナリファイルを添付するオプションがありません。 この機能は以前のバージョンでは利用可能だったようです。古いバージョンはどこで見つけてダウンロードできますか? これを実現するための代替案はありますか? Re: ECU BUS PRO こんにちは、 現在、 s32k342用のブートローダーを開発中です。開発はRTDバージョン6.0で行われています。(同じRTDバージョンはs32k344のブートローダー構築にも使用されており、これは機能し、ECUBUS Pro経由でアプリケーションをフラッシュする作業も完了しています) バス・マスタでCAN通信を確認しました。リクエスト0x02 10 03に対して、レスポンス0x02 50 03を受け取りました。 現在、Ecubus Proを介した通信に問題が発生しています。ECUBUS Proで同じリクエストを送信すると、バスエラーまたは上位レイヤータイムアウトが発生します。 私は以下のデバッグ作業を行いました。 CANのIDとそのフォーマットを照合しました。 user_config.h:CAN_RX:0x731、CAN_TX=0x739 EcuBus proインターフェース:CAN_TX=0x731、CAN_RX = 0x739 両CASEとも標準CANIdを使用しています ボーレート:500kbps、 CANビットタイミング: S32DSでg_RXCANMsgバッファをリアルタイムで監視すると、テスターからの要求メッセージがバッファに格納されます。 なぜバス・マスタで応答を受け取れるのに、EcuBus Proには返答が送られないのでしょうか? フラッシュ撮影中に他に注意すべき点はありますか?   ありがとう、 アキラ。 Re: ECU BUS PRO こちらをお試しください: https://app.whyengineer.com/examples/nxp_bootloader/readme.html Re: ECU BUS PRO こんにちは、 @parksuhun さん。 1.GitHubのEcuBusのリリースタブ(Releases · ecubus/EcuBus-Pro)に入り、すべてのプレビュビュスリリースを見つけることができます。 2. AN12323 S32K1xx Firmware updates – Application Noteも参照できます。ここではブートローダーとファームウェアアップデートの基本を説明しており、一方のボードがCAN経由でFWアップデートを送信し、もう一方のボードが更新されるデモも含まれています。 よろしくお願いします、 ジュリアン
View full article
Does gAdvertisingStateChanged_c indicate which advertising request completed? Hello, I have a question regarding the gAdvertisingStateChanged_c event. When Gap_StartAdvertising() or Gap_StopAdvertising() is called, the application waits for the gAdvertisingStateChanged_c event before proceeding to the next operation. However, is there a reliable way to determine whether a received gAdvertisingStateChanged_c event corresponds to a previous Gap_StartAdvertising() request or a previous Gap_StopAdvertising() request? For example, if advertising state change requests are issued close together, can the application correlate a specific gAdvertisingStateChanged_c event with the API call that triggered it? Or is it recommended that the application maintain its own state information to track pending advertising requests? Thanks. Protocol: Bluetooth Re: Does gAdvertisingStateChanged_c indicate which advertising request completed? Hello, Thank you for the clarification. I understand now that gAdvertisingStateChanged_c itself does not indicate whether it was triggered by an advertising start or stop request. After reviewing the beacon example, it appears that the application keeps track of the expected state internally (for example, by using variables such as mAdvertisingOn or mAppTargetState) and interprets the event based on its own state machine. Thank you for your support. I will close this thread. Best regards, Re: Does gAdvertisingStateChanged_c indicate which advertising request completed? Hello @hyama, hope you are doing well. The gAdvertisingStateChanged_c event does not contain information indicating whether it was triggered by an advertising start/stop call. The recommendation is that the application maintain its own state and further changes tracked. For reference on your development, I'd suggest referring to the SDK example at: wireless_examples/bluetooth/beacon, as it contains an implementation that tracks the advertising events through a software-defined flag. Please let me know if this helps.
View full article
ECU BUS PRO I am trying to implement a Bootloader.   I need to load data from a binary file into the MCU, and I understand that ECU BUS PRO performs this function. However, in the latest version (currently using ECU BUS PRO 0.8.15), there is no option to attach a binary file. It seems that this feature was available in older versions. Where can I find and download an older version? Are there any alternative solutions to achieve this? Re: ECU BUS PRO Hi,  I am currently working on bootloader for s32k342. The development is done in RTD version 6.0.  (The Same RTD version is used to build bootloader for s32k344, which is functional and flashing application via ECUBUS Pro was completed) I verified the CAN communication in bus master. For Request 0x02 10 03, I am getting response 0x02 50 03.  Now I am facing problem in Communicating through Ecubus Pro. The same request send on ECUBUS Pro gives me Bus error or Upper layer timeout.  I did the following debugging: Cross checked the CAN IDs and its format in user_config.h: CAN_RX:0x731, CAN_TX= 0x739 EcuBus pro interface: CAN_TX=0x731, CAN_RX = 0x739 Both the cases uses Standard CANId Baudrate:500kbps, CAN bit timing:   Monitored the g_RXCANMsg buffer on real time in S32DS, the request msg from the tester is stored in the buffer. Why No response is being send back to EcuBus Pro when I can receive the response in Bus master? Is there anything else to be taken care while flashing?   Thanks,  Akhila. Re: ECU BUS PRO try this: https://app.whyengineer.com/examples/nxp_bootloader/readme.html Re: ECU BUS PRO Hi @parksuhun, 1. You can go into EcuBus' release tab in github (Releases · ecubus/EcuBus-Pro) where you can find all of the preivous releases. 2. You can also refer to the AN12323: S32K1xx Firmware updates – Application Note, which explains the bootloader and firmware update basics, as well as including a demo where one board sends a FW update through CAN, and the second board is updated. Best regards, Julián
View full article
gAdvertisingStateChanged_c 是否指示哪个广告请求已完成? 你好, 我有一个关于 gAdvertisingStateChanged_c 事件的问题。 当调用 Gap_StartAdvertising() 或 Gap_StopAdvertising() 时,应用程序会等待 gAdvertisingStateChanged_c 事件,然后再继续执行下一个操作。 但是,是否有可靠的方法来确定接收到的 gAdvertisingStateChanged_c 事件对应于之前的 Gap_StartAdvertising() 请求还是之前的 Gap_StopAdvertising() 请求? 例如,如果广告状态更改请求在很短的时间内发出,应用程序能否将特定的 gAdvertisingStateChanged_c 事件与触发信号该事件的 API 调用关联起来? 或者,是否建议应用程序维护自己的状态信息以跟踪待处理的广告请求? 谢谢。 协议:蓝牙 Re: Does gAdvertisingStateChanged_c indicate which advertising request completed? 你好, 谢谢你的解释。 我现在明白了,gAdvertisingStateChanged_c 本身并不能指示它是由广告开始请求还是停止请求触发的。在查看信标示例后,可以看出该应用程序在内部跟踪预期状态(例如,通过使用 mAdvertisingOn 或 mAppTargetState 等变量),并根据其自身的状态机解释事件。 感谢您的支持。我将关闭此帖。 顺祝商祺! Re: Does gAdvertisingStateChanged_c indicate which advertising request completed? 你好@hyama ,希望你一切都好。 gAdvertisingStateChanged_c 事件不包含指示其是否由广告开始/停止调用触发的信息。建议应用程序维护自身的状态,并跟踪后续更改。 为了方便您的开发,我建议您参考以下 SDK 示例: wireless_examples/bluetooth/beacon ,因为它包含一个通过软件定义标志跟踪广播事件的实现。 请告诉我这是否有帮助。
View full article
ECU 总线 PRO 我正在尝试实现一个引导加载程序。   我需要将二进制文件中的数据加载到MCU中,我知道ECU BUS PRO可以执行此功能。 然而,在最新版本(目前使用的是 ECU 总线 PRO 0.8.15)中,没有附加二进制文件的选项。 看来这个功能在旧版本中就有了。哪里可以找到并下载旧版本? 是否有其他方法可以实现这一目标? Re: ECU BUS PRO 您好, 我目前正在研究s32k342的引导加载程序。该开发工作是在RTD 6.0版本下完成的。(使用相同的RTD版本构建了s32k344的引导加载程序,该程序功能正常,并且已通过ECUBUS Pro完成了应用程序的刷写。) 我已验证总线主控中的 CAN 通信。对于请求0x02 10 03,我得到了响应0x02 50 03。 现在我在使用 Ecubus Pro 进行通信时遇到了问题。在ECUBUS Pro上发送同样的请求,会收到总线错误或层超时错误。 我进行了以下调试: 交叉核对了 CAN ID 及其格式 user_config.h:CAN_RX:0x731,CAN_TX:0x739 EcuBus Pro接口:CAN_TX=0x731,CAN_RX=0x739 这两个案例都使用了标准 CANId。 波特率:500kbps CAN 位时序: 监测了 在 S32DS 中实时监测 g_RXCANMsg 缓冲区,测试仪的请求消息存储在缓冲区中。 为什么我在 总线 master 中可以收到响应,而 EcuBus Pro 却收不到响应? 刷机时还有其他需要注意的地方吗?   谢谢, 阿基拉。 Re: ECU BUS PRO 试试这个: https://app.whyengineer.com/examples/nxp_bootloader/readme.html Re: ECU BUS PRO 你好@parksuhun , 1.您可以进入 GitHub 上的 EcuBus 版本税务摊销收益(发布 · ecubus/EcuBus-Pro ),在那里您可以找到所有以前的版本。 2. 您还可以参考AN12323:S32K1xx 固件更新 - 应用笔记,其中解释了引导加载程序和固件更新的基础知识,并包含一个演示,其中一个板通过 CAN 发送固件更新,而第二个板则进行更新。 此致, 朱利安
View full article
Shared Hardware Configuration across different simulink models Hi,  I am working on a project where I have multiple simulink models that  use S32K3 library blocks for inputs and outputs of my microcontroller, I want my different models stored in independent .slx files to share the same Harware configuration (.mex file)  so that if I open one model, modify something in that configuration and save, I can later open a diferent model and I can see those changes applied to the configuration. My problem is that when using the option "referenced configuration" an independent .mex file is generated for each .slx file, also if I generate a configuration and set it as the reference for the different models it will create a local copy for each one of them but I modify any of the local configurations changes will not be applied to the template or other models. Is there a way that I can achieve what I am looking for?  Thanks in advance Re: Shared Hardware Configuration across different simulink models Hello, To use a reference configuration, you can follow these steps: 0. If you want to set up an existing model for reference configuration, I strongly recommend you to use source control, or to manually create a backup of the whole folder (which contains the model). It might be possible that important files to be deleted or corrupted during the process. Create a new Simulink Model. Save it. It this case, I named it 's32k3_ref_modelA.slx'. Model Model Settings and configure Hardware Board to NXP S32K3xx. In the Hardware tab, choose the right template depending on your board. Apply the settings. Go to Referenced Configuration tab and enable the checkbox. Select the location where you want to store the reference configuration. Click on Create Reference.  In the pop up dialog, choose Base Workspace then MAT-file. At the last pop-up, it is not mandatory to open the referenced configuration.  Now the model created previously uses the reference configuration you just created. These files ("s32k3_ref_modelA_config", "s32k3_ref_modelA_settings.mat" and "s32k3_refmodelAConfig.mex") can now be deleted as they are not used anymore.  To recreate the .mex, you can simply build the s32k3_ref_modelA.  After the build is completed, next to the model you should have the following files. The most important ones are the Configuration_RefS32K3_settings.mat (where the referenced configuration is saved) and the Configuration_RefS32K3Config.mex (where the configuration settings are stored). Create a new model. Save it as s32k3_ref_modelB. Inside the s32k3_ref_modelB, open the Model Explorer. Expand the s32k3_ref_modelB and click on Configuration. Click on Add configuration reference and select the previously created .mat file (Configuration_RefS32K3). Click Apply.  Activate the Refence configuration and delete the old one. This is how the Configuration tab for s32k3_ref_modelB should look at the end. Go back to s32k3_ref_modelB model and open Hardware Settings. Now it should state that a reference configuration is used.  To validate it, build the s32k3_ref_modelB and next to the model you should see only a .mex file Tip! In this scenario, if you want to replace the default .mex configuration file (Configuration_RefS32K3Config.mex) with your configuration project you need to do the following: IMPORTANT! Make sure you have a backup available in case something goes wrong. Delete Configuration_RefS32K3Config.mex Delete Configuration_RefS32K3_Config, s32k3_refModelA_ert_rtw and s32k3_refModelB_ert_rtw folders. Copy your .mex file next to the model. Renamed your .mex file to Configuration_RefS32K3Config.mex Do not forget to give a kudo and to mark this post as Solved if these steps helped you. Thanks! Best regards, Sorin Bancila Re: Shared Hardware Configuration across different simulink models I am using Matlab 2025b and the 1.8.0 version of the toolbox Re: Shared Hardware Configuration across different simulink models Hello, Can you please share what MATLAB and toolbox versions do you currently use? Best regards, Sorin Bancila
View full article