cancel
Showing results for 
Search instead for 
Did you mean: 

How to control an external digital potentiometer with the STM32F3DISCOVERY via SPI

dan_v
Associate II

Posted on July 24, 2017 at 10:32

Hi guys,

I need to control an external digital potentiometer (setting the variable resistance wiper position) with a STM32F3DISCOVERY MCU, via SPI interface.

The digital potentiometer is an AD5293.

I just need to change the variable resistor wiper position. I don't need to read values from the external digital potentiometer, I just have to set the wiper position to a desired one and nothing more.

After setting up the SPI interface (using the MCU as the master), I need to fisically link the STM32F3 to the AD5293 to send the data input.

My question is:

which pin (or pins) of the STM32F3 should I use to insert the wire to connect the two devices? 

Thank you in advance for your answers!

5 REPLIES 5
S.Ma
Principal
Posted on July 24, 2017 at 12:19

No worries, it's much easier than the RS232 RX/TX Murphy's law: Just connect MOSI, SCK and NSS together.

You can use any GPIO for NSS. MOSI = Master Output, Slave Input data

dan_v
Associate II
Posted on July 24, 2017 at 13:44

Thank you very much.

So, suppose I want to use SPI1 to communicate. I only have to trasfer, so I just need MOSI, SCK and NSS pins.

I would use PA5 as SCK, PA7 as MOSI and PA4 as NSS (channel select), selecting their alternate function modes.

So, I would have to wire PA5 to SCLK pin of the external digital potentiometer, PA7 to MOSI pin of the external digital potentiometer and PA5 to NSS pin of the external digital potentiometer.

Is it correct?

Posted on July 24, 2017 at 14:47

Yes, correct.

For NSS, it will be used without alternate function, it will be toggled by SW.

If layter you need to read back from the device (for example to detect if slave is present), then MISO will be needed.

dan_v
Associate II
Posted on July 24, 2017 at 14:53

Thanks! You are very useful.

Another little question: 

the external digital potentiometer must be powered; can I use the pins labelled as '5V' and '3V' onto the STM32F3 to supply power towards the external device?
Posted on July 24, 2017 at 15:02

Yes, you can.

But be aware that you can't just run your dig. potentiometer on +5V.  Else you will get trouble with logic levels, and probably internal protective diodes on the GPIO pins.