0
\$\begingroup\$

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)

\$\endgroup\$
3
  • 1
    \$\begingroup\$ If in doubt, maybe jumper MISO to another parallel input DIO pin, and monitor that? \$\endgroup\$ Jun 27, 2022 at 15:26
  • \$\begingroup\$ @ChrisKnudsen I will probably have to. However, I have read that it is possible but no code was supplied \$\endgroup\$ Jun 27, 2022 at 15:31
  • \$\begingroup\$ It has been years but I recall I was also communicating with a SPI chip that also signaled busy/ready via MISO pin, so the MCU had to poll it, and I recall simply reading the pin as GPIO as usual, without changing the IO pin mode between AF and GPIO. \$\endgroup\$
    – Justme
    Jun 27, 2022 at 16:49

2 Answers 2

3
\$\begingroup\$

Yes it is possible. And I've done it on another STM32 model, with a chip that uses SPI bus and indicates a busy/ready flag on MISO to indicate when MCU can read register data it just requested.

The reference manual section 11.3.11 says that when the IO port (which means the pin) is programmed as an alternate function (here the SPI MISO input), the data is sampled to input data register every AHB clock and can be read by MCU by reading the input data register.

See figure 44 for block diagram that indicates the same.

\$\endgroup\$
3
  • 1
    \$\begingroup\$ Section 11 - Interrupts and events? Which manual? I am looking at the one for the STM32F303xx \$\endgroup\$ Jun 28, 2022 at 8:22
  • \$\begingroup\$ RM0316 Referece manual, STM32F303xx, Rev 8.0, 19 January 2017. Opened directly from STM32F303 web page. Which manual you are looking at? \$\endgroup\$
    – Justme
    Jun 28, 2022 at 8:45
  • \$\begingroup\$ OK. I was using the 2013 version \$\endgroup\$ Jun 28, 2022 at 9:42
0
\$\begingroup\$

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) It seems that the pin number, 14, should not be entered that way and I should use

#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. This is totally unclear in the gpio.c library source and it actually reads

This parameter can be GPIO_Pin_x where x can be : (0..15) for GPIOA, GPIOB, GPIOC, GPIOD or GPIOE;

\$\endgroup\$
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.