2024-01-05 12:33 PM - edited 2024-01-05 02:47 PM
HelIo,
I connected the anode from a diode to the operating voltage and the cathode to a pinx. I need ground to make the diode glow. How can this be implemented?
2024-01-05 01:05 PM - edited 2024-01-05 01:05 PM
Well you'd need a resistor to limit current through the LED, as if you simply gate it to ground you'll get whatever the transistor will permit.
PINX ----[ R ]----|/|-- VCC
LED|\|
Configure GPIO as PP or OD OUTPUT, LOW to illuminate
2024-01-05 01:38 PM
I already have a resistor in the hardware. Unfortunately, these settings don't work.
2024-01-05 02:56 PM - edited 2024-01-05 02:59 PM
Perhaps draw what you've built
2024-01-06 04:48 AM
I've also tried this CLEAR_BIT(GPIOF->ODR, GPIO_ODR_OD3);
CLEAR_BIT(GPIOF->ODR, GPIO_ODR_OD5); NMOS transistor to force the I/O pin to ground.
HAL_GPIO_WritePin(GPIOF, GPIO_PIN_3,GPIO_PIN_SET);
HAL_GPIO_WritePin(GPIOF, GPIO_PIN_5,GPIO_PIN_SET);
Unfortunately, to no avail. Something is still missing in the setting.
Below is the circuit:
2024-01-06 06:16 AM - edited 2024-01-06 06:20 AM
To drive the pin low, just define it as a output , then set this low.
( here pb12 , just to show )
HAL_GPIO_WritePin(GPIOF, GPIO_PIN_3, GPIO_PIN_RESET); // LED ON
2024-01-06 06:44 AM
Thank you very much for your reply.
I've tried everything, unfortunately doesn't work. I always measure a voltage at the cathode. I usually need ground on the pin.
2024-01-06 06:57 AM
So try : set in cubeMX (-> xx.ioc) GPIO pin as output and at low level.
-> generate code , -> compile , -> debug --- and led is on. If not : your on the wrong pin (number or name).
( here pb12 , just to show )
2024-01-06 08:10 AM - edited 2024-01-06 08:13 AM
I did exactly the same. I'm using pin 14 and pin 16. On stm32 are the PF3 and PF5. I'm still measuring 1.9V voltage at the cathode.
2024-01-06 08:29 AM
But you wrote: HAL_GPIO_WritePin(GPIOF, GPIO_PIN_5,GPIO_PIN_SET);
this sets pin high.
Test: write NO progam, nothing, let only Cube make the init.
Just generate code, compile, debug -> pins are low.
Can you debug ? Then check gpio setting in SFRs view.