简体   繁体   English

通过 SPI 端口在 STM32CUBEIDE 中对 MCP4141 数字电位器进行编程

[英]Programming the MCP4141 digital potentiometer in STM32CUBEIDE by SPI port

I am trying to program a Microchip MCP4141 digital potentiometer with the STM32CUBEIDE development environment using a NUCLEO F334R8 board.我正在尝试使用 NUCLEO F334R8 板在 STM32CUBEIDE 开发环境中对 Microchip MCP4141 数字电位器进行编程。 I am sending a 16 bit command through the SPI communications port.我正在通过 SPI 通信端口发送 16 位命令。 When I send the command byte with the data byte, I cannot notice voltage variations between the P0A and P0W terminals of the MCP4141.当我发送带有数据字节的命令字节时,我无法注意到 MCP4141 的 P0A 和 P0W 端子之间的电压变化。 Could you help me find the programming error?你能帮我找出编程错误吗? Thanks谢谢

uint8_t data[2];
data[0]=0x00;
data[1]=0x0F;

HAL_GPIO_WritePin(GPIOA, GPIO_PIN_4,GPIO_PIN_RESET);
HAL_SPI_Transmit(&hspi1, data, 2, 500);
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_4,GPIO_PIN_SET);

Usually when an SPI peripheral does not work, the commands are not received by the slave chip.通常当 SPI 外设不工作时,从芯片接收不到命令。 This can have multiple reasons:这可能有多种原因:

  • Incorrect wiring (MOSI, MISO, CLK lines)接线错误(MOSI、MISO、CLK 线)
  • Incorrect SPI mode (clock phase, clock polarity) --> check SPI settings in CubeMX不正确的 SPI 模式(时钟相位、时钟极性) --> 检查 CubeMX 中的 SPI 设置
  • Slave chip is in Reset because of incorrect/floating EN or RST Pin由于 EN 或 RST 引脚不正确/浮动,从芯片处于复位状态

Can you probe the data and clock lines?你能探测数据和时钟线吗? Do you see a signal being transmitted?您是否看到正在传输的信号? Alternatively, can you successfully read anything from the chips internal memory eg the status register?或者,您能否成功地从芯片内部 memory 中读取任何内容,例如状态寄存器?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM