Page 1 of 1

GPIO36,39 as digital input not working

Posted: Fri Mar 27, 2020 5:19 pm
by xenpac
Hi guys,-)

I have a CSI camera attached and IO36, IO39 is used as input for D0,D1.

I cant get readings of the input.

All others are working (2 15 13 12 14 33 34 35 32)


Do i need to disable ADC or Hall sensor or ?

any clues welcome:-)

here my io init and reading:
  1.     int i;
  2.     gpio_config_t conf;
  3.  
  4.     conf.pin_bit_mask=0;
  5.     for (i=0;i<sizeof(pintab)/sizeof(gpio_num_t);i++)
  6. //  gpio_set_direction(pintab[i], GPIO_MODE_INPUT); // doesnt work as expected!
  7.         conf.pin_bit_mask |= 1ULL<<pintab[i]; // set the pin bits for gpio_config to apply below settings.
  8.    
  9.     conf.intr_type = GPIO_INTR_DISABLE;
  10.     conf.mode = GPIO_MODE_INPUT;
  11.     conf.pull_down_en = GPIO_PULLDOWN_DISABLE;
  12.     conf.pull_up_en = GPIO_PULLUP_DISABLE;
  13.     gpio_config(&conf); // we need to do it with gpio_config, otherwise some pins dont work as expected!!!
  14.  
  15. .....
  16. reading:
  17.         if (pin < 32)
  18.         {
  19.         state = (GPIO_REG_READ(GPIO_IN_REG)  >> pin) & 1U;
  20.         }
  21.         else
  22.         {
  23.             pin -= 31;
  24.         state = (GPIO_REG_READ(GPIO_IN1_REG)  >> pin) & 1U;
  25.         }
  26.  

Thanks

Re: GPIO36,39 as digital input not working

Posted: Fri Mar 27, 2020 5:26 pm
by xenpac
ooouuups.......

i found it.

reading inputs correct version:

if (pin < 32)
{
state = (GPIO_REG_READ(GPIO_IN_REG) >> pin) & 1U;
}
else
{
pin -= 32;
state = (GPIO_REG_READ(GPIO_IN1_REG) >> pin) & 1U;
}