Skip to main content
dbrue.1
Associate
June 28, 2022
Solved

STM32F303 - is it possible to read the state of PB14 when in MISO SPI mode?

  • June 28, 2022
  • 4 replies
  • 1227 views

I have an ADC chip, CS5532, that sets the MISO line on PB14 Hi if data not available, and Lo if it is. Can I read the state of the MISO line?

Every time I try to do it I read that the pin is Hi (I am reading the IDR register)

This topic has been closed for replies.
Best answer by waclawek.jan

> Can I read the state of the MISO line?

Yes.

> Every time I try to do it I read that the pin is Hi (I am reading the IDR register)

Well then that line is then probably always high.

Observe it using oscilloscope/logic analyzer.

JW

4 replies

waclawek.jan
waclawek.janBest answer
Super User
June 28, 2022

> Can I read the state of the MISO line?

Yes.

> Every time I try to do it I read that the pin is Hi (I am reading the IDR register)

Well then that line is then probably always high.

Observe it using oscilloscope/logic analyzer.

JW

dbrue.1
dbrue.1Author
Associate
June 28, 2022

I have done so, and the input is Lo

dbrue.1
dbrue.1Author
Associate
June 28, 2022

When I read the data register and do a bitmask I get the correct answer. For some reason I have a problem with GPIO_ReadInputDataBit(GPIOB, 14) when I cast the result to bool.

Anyway, problem solved

waclawek.jan
Super User
June 28, 2022

What is GPIO_ReadInputDataBit(), SPL?

If yes, the second parameter is not supposed to be a number of 0..15, but one of the GPIO_Pin_x symbols, see description of GPIO_ReadInputDataBit() function. GPIO_Pin_x are defined in STM32F0xx_StdPeriph_Driver\inc\stm32f0xx_gpio.h as

#define GPIO_Pin_0                ((uint16_t)0x0001) /*!< Pin 0 selected   */

#define GPIO_Pin_1                ((uint16_t)0x0002) /*!< Pin 1 selected   */

#define GPIO_Pin_2                ((uint16_t)0x0004) /*!< Pin 2 selected   */

#define GPIO_Pin_3                ((uint16_t)0x0008) /*!< Pin 3 selected   */

#define GPIO_Pin_4                ((uint16_t)0x0010) /*!< Pin 4 selected   */

etc.

JW