cancel
Showing results for 
Search instead for 
Did you mean: 

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

dbrue.1
Associate II

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)

1 ACCEPTED SOLUTION

Accepted Solutions

> 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

View solution in original post

4 REPLIES 4

> 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

I have done so, and the input is Lo

dbrue.1
Associate II

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

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