0

I am trying to program a Microchip MCP4141 digital potentiometer with the STM32CUBEIDE development environment using a NUCLEO F334R8 board. I am sending a 16 bit command through the SPI communications port. When I send the command byte with the data byte, I cannot notice voltage variations between the P0A and P0W terminals of the MCP4141. 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);

1 Answers1

0

Usually when an SPI peripheral does not work, the commands are not received by the slave chip. This can have multiple reasons:

  • Incorrect wiring (MOSI, MISO, CLK lines)
  • Incorrect SPI mode (clock phase, clock polarity) --> check SPI settings in CubeMX
  • Slave chip is in Reset because of incorrect/floating EN or RST Pin

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 e.g. the status register?

mnemocron
  • 23
  • 1
  • 4