2022-06-28 01:51 AM
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)
Solved! Go to Solution.
2022-06-28 02:50 AM
> 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
2022-06-28 02:50 AM
> 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
2022-06-28 02:51 AM
I have done so, and the input is Lo
2022-06-28 05:09 AM
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
2022-06-28 05:31 AM
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