ESP32-S3 SoC questions: integrated USB, SPI Flash, crystal (& schematic review)

Peugot206
Posts: 4
Joined: Wed Dec 14, 2022 9:10 am

ESP32-S3 SoC questions: integrated USB, SPI Flash, crystal (& schematic review)

Postby Peugot206 » Wed Dec 14, 2022 9:20 am

Hi all!

I'm working on a project that involves an ESP32-S3 SoC. I'm trying to read and understand the datasheet myself as much as possible and have come up with the following schematic:

* MCU section schematic PDF: https://drive.google.com/file/d/1dbvD-F ... sp=sharing

I've tried to add relevant comments everywhere why I did X or Y. If you see a P7 for example, it means Page 7 from the datasheet (https://www.espressif.com/sites/default ... nes_en.pdf) (except for the JTAG part). If you spot any mistakes or have any additional questions about my schematic, please let me know!

Now I have some questions that I can't really figure out and sometimes read contrasting (questions 1 and 2) things about. I hope someone can help me out here.

1. Since the ESP32-S3 comes with a USB (driver/peripheral?) I can directly connect the USB lines to GPIO19 (D-) and GPIO20 (D+), the datasheet mentions stuff about strapping pin GPIO3 which at 0: JTAG signal from on-chip JTAG, and 1: JTAG signal from USB Serial/JTAG controller. I am unsure whether I should pull this LOW/HIGH, thus for now I added a switch. But I would still like to hear what is the right approach.

2. Does anyone happen to know whether I can program the ESP32-S3 with Platform IO if my USB is directly connected to the ESP32-S3 (instead of an USB driver like CP2102)? I've seen people saying that it's not possible, and people saying that it's perfectly fine..

3. Which one is recommended to use: USB Serial/JTAG controller or the integrated USB OTG? Both can be used directly by USB, what are the advantages of using which?

4. The ESP32-S3 can run at 240MHz, but the crystal (that is mandatory) runs only at 40MHz? Does this mean the ESP32-S3 has an internal clock at 240MHz, if so then why is the 40MHz clock mandatory?

5. First time using the bare ESP32-S3 SoC, instead of a module. I have added 8M-bit SPI flash (W25Q80DVSSIG), is it as simple as connecting it to the ESP32 and it will work? Or is there something in the software I have to do to before it works as well? What is recommended, DUAL SPI or QUAD SPI?

6. Could I also swap the SPI Flash for a larger 16M-bit one like this: ZD25WQ16BTIGR https://datasheet.lcsc.com/lcsc/2109141 ... 896790.pdf? What specs should I look at when I want to take another SPI flash chip?

7. I struggled quite a bit with the antenna part, it must be impedance matched at 50 ohm, and I use a pi network for better efficiency. I think I can only start calculating these values of C11, C12 and L3 once I start routing the PCB and need to check the actual traces impedance to the antenna? Furthermore the antenna should have some spacing around it on the top layer without any copper next to it, and a ground plane below it on the bottom layer, no signals running below it either. The traces to the antenna should be straight with the pi matched network components 'laying' on top of these traces going into the antenna. How do I exactly calculate those pi matched network values? Anything I'm wrong about/missing?

Thanks for any help!

ESP_Sprite
Posts: 9739
Joined: Thu Nov 26, 2015 4:08 am

Re: ESP32-S3 SoC questions: integrated USB, SPI Flash, crystal (& schematic review)

Postby ESP_Sprite » Thu Dec 15, 2022 1:57 am

