2014-05-09 08:21 AM
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 ? thanks2014-05-09 09:01 AM
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?2014-05-12 01:47 AM
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? no2014-05-12 02:33 AM
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.