DFRO316 MCP3424和STM32

发布于 2025-02-11 11:47:53 字数 481 浏览 2 评论 0原文

我试图知道MCP3424的状态,要么连接到具有定义地址0x68的主STM32。 ADC模块与Arduino连接在同一地址中,但是使用STM32,我无法与以下代码连接:

while(1) { / *用户代码结束时 */

/* USER CODE BEGIN 3 */
    if((HAL_I2C_IsDeviceReady(&hi2c1, 0x68 << 1, 100, 1000))==HAL_OK){
            HAL_UART_Transmit(&huart2, "device connected\r\n", 10, 10);
         }
    else{
      HAL_UART_Transmit(&huart2, "no device\r\n", 100, 10);
    }

}

我在此代码中是否有任何错误或任何其他方式专门处理MCP3424 ADC模块?请建议我。

I am trying to know the status of MCP3424, either it is connected or not to the master STM32 with defined address 0x68. The ADC module gets connected with the Arduino in same address but using STM32, I am not able to get connected with the following code:

while (1)
{
/* USER CODE END WHILE */

/* USER CODE BEGIN 3 */
    if((HAL_I2C_IsDeviceReady(&hi2c1, 0x68 << 1, 100, 1000))==HAL_OK){
            HAL_UART_Transmit(&huart2, "device connected\r\n", 10, 10);
         }
    else{
      HAL_UART_Transmit(&huart2, "no device\r\n", 100, 10);
    }

}

Is there any mistake that I have done in this code by chance or any other way there is to deal with MCP3424 ADC module specifically? Please suggest me.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

﹎☆浅夏丿初晴 2025-02-18 11:47:53

我相信您的问题在于电压水平:您的STM32功能为3.3V,而MCP3424的功能为5V。让我们打开MCP3424的数据表,第6页:

”在此处输入图像描述

高级输入电压为0.7VDD,为0.7V*5V = 3.5V,这意味着您的A/D无法检测到“ 1”在线。即使STM32 MCU输出高(3.3V),它也会像往常一样看到线路。

可能的解决方案:

  1. 逻辑级别转换(各种方式)。 A/D IC和MCU之间的电路将3.3V水平转换为5V水平。有一些专用的芯片,还有其他使用电阻和MOSFET的方法。您可能想在电气工程stackexchange上探索的东西。
  2. 检查MCU的数据表,查找GPIO属性。实际上,这些I2C引脚很可能是5V耐耐剂,这意味着您可以将I2C线拉到5V,并且仍然使用3.3V STM32驱动它们,并且它将在STM32 MCU的规格之内。如果是这样,则无需额外的电路。

I believe your problem lies with voltage levels: your STM32 functions with 3.3V, while MCP3424 is powered from 5V. Let's open the datasheet of the MCP3424, page 6:

enter image description here

High level input voltage is 0.7Vdd, which is 0.7V*5V=3.5V, which means your A/D can't detect "1" on the line. It sees the line as always "0", even when STM32 MCU outputs HIGH (3.3V).

Possible solutions:

  1. Logic level conversion (various ways). A circuit between A/D IC and MCU to convert 3.3V levels into 5V levels. There are dedicated chips for that, there are also other approaches using resistors and mosfets. Something you may want to explore on electrical engineering stackexchange.
  2. Check the datasheet of the MCU, find GPIO properties. It's very likely those I2C pins are in fact 5V-tolerant, meaning you can pull up I2C lines to 5V and still drive them with 3.3V STM32, and it will be within the spec of STM32 MCU. If that's the case, no extra circuit will be necessary.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文