Answering what I know:
Peugot206 wrote:
Wed Dec 14, 2022 9:20 am
1. Since the ESP32-S3 comes with a USB (driver/peripheral?) I can directly connect the USB lines to GPIO19 (D-) and GPIO20 (D+), the datasheet mentions stuff about strapping pin GPIO3 which at 0: JTAG signal from on-chip JTAG, and 1: JTAG signal from USB Serial/JTAG controller. I am unsure whether I should pull this LOW/HIGH, thus for now I added a switch. But I would still like to hear what is the right approach.
You don't have to do anything with that pin. It doesn't do anything unless you burn a certain eFuse. If you do not need GPIO JTAG, you can just leave that fuse alone and use GPIO3 for whatever you want; it doesn't do anything in that case.
3. Which one is recommended to use: USB Serial/JTAG controller or the integrated USB OTG? Both can be used directly by USB, what are the advantages of using which?
It depends. Both allow for programming the chip. USB serial/JTAG allows for debugging (via JTAG) as well. USB OTG allows you to set up an USB device in software, e.g. a mass storage device ('USB stick') while USB serial/JTAG only does that function.
4. The ESP32-S3 can run at 240MHz, but the crystal (that is mandatory) runs only at 40MHz? Does this mean the ESP32-S3 has an internal clock at 240MHz, if so then why is the 40MHz clock mandatory?
There's an internal PLL in there which effectively uses the very stable 40MHz signal to generate a very stable 240MHz signal. If the 40MHz signal was not there, the PLL wouldn't have anything to lock against and the 240MHz signal would be very unstable. As this also affects the WiFi frequency, this is not very desirable.
5. First time using the bare ESP32-S3 SoC, instead of a module. I have added 8M-bit SPI flash (W25Q80DVSSIG), is it as simple as connecting it to the ESP32 and it will work? Or is there something in the software I have to do to before it works as well? What is recommended, DUAL SPI or QUAD SPI?
Should work. Quad SPI is twice as fast as dual SPI, so you'd want to use that.
6. Could I also swap the SPI Flash for a larger 16M-bit one like this: ZD25WQ16BTIGR https://datasheet.lcsc.com/lcsc/2109141 ... 896790.pdf? What specs should I look at when I want to take another SPI flash chip?
Possibly? I don't quite know that chip. There's a fair bit to compare, but mostly you'd want to know if the dual/quad read instructions are the same as e.g. the W25Q80, and if the QE bit is in the same location. Easiest may be to simply try it, generally it either works or it doesn't.
7. I struggled quite a bit with the antenna part, it must be impedance matched at 50 ohm, and I use a pi network for better efficiency. I think I can only start calculating these values of C11, C12 and L3 once I start routing the PCB and need to check the actual traces impedance to the antenna? Furthermore the antenna should have some spacing around it on the top layer without any copper next to it, and a ground plane below it on the bottom layer, no signals running below it either. The traces to the antenna should be straight with the pi matched network components 'laying' on top of these traces going into the antenna. How do I exactly calculate those pi matched network values? Anything I'm wrong about/missing?
You wouldn't, in practice, calculate those (except perhaps as a first-order approach) in the design stage. You'd fab the PCB, then use a VNA to find out the characteristics, then tweak the Cs and Ls to match. Sorry, I don't know much more than that.

One more thing to make sure: It's not on the page you shared, but make 100% sure your power supply is adequate: it should be able to deliver 500mA @ 3.3V. If this is undersized, you'll get brownouts, likely on WiFi initialization.

Peugot206
Posts: 4
Joined: Wed Dec 14, 2022 9:10 am

Re: ESP32-S3 SoC questions: integrated USB, SPI Flash, crystal (& schematic review)

Postby Peugot206 » Thu Dec 15, 2022 9:02 am

@ESP_Sprite thanks for your great detailed answer, much appreciated! My power supply can deliver 500mA@3.7V through a LiPo so that should be fine.

Furthermore I had one more question regarding:
It depends. Both allow for programming the chip. USB serial/JTAG allows for debugging (via JTAG) as well. USB OTG allows you to set up an USB device in software, e.g. a mass storage device ('USB stick') while USB serial/JTAG only does that function.
I've read somewhere that through USB-OTG you could also JTAG debug, so that is not the case then? Only flashing?
Is it then also possible to connect the USB D+ and D- in a way that you use the USB serial/JTAG or does that only work through the JTAG headers (which is more than 2 pins).

