Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

USB-JTAG pin19 and pin20 to be used as GPIO #11100

Unanswered
muzahid13 asked this question in Q&A
Discussion options

Board

esp32-s3

Device Description

i am using esp32-s3 based LVGL 7 inch display. I need to use the USB-JTAG pin19 and pin20 as gpio. i already prepared the PCB. i just made high and low pin20 at regular interval, then i noticed that it impacted on other code, i am using visual studio code platformio and framework: arduino.how can i disbale usb-jtag in platformio and framework arduino. my code is completed, i stuck on pin19 and pin20 to be gpio. thanks

Hardware Configuration

GPIO pin19 and pin20 are connected to max485 D-enable and R-enable pin. so those pin shoudl be used as GPIO pin

Version

latest master (checkout manually)

IDE Name

PlatformIO

Operating System

Windows11

Flash frequency

40Mhz

PSRAM enabled

yes

Upload speed

115200

Description

pin19 and pin20 must be used as GPIO. when i enable PIN19 and 20 as GPIO, the code impact on other portion like the mcu is hanged

Sketch

void loop()
{
 lv_timer_handler(); /* let the GUI do its work */
 delay(5);
 pinMode(20,OUTPUT);
 digitalWrite(20,LOW);
 if (Serial1.available()>0)
 {
 digitalWrite(20,HIGH);
 Serial1.write(Serial1.read());
 delay(2);
 digitalWrite(20,LOW);
 }
}

Debug Message

no error found on debug

Other Steps to Reproduce

No response

I have checked existing issues, online documentation and the Troubleshooting Guide

  • I confirm I have checked existing issues, online documentation and Troubleshooting guide.
You must be logged in to vote

Replies: 15 comments

Comment options

Idk if it is possible at all to get this restricted GPIOs glitch free.
There are some sdkconfig options to disable some USB JTAG features. Maybe it needs burning some efuses to solve.
In every case you have to compile your project with Arduino as an component of IDF to have the possibility to change the involved sdkconfig settings.

In short not possible with Arduino "only"

You must be logged in to vote
0 replies
Comment options

There should be no problem using pins 20 and 19 from S3.
The configuration shall not enable USB.
Check if ARDUINO_USB_CDC_ON_BOOT=0 to disable this USB.

You must be logged in to vote
0 replies
Comment options

configuration

I placed
#define ARDUINO_USB_CDC_ON_BOOT 0
but unfortunately the my lvgl code didn’t work. Actually usb pin19 and 20 works as gpio but impact on others code. I need to disable usb jtag then use as gpio

You must be logged in to vote
0 replies
Comment options

configuration

I placed #define ARDUINO_USB_CDC_ON_BOOT 0 but unfortunately the my lvgl code didn’t work. Actually usb pin19 and 20 works as gpio but impact on others code. I need to disable usb jtag then use as gpio

It doesn't work like that (it can't be defined in the sketch).
I have limited knowledge about PlatformIO, but it shall be done like here:
https://community.platformio.org/t/enabling-usb-cdc-on-boot-on-esp32-c3-devkit/33346/2

Maybe @Jason2866 can help it.

You must be logged in to vote
0 replies
Comment options

Idk if it is possible at all to get this restricted GPIOs glitch free. There are some sdkconfig options to disable some USB JTAG features. Maybe it needs burning some efuses to solve. In every case you have to compile your project with Arduino as an component of IDF to have the possibility to change the involved sdkconfig settings.

In short not possible with Arduino "only"

i am using platformio on vs code, below is my platformio.ini data
[env:4d_systems_esp32s3_gen4_r8n16]
platform = espressif32
board = 4d_systems_esp32s3_gen4_r8n16
framework = arduino
monitor_speed = 115200
lib_deps = lvgl/lvgl@^8.3.11
please suggest where i need to change or add any contents. thanks

You must be logged in to vote
0 replies
Comment options

This:

