2024-08-19 05:03 AM - edited 2024-08-19 05:04 AM
Hello everyone!
I have a very important question about a PCB design that I'm making.
I basically have a PCB with a bunch of sensors, a 4Gb eMMC memory and a USB-C connector. Here's the related schematics :
- Power section :
- Microcontroller (I'm sorry for this layout, I'll make it more readable in the near future) :
- eMMC memory and USB-C connector :
If you see some issues on the schematics please do not hesitate to let me know.
The desired behavior is :
1) The USB is not connected and the module is powered up -> Data gathering from sensors and logging into the eMMC memory.
2) The USB is connected and powers up the module (with the VBUS pin that goes from the USB to the input of the DC/DC converter) -> Data Retrieval mode -> The sensors are not gathering data neither logging into the eMMC memory, but the module can be accessed with a PC as a USB stick so i can pick up the log data easily.
My question is : Are the electronics schematics showed above good for what i'm doing? How can i switch between this 2 modes by detecting a connection via USB?
I found this function on the USBD driver that can maybe do the job:
Do you know if there's a basic implementation of this function for what I'm trying to do ?
I hope my post is clear enough, thank you in advance for your help!
Solved! Go to Solution.
2024-08-19 06:09 AM
> Are the electronics schematics showed above good for what i'm doing?
> How can i switch between this 2 modes by detecting a connection via USB?
This is typically done by sensing the VBUS voltage. When it's present, the USB connection is present. You can put a resistor divider from this voltage to an ADC pin to measure the actual voltage, or you can read it with a digital pin for an on/off indication.
2024-08-19 06:09 AM
> Are the electronics schematics showed above good for what i'm doing?
> How can i switch between this 2 modes by detecting a connection via USB?
This is typically done by sensing the VBUS voltage. When it's present, the USB connection is present. You can put a resistor divider from this voltage to an ADC pin to measure the actual voltage, or you can read it with a digital pin for an on/off indication.
2024-08-19 06:20 AM
Additionally:
2024-08-19 06:25 AM
Thank you for the fast response!! For the electronics I'm looking at the microcontroller datasheet, especially this page here :
And that's why I used a 100nF capacitor for VCAPs :
The NRST pin already have a decoupling capacitor here (didn't show that before sorry) :
For BOOT0, it's already pulled to ground isn't it?
So, based on what you've said, if I activate the VBUS on CubeIDE as follows :
And on my schematics, connect the VBUS of the USB :
To the new available VBUS pin of the STM32H7 :
I should be able to know whenever a USB connection with my PC is made right ?
2024-08-19 06:28 AM - edited 2024-08-19 06:30 AM
Dang, I just saw that.. Thank you for pointing the issue, I just tried to follow the datasheet :
But it seems very confusing. Do you know how can I solve it ?
2024-08-19 06:53 AM
> And that's why I used a 100nF capacitor for VCAPs :
Is LDO disabled for your layout? This means you need to supply the VCAP voltage yourself, which I don't see in the schematic.
> For BOOT0, it's already pulled to ground isn't it?
That's a capacitor, not a resistor. There will be some leakage, but I would not rely on that to pull down the pin. In any case, having a capacitor instead of a resistor here makes very little sense to me.
The USB is correct in theory, but you may want to put it as a GPIO. Not sure how well integrated VBUS detection is in the USB software stack.
2024-08-19 07:16 AM
> Is LDO disabled for your layout? This means you need to supply the VCAP voltage yourself, which I don't see in the schematic.
Oh I didn't know that. I just assumed it was a functionnality that I didn't need. Made the change and switched to 2.2uF capacitors!
> That's a capacitor, not a resistor. There will be some leakage, but I would not rely on that to pull down the pin. In any case, having a capacitor instead of a resistor here makes very little sense to me.
That's so *** of me, you're totally right. An attention error, I'll change it right away, thanks!
> The USB is correct in theory, but you may want to put it as a GPIO. Not sure how well integrated VBUS detection is in the USB software stack.
I see, I'll put it as GPIO and use it as voltage detector. Do you think that i can connect it "as is" or do i have to add extra passive components?
2024-08-19 07:36 AM
As mentioned - feed VDDA by 3.3V directly and just connect the 47ohms from VDDA to VREF+, and keep the caps on both sides of the resistor.
2024-08-19 07:48 AM
I see now :
Looks better now!
2024-08-19 08:00 AM
> I see, I'll put it as GPIO and use it as voltage detector. Do you think that i can connect it "as is" or do i have to add extra passive components?
I would put a resistor divider so the voltage is max 3.3V when USB is connected. 5V can be safe, but you would need to verify the pin can handle it. Most can.