Skip to main content
hilwan
Associate III
May 9, 2014
Question

Reading from GPIO PD

  • May 9, 2014
  • 3 replies
  • 752 views
Posted on May 09, 2014 at 17:21

Hi all,

I'm using Discovery F3. I have a problem to read my input GPIO PD.

The configuration is as indicated below:

/* GPIOD Periph clock enable */

  RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOD, ENABLE);

 /* Configure PD4, PD10 input mode */

    GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4 | GPIO_Pin_10;

  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;

  GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_DOWN;

  GPIO_Init(GPIOD, &GPIO_InitStructure);

The PD10 is controlled by an external command that switch between 0 and 1(3v), 

In main i add this code:

while(Ctrl_Status==0x00)  // Waiting for the Ctrl_Status to be 0x01

   {            

                    cpt=(GPIOD->IDR & GPIO_Pin_10);

                    if(cpt)

                    {

                         STM_EVAL_LEDToggle(LED3);

                         //Ctrl_Status=0x01;  

                  }

  }

The problem is that the Led is always blanking even before applying my 3v, that means that the PD0 is always high.

any opinions ?

thanks
    This topic has been closed for replies.

    3 replies

    Tesla DeLorean
    Guru
    May 9, 2014
    Posted on May 09, 2014 at 18:01

    The problem with providing context free blobs of code is that it's very difficult to see what you're actually doing, or failing to do, that is at the root of most problems.

    Do you initialize the LED's properly? Can you toggle outside the code provided? Are there other things precluding the code from actually looking at PD.10?
    Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
    hilwan
    hilwanAuthor
    Associate III
    May 12, 2014
    Posted on May 12, 2014 at 10:47

    Hi clive1;

    Yes, i know that it isn't easy to imagine what I'm doing.

    I posted this part of code because i though that my problem would be a story of Pull-up Pull-down. I tried all the combinations with no success.

     Do you initialize the LED's properly? yes i do

    Can you toggle outside the code provided? yes

    Are there other things precluding the code from actually looking at PD.10? no

    hilwan
    hilwanAuthor
    Associate III
    May 12, 2014
    Posted on May 12, 2014 at 11:33

    In fact, with the configuration i give above, the (GPIOD->IDR & GPIO_Pin_10) is always true even if in the IDR register IDR10 is unchecked.