[env:4d_systems_esp32s3_gen4_r8n16]
platform = espressif32
board = 4d_systems_esp32s3_gen4_r8n16
framework = arduino
monitor_speed = 115200
lib_deps = lvgl/lvgl@^8.3.11

uses any Arduino version Platformio founds. You don't know if this is the latest. I highly doubt.
Use that

[env:4d_systems_esp32s3_gen4_r8n16]
platform = https://github.com/pioarduino/platform-espressif32.git
board = 4d_systems_esp32s3_gen4_r8n16
framework = arduino
monitor_speed = 115200
lib_deps = lvgl/lvgl@^8.3.11

The board you have specified use this settings

 "-DARDUINO_ESP32_S3R8N16",
 "-DBOARD_HAS_PSRAM",
 "-DARDUINO_USB_MODE=1",
 "-DARDUINO_USB_CDC_ON_BOOT=1",
 "-DARDUINO_RUNNING_CORE=1",
 "-DARDUINO_EVENT_RUNNING_CORE=1

for sure wrong regarding USB. To help what exactly S3 variant does you have.
Flash size and type and PSRAM type (QIO or OPI)?
With this Infos it is possible to help

You must be logged in to vote
0 replies
Comment options

platform = https://github.com/pioarduino/platform-espressif32.git

esp32-s3 mcu
i shared the esp32s3 picture here. i am using this mcu. please check. thanks

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

16MB QIO Flash and 8MB OPI PSRAM Use this https://github.com/sivar2311/ESP32-S3-PlatformIO-Flash-and-PSRAM-configurations?tab=readme-ov-file#esp32-s3-wroom-11u-n16r8

i placed the following contents on the platformio.ini file but i think USB-JTAG didnot disable,
; Flash: 16MB QD, PSRAM: 8MB OT
[env:esp32-s3-devkitc-1]
platform = espressif32
board = esp32-s3-devkitc-1
framework = arduino
monitor_speed = 115200
lib_deps = lvgl/lvgl@^8.3.11

board_build.arduino.memory_type = qio_opi
board_build.flash_mode = qio
board_build.psram_type = opi
board_upload.flash_size = 16MB
board_upload.maximum_size = 16777216
board_build.extra_flags =
-DBOARD_HAS_PSRAM

build_flags =
-DARDUINO_ESP32_S3R8N16
-DBOARD_HAS_PSRAM
-DARDUINO_USB_MODE=0
-DARDUINO_USB_CDC_ON_BOOT=0
-DARDUINO_RUNNING_CORE=1
-DARDUINO_EVENT_RUNNING_CORE=1

i wrote the follwing line in void loop,
pinMode(20,OUTPUT);
digitalWrite(20,LOW);
delay(1000);
digitalWrite(20,HIGH);
delay(1000);

here pin20 worked as gpio, pin20 blinking but impact other other code, other code didnot run. did you get the point where it stuck? thanks

You must be logged in to vote
0 replies
Comment options

@muzahid13
Anyway, this issue has a resolution. pin 19 and 20 work correctly as GPIO.
The rest of the code that is not working is not related to an Arduino Core issue, right?

Therefore, should we close this issue?

You must be logged in to vote
0 replies
Comment options

Small advice: Look up how to properly format github issues and comments... e.g. the code above is unreadable. Enclose it like this:

```
this is
my
program
```

You must be logged in to vote
0 replies
Comment options

Small advice: Look up how to properly format github issues and comments... e.g. the code above is unreadable. Enclose it like this:

`this is` `my` `program`
i updated my below code. could anyone help me to solve the issue
but if i dont use pin19 and 20 as gpio, my other code works good. only impact appeared on other code when i use pin19 and 20 as GPIO.
below is my complete code:

