πŸ“˜ How to start with ESP32-C2 (ESP8684) PWM (ledc) ESP-IDF VSCode

Intro

Very interesting SoC ESP8684 stands out from other MCUs because of 12-bit ADC memory with 5 channels, built-in FLASHΒ  and moderate price, that is lower than other ESP32 chips.

Image

Installing VSCode and ESP-IDF SDK

1) Download VSCode (Visual Studio Code) and install it:

Image

2) Open VSCode, open Extensions (Ctrl + Shift + X) and install ESP-IDF extension:

Image

3) In Command Palette (Ctrl + Shift + P) find and open ESD-IDF: Configure ESP-IDF Extension. Choose EXPRESS setup option then select ESP-IDF directory (optional) and pressInstall:

Image

4) This process is long an takes approximately 6-7 minutes. After finishing I recommend to restart the program.

Image

Creation of Project

1) In Command Palette (Ctrl + Shift + P) find and open Example. Now you can see many test projects, choose ledc (PWM) and specify directory for saving:

Image

2) Now super important to choose MCU, because by default it's ESP32. Set ESP-IDF: Espressif Device Target to esp32c2(esp8684)

Image

3) Try to build project by ESP-IDF: Build Project. Building is successful:

Image

Flashing & Debug

1) Connect you ESP32C2 (ESP8684) to PC using USB Cable, open Device Manager and check that is correctly identified:

Image

2) In VSCode IDE ESP-IDF: Select Port to Use (com, tty, usbserial) and specify port number (in my case it's COM7). (Choose USB-Bridge if not selected before)

Image

3) Press on fire icon or ESP-IDF: Build, Flash and Monitor

Image

4) After a few mins of compiling you should see green debug information in TERMINAL window.

Image

πŸ’‘ Testing

1) As you can see we didn't changed any default code. So let's specify gpio to GPIO0 and press on fire icon (Build, Flash and Monitor)

Image

2) Now I connected frequency meter to the GPIO0 and as you can see frequency and duty cycle is the same as in the code

ImageImage

The same value measured by using logic analyzer (channel D0):Β 

Image

πŸ“˜ Fix-Tip

If you use the similar Chinese board as mine you could see yellow errors in monitor and get incorrect frequency value most likely your devboard have another XTAL (crystal) than specified in the default configs. So, see the small fix-article of this issue:

ImageImage

Conclusions

  • New chip looks like very good choice for the small low-power and low-cost devices, because it has built-in FLASH and ADC with 12-bit resolution and five channels
  • ESP-IDF peripheral examples give a chance to quickly get working results, that can be used for your project
  • Pay attention, that ESP have many configurations (such as crystal frequency), that will affect of working
353
No comments yet. Be the first to add a comment!
Cookies?