Skip to main content
MD SABBIR BIN ZAMAN
Associate II
January 18, 2017
Solved

Idea needed for 9 bit spi transfer using HAL Library

  • January 18, 2017
  • 2 replies
  • 2424 views

Posted on January 18, 2017 at 03:55

I am using stm32cubeMx to generate initialization C code for programming STM32L476RGTx MCU using Keil IDE. Recently, I need to interface an AD5262 digital potentiometer to control the gain of an amplifier automatically. The AD5262 requires 9 bit spi data to be configured perfectly (1 bit for resistor selection, 8 bit for wiper position selection). I have tried HAL_SPI_Transmit_IT(&hspi,&data,1) // data is 8 bit. //

to transmit twice (so I did some bit manipulation so it becomes A0 D7 D6 D5 D4 D3 D2 D1 D0 0 0 0 0 0 0 0, please check AD5262.jpg). I considered last 7 zeros' to be ignored by AD5262. Seems like my process is not working. There one other way I can think of which is 1st bit (A0) to be transferred manually programming the spi by using the gpio pins (CS, SCLK and SDA) and transmitting the rest 8 bit using the function I mentioned. But I will do it if I can not find any other convenient way to transmit 9 bit directly using HAL. Can you people help with other ideas? since I noticed there data size of 8, 9, 10, 12, ....... 16 bits while configuring MCU's spi using STM32CubeMx(other two png files). 

Thanks in advance.

This topic has been closed for replies.
Best answer by MD SABBIR BIN ZAMAN
Posted on February 11, 2017 at 09:12

Solved the problem. I transfered (uint8_t)1 using 8 bit spi transmission and then I transfered (uint8_t)wiperposition

2 replies

MD SABBIR BIN ZAMAN
Associate II
February 11, 2017
Posted on February 11, 2017 at 09:12

Solved the problem. I transfered (uint8_t)1 using 8 bit spi transmission and then I transfered (uint8_t)wiperposition

TSaad
Visitor II
August 9, 2018

can please say how you solved the problem