/*******************************************************************************
 * LVGL Widgets
 * This is a widgets demo for LVGL - Light and Versatile Graphics Library
 * import from: https://github.com/lvgl/lv_demos.git
 *
 * Dependent libraries:
 * LVGL: https://github.com/lvgl/lvgl.git
 * Touch libraries:
 * FT6X36: https://github.com/strange-v/FT6X36.git
 * GT911: https://github.com/TAMCTec/gt911-arduino.git
 * XPT2046: https://github.com/PaulStoffregen/XPT2046_Touchscreen.git
 *
 * LVGL Configuration file:
 * Copy your_arduino_path/libraries/lvgl/lv_conf_template.h
 * to your_arduino_path/libraries/lv_conf.h
 * Then find and set:
 * #define LV_COLOR_DEPTH 16
 * #define LV_TICK_CUSTOM 1
 *
 * For SPI display set color swap can be faster, parallel screen don't set!
 * #define LV_COLOR_16_SWAP 1
 *
 * Optional: Show CPU usage and FPS count
 * #define LV_USE_PERF_MONITOR 1
 ******************************************************************************/
#include <Arduino.h>
#include <lvgl.h>
#include "uart0.h"
#include "ui.h"
#define TX1_PIN 17
#define RX1_PIN 18
#define TX_PIN 43
#define RX_PIN 44
#include <Arduino_GFX_Library.h>
#define TFT_BL 2
// #define GFX_BL DF_GFX_BL // default backlight pin, you may replace DF_GFX_BL to actual backlight pin
/* More dev device declaration: https://github.com/moononournation/Arduino_GFX/wiki/Dev-Device-Declaration */
#if defined(DISPLAY_DEV_KIT)
Arduino_GFX *gfx = create_default_Arduino_GFX();
#else /* !defined(DISPLAY_DEV_KIT) */
/* More data bus class: https://github.com/moononournation/Arduino_GFX/wiki/Data-Bus-Class */
// Arduino_DataBus *bus = create_default_Arduino_DataBus();
/* More display class: https://github.com/moononournation/Arduino_GFX/wiki/Display-Class */
// Arduino_GFX *gfx = new Arduino_ILI9341(bus, DF_GFX_RST, 0 /* rotation */, false /* IPS */);
Arduino_ESP32RGBPanel *bus = new Arduino_ESP32RGBPanel(
 GFX_NOT_DEFINED /* CS */, GFX_NOT_DEFINED /* SCK */, GFX_NOT_DEFINED /* SDA */,
 41 /* DE */, 40 /* VSYNC */, 39 /* HSYNC */, 42 /* PCLK */,
 14 /* R0 */, 21 /* R1 */, 47 /* R2 */, 48 /* R3 */, 45 /* R4 */,
 9 /* G0 */, 46 /* G1 */, 3 /* G2 */, 8 /* G3 */, 16 /* G4 */, 1 /* G5 */,
 15 /* B0 */, 7 /* B1 */, 6 /* B2 */, 5 /* B3 */, 4 /* B4 */
);
// option 1:
// 7寸 50PIN 800*480
Arduino_RPi_DPI_RGBPanel *gfx = new Arduino_RPi_DPI_RGBPanel(
 bus,
 // 800 /* width */, 0 /* hsync_polarity */, 8/* hsync_front_porch */, 2 /* hsync_pulse_width */, 43/* hsync_back_porch */,
 // 480 /* height */, 0 /* vsync_polarity */, 8 /* vsync_front_porch */, 2/* vsync_pulse_width */, 12 /* vsync_back_porch */,
 // 1 /* pclk_active_neg */, 16000000 /* prefer_speed */, true /* auto_flush */);
 800 /* width */, 0 /* hsync_polarity */, 210 /* hsync_front_porch */, 30 /* hsync_pulse_width */, 16 /* hsync_back_porch */,
 480 /* height */, 0 /* vsync_polarity */, 22 /* vsync_front_porch */, 13 /* vsync_pulse_width */, 10 /* vsync_back_porch */,
 1 /* pclk_active_neg */, 16000000 /* prefer_speed */, true /* auto_flush */);
#endif /* !defined(DISPLAY_DEV_KIT) */
/*******************************************************************************
 * End of Arduino_GFX setting
 ******************************************************************************/
