AnsweredAssumed Answered

Inputs GPIO

Question asked by medina.edgar on May 9, 2014
Latest reply on May 10, 2014 by Clive One
Hello everybody.
I want to solve a read problem in a special hardware, the configuration of each pin is input:

RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA | RCC_AHB1Periph_GPIOB | RCC_AHB1Periph_GPIOC | RCC_AHB1Periph_GPIOD | RCC_AHB1Periph_GPIOE, ENABLE);

GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8 | GPIO_Pin_9;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
GPIO_Init(GPIOC, &GPIO_InitStructure);

GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7 | GPIO_Pin_6 | GPIO_Pin_10;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIO_Init(GPIOC, &GPIO_InitStructure);

there many pins work...

my problem is in the next code (this is a function in my library):

unsigned int ReadData(void)
{
   unsigned char nop=eco;//eco=5, is a delay.
   unsigned int data = 0;
   unsigned char count=0;

   for(count=0; count<12; count++)
   {
      data <<= 1;
      GPIO_SetBits(GPIOC, GPIO_Pin_10);               
      while(nop!=0){nop--;}
       nop=eco;
      GPIO_ResetBits(GPIOC, GPIO_Pin_10);
      while(nop!=0){nop--;}
      nop=eco;
      if (GPIO_ReadInputDataBit(GPIOC, GPIO_Pin_8));
     {data++;}
   }
   return(data);
}

when I read the value in data, only I read 0xFFF (12 bits)  in all cases, but I see signals for example 0x34F or 0x584 many combinations and I saw a good synchronization with the clock
using a analyzer logic. maybe is the configuration of the inputs but I 'm not sure.

thank you in advance.

Outcomes