cancel
Showing results for 
Search instead for 
Did you mean: 

Idea needed for 9 bit spi transfer using HAL Library

MD SABBIR BIN ZAMAN
Associate II

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.

1 ACCEPTED SOLUTION

Accepted Solutions
MD SABBIR BIN ZAMAN
Associate II
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

View solution in original post

2 REPLIES 2
MD SABBIR BIN ZAMAN
Associate II
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
Associate

can please say how you solved the problem