/*******************************************************************************
 * Please config the touch panel in touch.h
 ******************************************************************************/
#include "touch.h"
uint32_t preMillis=0;
bool lock_loop=false;
/* Change to your screen resolution */
static uint32_t screenWidth;
static uint32_t screenHeight;
static lv_disp_draw_buf_t draw_buf;
static lv_color_t *disp_draw_buf;
static lv_disp_drv_t disp_drv;
/* Display flushing */
void my_disp_flush(lv_disp_drv_t *disp, const lv_area_t *area, lv_color_t *color_p)
{
 uint32_t w = (area->x2 - area->x1 + 1);
 uint32_t h = (area->y2 - area->y1 + 1);
#if (LV_COLOR_16_SWAP != 0)
 gfx->draw16bitBeRGBBitmap(area->x1, area->y1, (uint16_t *)&color_p->full, w, h);
#else
 gfx->draw16bitRGBBitmap(area->x1, area->y1, (uint16_t *)&color_p->full, w, h);
#endif
 lv_disp_flush_ready(disp);
}
void my_touchpad_read(lv_indev_drv_t *indev_driver, lv_indev_data_t *data)
{
 if (touch_has_signal())
 {
 if (touch_touched())
 {
 preMillis=millis();
 lock_loop=true; 
 data->state = LV_INDEV_STATE_PR;
 /*Set the coordinates*/
 data->point.x = touch_last_x;
 data->point.y = touch_last_y;
 // Serial0.print( "Data x " );
 // Serial0.println( data->point.x );
 // Serial0.print( "Data y " );
 // Serial0.println( data->point.y );
 }
 else if (touch_released())
 {
 data->state = LV_INDEV_STATE_REL;
 }
 }
 else
 {
 data->state = LV_INDEV_STATE_REL;
 }
}
void setup()
{
 uart0_init();
// Serial0.begin(115200, SERIAL_8N1, RX_PIN, TX_PIN);
 gfx->begin();
#ifdef TFT_BL
 pinMode(TFT_BL, OUTPUT);
 digitalWrite(TFT_BL, HIGH);
// ledcSetup(PWM_CHANNEL, PWM_FREQUENCY, PWM_RESOUTION);
// ledcAttachPin(speakerPin, PWM_CHANNEL);
 ledcSetup(0, 300, 8);
 ledcAttachPin(TFT_BL, 0);
 //ledcAttach(uint8_t pin, uint32_t freq, uint8_t resolution);
 //ledcAttach(TFT_BL, 300, 8);
 ledcWrite(0, 255); /* Screen brightness can be modified by adjusting this parameter. (0-255) */
#endif
 gfx->fillScreen(RED);
 delay(500);
 gfx->fillScreen(GREEN);
 delay(500);
 gfx->fillScreen(BLUE);
 delay(500);
 gfx->fillScreen(BLACK);
 delay(500);
 lv_init();
 // Init touch device
 pinMode(TOUCH_GT911_RST, OUTPUT);
 digitalWrite(TOUCH_GT911_RST, LOW);
 delay(10);
 digitalWrite(TOUCH_GT911_RST, HIGH);
 delay(10);
 touch_init();
 // touch.setTouch( calData );
 screenWidth = gfx->width();
 screenHeight = gfx->height();
#ifdef ESP32
 disp_draw_buf = (lv_color_t *)heap_caps_malloc(sizeof(lv_color_t) * screenWidth * screenHeight / 4, MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT);
#else
 disp_draw_buf = (lv_color_t *)malloc(sizeof(lv_color_t) * screenWidth * screenHeight / 4);
#endif
 if (!disp_draw_buf)
 {
 // Serial0.println("LVGL disp_draw_buf allocate failed!");
 }
 else
 {
 lv_disp_draw_buf_init(&draw_buf, disp_draw_buf, NULL, screenWidth * screenHeight / 4);
 /* Initialize the display */
 lv_disp_drv_init(&disp_drv);
 /* Change the following line to your display resolution */
 disp_drv.hor_res = screenWidth;
 disp_drv.ver_res = screenHeight;
 disp_drv.flush_cb = my_disp_flush;
 disp_drv.draw_buf = &draw_buf;
 lv_disp_drv_register(&disp_drv);
 /* Initialize the (dummy) input device driver */
 static lv_indev_drv_t indev_drv;
 lv_indev_drv_init(&indev_drv);
 indev_drv.type = LV_INDEV_TYPE_POINTER;
 indev_drv.read_cb = my_touchpad_read;
 lv_indev_drv_register(&indev_drv);
 // lv_demo_widgets();
 ui_init();
 // Serial0.println("Setup done");
 }
 
}
uint32_t preMillis_Sent = 0;
uint8_t i = 0, protocol[32], len = 0,sentCount=0;
uint8_t checksum(uint8_t data[],uint8_t length);
//bool lock_loop=false;
uint8_t disAuth[6] = {0x02, 0x29, 0x03, 0xE9, 0x31,0xF0};
uint8_t ScanOpCD[6] = {0x02, 0x29, 0x03, 0xE9, 0x32,0xF3};
uint8_t enterKilo[6] = {0x02, 0x29, 0x03, 0xE9, 0x33,0xF2};
uint8_t CDnotRg[6] = {0x02, 0x29, 0x03, 0xE9, 0x38,0xF9};
uint8_t DontHvLmt[6] = {0x02, 0x29, 0x03, 0xE9, 0x39,0xF8};
uint8_t blockCD[6] = {0x02, 0x29, 0x03, 0xE9, 0x3A,0xFB};
uint8_t carPlate[6] = {0x02, 0x29, 0x03, 0xE9, 0x44,0x85};
uint8_t EnterPin[6] = {0x02, 0x29, 0x03, 0xE9, 0x45,0x84};
uint8_t CDbelongTo[32]= {0x02, 0x29, 0x03, 0xE9, 0x37,'A','d','h','a','m','A','d','h','a','m','A','d','h','a','m','A',0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xF6};
//02 29 03 E9 37 41 64 68 61 6D 41 64 68 61 6D 41 64 68 61 6D 41 64 68 61 6D 41 64 68 61 6D 78 CF
uint8_t disAuthLmt[10]= {0x02, 0x29, 0x03, 0xE9, 0x36,0x11, 0x22, 0x33, 0x44,0xB3};
 //02 29 03 E9 36 11 22 33 44 B3