ESP_Sprite
Posts: 9739
Joined: Thu Nov 26, 2015 4:08 am

Re: ESP32-S3 SoC questions: integrated USB, SPI Flash, crystal (& schematic review)

Postby ESP_Sprite » Fri Dec 16, 2022 2:34 am

You cannot use USB-OTG for JTAG, only flashing. The USB-OTG and USB-serial-JTAG are on the same pins: unless you specifically initialize something that enables the USB-OTG (e.g. TinyUSB) or burn eFuses, the USB-serial-JTAG will be on GPIO19/GPIO20, and you can use that to JTAG-debug it.

Peugot206
Posts: 4
Joined: Wed Dec 14, 2022 9:10 am

Re: ESP32-S3 SoC questions: integrated USB, SPI Flash, crystal (& schematic review)

Postby Peugot206 » Fri Dec 16, 2022 11:02 am

ESP_Sprite wrote:
Fri Dec 16, 2022 2:34 am
You cannot use USB-OTG for JTAG, only flashing. The USB-OTG and USB-serial-JTAG are on the same pins: unless you specifically initialize something that enables the USB-OTG (e.g. TinyUSB) or burn eFuses, the USB-serial-JTAG will be on GPIO19/GPIO20, and you can use that to JTAG-debug it.
Thanks again! I've read the technical ESP32-S3 datasheet https://www.espressif.com/sites/default ... serialjtag on the USB Serial/JTAG controller and the USB-OTG parts, and the USB Serial/JTAG controller is exactly what I need. It seems to offer:
- Flashing the chip
- Debug chip over JTAG
- Only requires the hardware D- and D+ USB pins.
- Auto chip reset and auto download mode (with CDC-ACM)

Since you can't use both USB-OTG and USB-Serial/JTAG the eFuse settings decide which are being used, they show me this table in the datasheet (see attachment). It seems to me that by default the USB-Serial/JTAG is used and I don't have to do anything with those settings? Does this also mean that by default I can't use the external JTAG pins to connect an ESP32-JTAG programmer just as a back-up case, it's either the internal JTAG or the external JTAG?

If what all I said above is true, I really can't believe this is all integrated in the ESP32-S3!
Attachments
ds table.png
ds table.png (64.68 KiB) Viewed 3516 times

ESP_Sprite
Posts: 9739
Joined: Thu Nov 26, 2015 4:08 am

Re: ESP32-S3 SoC questions: integrated USB, SPI Flash, crystal (& schematic review)

Postby ESP_Sprite » Sat Dec 17, 2022 4:04 am

Yes, that is all correct. Some nuance: as I said before, having USB-serial-JTAG (or whatever you set with the efuses) on the pin is the default; if your application itself needs to use USB-OTG, it can always switch over once it's booted (and that keeps until the chip is reset). Also, do note that USB-serial-JTAG isn't perfect, there's some limitations compared to an external USB-serial converter. They are mostly applicable to pretty specific scenarios, but it's probably good to be aware of them.

Peugot206
Posts: 4
Joined: Wed Dec 14, 2022 9:10 am

Re: ESP32-S3 SoC questions: integrated USB, SPI Flash, crystal (& schematic review)

Postby Peugot206 » Mon Dec 19, 2022 10:49 am

Thanks a lot once again, these limitation are not a problem for me! :D

I was just double checking my schematic and I noticed that the SPI Flash I currently use W25Q80DVSSIG is from a forum post where someone asked the question whether or not this chip works with the ESP32. I thought I found this chip in an official ESP32 example, but I can't find which SPI flash chips the ESP32-S3 module use (like WROOM) anywhere. Is there any 16M-bit (I know current one is 8M-bit, but I prefer 16M-bit) that is known to work with the ESP32-S3?

Who is online

Users browsing this forum: Bing [Bot], MicroController and 100 guests