cancel
Showing results for 
Search instead for 
Did you mean: 

SPI not working with MISO connected to 3V and 0V

JAlle.2
Associate II

I am trying to code SPI functionality to connect with an external 16-bit ADC. The STM32 only receives data from the ADC, so only a MISO and SCLK line, along with a Conversion/CS line is required. I am currently using the 32F072BDISCOVERY board to test my code. Unfortunately, I do not have access to the ADC yet, so to perform simple testing to see if my SPI code is working, I figured I could set the MISO line to ground to receive all 0s or to 3V to receive all 1s. However, no matter what I connect the MISO line to, I only receive 1s.

To make things simple, I set the SPI peripheral data size on the STM32 to 8 bits.

Here is my code. Super simple so I don't know what could be going wrong here.

uint8_t spi_value[1];

HAL_SPI_Receive(&hspi1, spi_value,1,1000);

I am reading out the value over UART and checking it in the live variables section in the debugger. It always is 255, which is the equivalent of all 1s.

11 REPLIES 11

While you are supposed to read the entire boring manual, these are all very valid points to the quality of the given manual.

@Imen DAHMEN​ , can comebody please sweep through that manual and insert full pin names (e.g. "PA2, PA3, PA6, PA7"| instead of "PA2, 3, 6, 7") so they are searchable; and also insert remarks/footnotes to the pinout table, as JAlle.2 suggested above?

And, of course, all Disco manuals would deserve a respin (and removal of the "modern feel and look" where it was used ;-), and insertion of the schematics EVEN IF IT IS MORE WORK TO ST). The DiscoF4 manual is perhaps a good example how manual can be improved in time, especially the pinout table is excellent there. I know how ST frowns upon this kind of work, which in the view of management is unproductive. Yet it's the Disco boards which brought STM32 to the position they are now.

Thanks,

Jan

TDK
Guru

Valid points. Although, it does show up in a search for "PA6", which if you look at what the columns/notes mean, will get you the same information. That's how I found it.

0693W000006HIgmQAG.png

If you feel a post has answered your question, please click "Accept as Solution".