2017-11-16 02:32 AM
Hi !
I'm working on a STM32L031 project, and I need to read 10 digital 0V-3v3 Inputs.
Everything works fine if i'm reading 5 inputs (PA3, PA4, PA5, PA6, PA7). It is also working if I'm reading 5 other inputs (PB3, PB4, PB5, PB6, PB7).
But as soon as I plug both PA3, PA4, PA5, PA6, PA7 and PB3, PB4, PB5, PB6, PB7, it stops working.
I checked using a voltmetre in the 10 inputs config, and 4 inputs don't rise to 3v3, but only 1V.
So It only reads 3 inputs of (PA3, PA4, PA5, PA6, PA7) and 3 inputs of (PB3, PB4, PB5, PB6, PB7).
Would it be a problem of current sinking ? or just a wrong software configuration ?
I tried configuring inputs with and without pull down.
I checked GND is common to every inputs.
Any ideas ?
thanks for your time.
Hugo
#current-sink #digital-input #stm32l0 #3v3Solved! Go to Solution.
2017-11-16 04:00 AM
If you are using EXTI, you can only choose one pin per source: PB3 xor PA3, PB4 xor PA4.
If you want 10 pins, you shall use Px0 to Px9, some group of pins will share the same interrupt vector.
2017-11-16 02:39 AM
Instead of guessing, it would be better if you presented at least the init code for those ports.
I guess you missed something, perhaps enabling port B.
2017-11-16 02:45 AM
Ok AvaTar, thanks for your quick response.
Here is my init code :
static void MX_GPIO_Init(void) { GPIO_InitTypeDef GPIO_InitStruct; /* GPIO Ports Clock Enable */ __HAL_RCC_GPIOC_CLK_ENABLE(); __HAL_RCC_GPIOA_CLK_ENABLE(); __HAL_RCC_GPIOB_CLK_ENABLE(); /*Configure GPIO pins : Sensor_1A_Pin Sensor_2A_Pin Sensor_3A_Pin Sensor_4A_Pin Sensor_5A_Pin */ GPIO_InitStruct.Pin = Sensor_1A_Pin|Sensor_2A_Pin|Sensor_3A_Pin|Sensor_4A_Pin |Sensor_5A_Pin; GPIO_InitStruct.Mode = GPIO_MODE_INPUT; GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); /*Configure GPIO pins : Sensor_5B_Pin Sensor_4B_Pin Sensor_3B_Pin Sensor_2B_Pin Sensor_1B_Pin */ GPIO_InitStruct.Pin = Sensor_5B_Pin|Sensor_4B_Pin|Sensor_3B_Pin|Sensor_2B_Pin |Sensor_1B_Pin; GPIO_InitStruct.Mode = GPIO_MODE_INPUT; GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); }
I may have forget to precise something.
When I plug all of the 10 inputs, it don't work, but as soon as I unplug 5 of the 10 inputs, is works fine.
2017-11-16 02:54 AM
Where these pins are connected to? If they are floating, the voltage will be random (it's like GPIOs are 'antennas').
To prevent this, you can activate a weak pull-up on each pin so that when left unconnected, you will read a 1.
More fun: If you pull-up then pull-down (with few usec delay), you can guess the pin is left unconnected...
2017-11-16 03:57 AM
These pins are connected to a pulled-down signal.
The signal is rising to 3V3 when I get an event.
I already tried to enable pull-down during initialization, but it is the same problem. :\
Thanks for your help !
2017-11-16 04:00 AM
If you are using EXTI, you can only choose one pin per source: PB3 xor PA3, PB4 xor PA4.
If you want 10 pins, you shall use Px0 to Px9, some group of pins will share the same interrupt vector.
2017-11-16 04:03 AM
Thanks
KIC8462852 EPIC204278916
for your answer.I'm not using EXTI, or interruptions for the moment, but I'll try to use the same GPIO PORT.
Thanks !
2017-11-16 04:33 AM
Thanks for your advise KIC8462852 EPIC204278916
After using one single GPIO PORT, it is now working fine.
I can't explain why because I wasn't using interrupts, but using only PORTA works fine !
Thanks !
2017-11-16 04:44 AM
After using one single GPIO PORT, it is now working fine.
I can't explain why because I wasn't using interrupts, but using only PORTA works fine !
Most probably because your initialization of port B was not correct.
2017-11-16 04:50 AM