uint8_t sendAck[6] = {0x02, 0x29, 0x03, 0xE9, 0xAF,0x6E};
uint8_t recvAck[6] = {0x02, 0x29, 0x03, 0xE9, 0xBF,0x7E};
 
void loop()
{
 lv_timer_handler(); /* let the GUI do its work */
 delay(5);
pinMode(20,OUTPUT);
digitalWrite(20,LOW);
delay(1000);
digitalWrite(20,HIGH);
delay(1000);
}

for the above code my lvgl code is stuck when pin20 is active as GPIO but if i remove pin20 gpio code, my lvgl code is working good. could you please help to solve this?

You must be logged in to vote
0 replies
Comment options

@muzahid13 - please try this code in the begining of setup():

void setup()
{
 pinMode(19, OUTPUT);
 pinMode(20, OUTPUT);
 uart0_init();
You must be logged in to vote
0 replies
Comment options

@SuGlider; I think you maybe wanted to @ reference someone else, as above issue is for ESP32-S3, and mine was re. ESP32-C3?

You must be logged in to vote
0 replies
Comment options

@SuGlider; I think you maybe wanted to @ reference someone else, as above issue is for ESP32-S3, and mine was re. ESP32-C3?

Thanks for the warning.
It was for @muzahid13 instead.

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
Type: Question Only question Area: Peripherals API Relates to peripheral's APIs.
Converted from issue

This discussion was converted from issue #10587 on March 12, 2025 18:21.

AltStyle によって変換されたページ (->オリジナル) /