STM32F: Blinking red Neo when EN and USB in use

Please tell us which board you are using.
For CircuitPython issues, ask in the Adafruit CircuitPython forum.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
hockeygoalie35
 
Posts: 6
Joined: Mon Jul 25, 2022 12:55 pm

STM32F: Blinking red Neo when EN and USB in use

Post by hockeygoalie35 »

Hi! I'm a Mech-E, so forgive maybe the noob-ish question. I have a little board that connects to my STM32F Express feather, which connects USB to A1 (for USB voltage monitoring), and a switch between EN and GND. when I flip the switch to connect the two (hoping to turn off the feather), the Neopixel blinks red and doesn't actually shut off. Am I shorting something? Once I remove the USB -> A1 connection, it works fine.

User avatar
dastels
 
Posts: 15608
Joined: Tue Oct 20, 2015 3:22 pm

Re: STM32F: Blinking red Neo when EN and USB in use

Post by dastels »

What connection on USB? AI'm assuming the 5v line. Is it connected directly to A1?

Dave

User avatar
hockeygoalie35
 
Posts: 6
Joined: Mon Jul 25, 2022 12:55 pm

Re: STM32F: Blinking red Neo when EN and USB in use

Post by hockeygoalie35 »

dastels wrote: Sat Sep 17, 2022 12:26 pm What connection on USB? AI'm assuming the 5v line. Is it connected directly to A1?

Dave
Hi Dave. Yes, 5V on the USB, and USB pin is direct connected to A1. Any easy way to try it out: plug the feather into a 5V USB C source, put a jumper from pins A1 to USB, and EN to GND. Either right away or after hitting reset, the neopixel begins to blink red until you disconnect one of the jumpers.

User avatar
dastels
 
Posts: 15608
Joined: Tue Oct 20, 2015 3:22 pm

Re: STM32F: Blinking red Neo when EN and USB in use

Post by dastels »

You shouldn't connect 5v to A1. From the tutorial guide:
A1 / GPIO 17 / PA5
This pin is analog input A1 (ADC12 IN5)
... You can set the raw voltage to anything from 0 to 3.3V ...
You need to use a voltage divider to halve the 5v input then double the voltage that you read.

Dave

User avatar
alpierce
 
Posts: 206
Joined: Mon May 13, 2013 2:44 am

Re: STM32F: Blinking red Neo when EN and USB in use

Post by alpierce »

If you don’t need to know the exact voltage of the USB, but only need to know if it is present or not you can also use the voltage divider dastels mentioned and read A1 (or any other analog or digital pin) as a digital input. It will be True if there is USB voltage present and False if there is not. Simplifies your code somewhat.

User avatar
dastels
 
Posts: 15608
Joined: Tue Oct 20, 2015 3:22 pm

Re: STM32F: Blinking red Neo when EN and USB in use

Post by dastels »

alpierce wrote: Sat Sep 17, 2022 1:01 pm If you don’t need to know the exact voltage of the USB, but only need to know if it is present or not ...
Good point. It all depends on what you need.

Dave

User avatar
hockeygoalie35
 
Posts: 6
Joined: Mon Jul 25, 2022 12:55 pm

Re: STM32F: Blinking red Neo when EN and USB in use

Post by hockeygoalie35 »

alpierce wrote: Sat Sep 17, 2022 1:01 pm If you don’t need to know the exact voltage of the USB, but only need to know if it is present or not you can also use the voltage divider dastels mentioned and read A1 (or any other analog or digital pin) as a digital input. It will be True if there is USB voltage present and False if there is not. Simplifies your code somewhat.
I haven't decided yet if I'm going to show the user battery percentage yet, but if I don't, that's a good option, thanks. 2 questions:
  • Any ideas on the "why" this happens?
  • Also, do I need to worry about current in the voltage divider, or not really since I'm just measuring voltage?

User avatar
alpierce
 
Posts: 206
Joined: Mon May 13, 2013 2:44 am

Re: STM32F: Blinking red Neo when EN and USB in use

Post by alpierce »

Putting 5v on an input pin can cause unreliable functionality and/or destroy the input, depending on the input circuitry of the chip.

I typically use high value resistors (100k) for voltage dividers to keep the current use low, especially for battery powered designs. Check out the Measuring Battery section of the Power Management topic in the Primary Guide: Adafruit STM 32F405 Feather Express towards the bottom of the product page.

User avatar
hockeygoalie35
 
Posts: 6
Joined: Mon Jul 25, 2022 12:55 pm

Re: STM32F: Blinking red Neo when EN and USB in use

Post by hockeygoalie35 »

alpierce wrote: Sat Sep 17, 2022 2:46 pm Putting 5v on an input pin can cause unreliable functionality and/or destroy the input, depending on the input circuitry of the chip.

I typically use high value resistors (100k) for voltage dividers to keep the current use low, especially for battery powered designs. Check out the Measuring Battery section of the Power Management topic in the Primary Guide: Adafruit STM 32F405 Feather Express towards the bottom of the product page.
Ooh, that's super helpful, turns out they had the functionality all along on A6. Great find, thanks! Guess I didn't RTFM enough. I can then infer if the value on A6 is 0, then it must be on USB.


EDIT: I can copy the voltage divider from the schematic and make A1 a digital input to test if the USB pin is active. If it isn't, then use A6 to get the battery voltage.
Image

Locked
Please be positive and constructive with your questions and comments.

Return to “Feather - Adafruit's lightweight platform”