espressif / arduino-esp32

Arduino core for the ESP32
GNU Lesser General Public License v2.1
13.07k stars 7.31k forks source link

Unable to use uart0 RX pin in esp32-c6 #9959

Closed adiiot-1316 closed 2 weeks ago

adiiot-1316 commented 4 weeks ago

Board

ESP32-C6

Device Description

ESP32-C6-WROOM-1-N8 Board

Hardware Configuration

GPIO 4,5 are connected to GSM Module TX RX respectively

Version

latest master (checkout manually)

IDE Name

Arduino IDE

Operating System

Windows 10

Flash frequency

80Mhz

PSRAM enabled

yes

Upload speed

9200

Description

Hi ,

I am trying to connect my Lora module with ESP32-c6 over UART Rx Tx line. UART 4,5 are already used in connection with GSM Module. I am trying to use ESP32-c6 UART Pin N.o. 16,17 with Lora Module , but Rx is not receiving the packets as GPIO17 is default function active. How to enable the Rx function in Arduino IDE? As checked in c6 documentation, there are 3 functions associated with GPIO 17. 1.)Rx 2.)GPIO17 3.)Chipselect. By default f1 is enabled. We need to change the function to f0. tried below code but it didnot work out.

define IO_MUX_GPIO17_MCU_SEL 0;

Same piece of code is working when i am using UART Pin# 4, 5. I am quite stuck due to this issue in prototype phase and would really appreciate your support here.

Sketch

//Receiver Code
#include "Arduino.h"
#define E32_TTL_1W
#include "LoRa_E32.h"
/* For esp32
#define AUX 15
#define M0 2
#define M1 3
*/
#define AUX 23
#define M0 14
#define M1 15
//#define IO_MUX_GPIO17_MCU_SEL 0;

LoRa_E32 e32ttl1w(&Serial0, AUX, M0, M1);
ResponseContainer rc;
void setup() {
    Serial.begin(9600);
  Serial.println("In setup mode");
    delay(500);
// Startup all pins and UART
    e32ttl1w.begin();
    nodeConfig();
}

void loop() {
    if (e32ttl1w.available() > 0) {
        Serial.println("———-");
        rc = e32ttl1w.receiveMessageUntil();    
        if (rc.status.code != 1) {
            rc.status.getResponseDescription();      
        } else {
            // Print the data received
            Serial.println(rc.data);
        }
    }
    delay(100);
}

void nodeConfig() {
    ResponseStructContainer c;
    c = e32ttl1w.getConfiguration();
    Configuration configuration = *(Configuration*) c.data;
    configuration.ADDH = 0x0;
    configuration.ADDL = 0x3;
    configuration.CHAN = 0x4;
    configuration.SPED.airDataRate = AIR_DATA_RATE_010_24;
    configuration.SPED.uartBaudRate = UART_BPS_9600;
    configuration.SPED.uartParity = MODE_00_8N1;
    configuration.OPTION.fec = FEC_1_ON;
    configuration.OPTION.fixedTransmission = FT_FIXED_TRANSMISSION;
    configuration.OPTION.ioDriveMode = IO_D_MODE_PUSH_PULLS_PULL_UPS;
    configuration.OPTION.transmissionPower = POWER_21;
    configuration.OPTION.wirelessWakeupTime = WAKE_UP_1250;
    // Set configuration changed and set to not hold the configuration
    c.close();
    Serial.println("Updtaed config is ");

    ResponseStatus rs = e32ttl1w.setConfiguration(configuration, WRITE_CFG_PWR_DWN_SAVE);
    Serial.print("Config: ");
    Serial.println(rs.getResponseDescription());
}

Debug Message

No Error message

Other Steps to Reproduce

No response

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

me-no-dev commented 3 weeks ago

I don't see you using Serial*.setPins(RX, TX); anywhere? You need to set the pins prior to calling begin

adiiot-1316 commented 3 weeks ago

Thanks for your reply !! Though it should be covered in E32 Library, i'll cross verify and get back to you.

adiiot-1316 commented 3 weeks ago

I don't see you using Serial*.setPins(RX, TX); anywhere? You need to set the pins prior to calling begin

Just checked in Library, they are using below code internally. this->serialDef.begin(*this->hs, this->bpsRate, this->serialConfig, this->txE32pin, this->rxE32pin);

VojtechBartoska commented 2 weeks ago

hello @adiiot-1316, can I mark this as answered?

adiiot-1316 commented 2 weeks ago

@VojtechBartoska yes please. Some issue with uart pin. Work fine on other board.