esp32-c3 super mini and esp32-c2 xiao destroyed using serial1
Posted: Thu Dec 28, 2023 9:08 pm
Hi
when I load and run the code below in a ESP32-c3 super mini or in a ESP32-c3 XIAO then it destroys the device : the device is not recognised by windows any more : "the device last connected caused an error" : the usb is not recognised anymore.
It is caused by the line :
#define GpsSerial Serial1 //NB Serial1 vernietigt de esp32c3 !!!!!!!!!!!!!!!!!<br/>
and later writing to GpsSerial.
When I use Serial0 it runs ok.
The destroyed devices keep causing an error when connecting to my laptop. So really destroyed.
Can anyone explain why ?
thanks
Sjors
<r><CODEBOX codebox="cpp" file="Untitled.cpp"><s></e></CODEBOX></r>
when I load and run the code below in a ESP32-c3 super mini or in a ESP32-c3 XIAO then it destroys the device : the device is not recognised by windows any more : "the device last connected caused an error" : the usb is not recognised anymore.
It is caused by the line :
#define GpsSerial Serial1 //NB Serial1 vernietigt de esp32c3 !!!!!!!!!!!!!!!!!<br/>
and later writing to GpsSerial.
When I use Serial0 it runs ok.
The destroyed devices keep causing an error when connecting to my laptop. So really destroyed.
Can anyone explain why ?
thanks
Sjors
<r><CODEBOX codebox="cpp" file="Untitled.cpp"><s>
- </s>
- /* test gps connect to uart rx1<br/>
- * <br/>
- * te doen : * checksum nmea aftesten<br/>
- * <br/>
- * sd card en st7739 kunnen beide op dezelfde hw spi poort :<br/>
- * mosi miso clk van sd en st7739 aan dezelfde pinnen van esp32c3<br/>
- */<br/>
- <br/>
- #include <SD.h><br/>
- #include <SPI.h><br/>
- File myFile;<br/>
- <br/>
- #include <ESP32Time.h><br/>
- //ESP32Time rtc(3600); // offset in seconds GMT+1<br/>
- ESP32Time rtc(0); // offset in seconds GMT<br/>
- <br/>
- // include library en instantieer --------------------------------------------<br/>
- #include <TFT_eSPI.h><br/>
- TFT_eSPI tft = TFT_eSPI();<br/>
- <br/>
- // serial port used rx0 tx0 pin 20 21<br/>
- #define GpsSerial Serial1 //NB Serial1 vernietigt de esp32c3 !!!!!!!!!!!!!!!!!<br/>
- <br/>
- <br/>
- // globale variabelen ------------------------------------------------<br/>
- const byte led0blauw = 0;<br/>
- const byte led2rood = 2;<br/>
- const byte led3geel = 3;<br/>
- const byte led8 = 8;<br/>
- const byte pin1 = 1;<br/>
- uint16_t ReadcharCounter;<br/>
- char Readchar[1000];<br/>
- volatile byte TimerHit;<br/>
- String Readstr;<br/>
- String NMEAstrSplit[3][50]; //rmc = 0, gsv = 1, gga = 2<br/>
- char FolderFileNamesSet;<br/>
- //const int SDChipSelect = 7; //sd card<br/>
- char FileNamechar[13];<br/>
- char FolderNamechar[9];<br/>
- char FolderFileNamechar[23];<br/>
- String FileNamestr;<br/>
- String FolderNamestr;<br/>
- String FolderFileNamestr;<br/>
- <br/>
- uint32_t starttime, endtime;<br/>
- byte UseFont;<br/>
- char str[80];<br/>
- String strhlp;<br/>
- byte cardok;<br/>
- <br/>
- uint32_t StartMillis;<br/>
- uint32_t TimerValue;<br/>
- bool TimerIsRunning;<br/>
- <br/>
- <br/>
- // setup ---start objects en andere-----------------------------------------------------------<br/>
- <br/>
- void setup() {<br/>
- // init variables<br/>
- pinMode(pin1, OUTPUT); <br/>
- digitalWrite(pin1,HIGH);<br/>
- pinMode(led0blauw, OUTPUT);<br/>
- digitalWrite(led0blauw,LOW);<br/>
- pinMode(led2rood, OUTPUT);<br/>
- digitalWrite(led2rood,LOW);<br/>
- pinMode(led3geel, OUTPUT);<br/>
- digitalWrite(led3geel,LOW);<br/>
- pinMode(led8, OUTPUT);<br/>
- digitalWrite(led8,HIGH);<br/>
- <br/>
- ReadcharCounter = 0;<br/>
- TimerHit = 0;<br/>
- FolderFileNamesSet = 'N';<br/>
- <br/>
- // blink<br/>
- for (int i=0; i<5 ; i++) {<br/>
- digitalWrite(led8, LOW);<br/>
- delay(100);<br/>
- digitalWrite(led8, HIGH);<br/>
- delay(500);<br/>
- }<br/>
- <br/>
- // serial monitor<br/>
- Serial.begin(115200);<br/>
- delay(2000);<br/>
- // while (!Serial) { // wait for serial port to connect.<br/>
- // }<br/>
- <br/>
- Serial.println("started");<br/>
- <br/>
- <br/>
- // display ST7739<br/>
- tft.init(); // tft.begin(); zijn hetzelfde<br/>
- tft.setRotation(0);<br/>
- tft.fillScreen(TFT_DARKBLUE);<br/>
- tft.setTextColor(TFT_YELLOW, TFT_DARKBLUE);<br/>
- tft.setTextSize(1);<br/>
- //tft.setTextWrap(false, true); //werkt niet met drawstring<br/>
- UseFont = 4;<br/>
- <br/>
- // serial 1 gps start met 9600 en veranderen naar 19200 baud; de zwarte gps modules slaan niets op dus telkens opnieuw zetten<br/>
- GpsSerial.begin(9600);<br/>
- GpsSerial.println("$PUBX,41,1,0007,0003,19200,0*25");<br/>
- delay(2000);<br/>
- GpsSerial.end(); <br/>
- GpsSerial.begin(19200);<br/>
- <br/>
- }<br/>
- <br/>
- // loop ---------------------------------------------------------------<br/>
- <br/>
- void loop() {<br/>
- CheckTimer();<br/>
- if (TimerHit == 1) {<br/>
- starttime = millis();<br/>
- DisplayData(); //in de vorm van de gelezen string<br/>
- <br/>
- ReadcharCounter = 0;<br/>
- TimerHit = 0;<br/>
- endtime = millis();<br/>
- <br/>
- sprintf(str, "%03d ", endtime - starttime);<br/>
- tft.drawString(str, 198, 168, UseFont); <br/>
- } // end if(TimerHit = 1)<br/>
- <br/>
- if (GpsSerial.available() > 0) {<br/>
- // t1.trigger(5'000); // 5ms<br/>
- digitalWrite(led0blauw,HIGH);<br/>
- StartTimer(100);<br/>
- byte Incomingbyte = GpsSerial.read();<br/>
- if (isAscii(Incomingbyte)) {<br/>
- Readchar[ReadcharCounter] = Incomingbyte;<br/>
- ReadcharCounter++ ; //nog te doen : limiteer tot 999, array is 1000 chars<br/>
- }<br/>
- digitalWrite(led0blauw,LOW);<br/>
- } // end gpsserial.available<br/>
- <br/>
- } // end loop<br/>
- <br/>
- // overige functies ----------------------------------------------<br/>
- <br/>
- void StartTimer(uint16_t TimerValueParm) {<br/>
- TimerValue = TimerValueParm;<br/>
- TimerIsRunning = true;<br/>
- StartMillis = millis();<br/>
- }<br/>
- <br/>
- void CheckTimer() {<br/>
- if (TimerIsRunning) {<br/>
- if ((millis() - StartMillis) >= TimerValue) {<br/>
- TimerHit = 1;<br/>
- //Serial.print("noofbytesread=");Serial.println(ReadcharCounter);<br/>
- TimerIsRunning = false;<br/>
- }<br/>
- }<br/>
- }<br/>
- <br/>
- void DisplayData() {<br/>
- Serial.print("no bytes read:"); Serial.println(ReadcharCounter);<br/>
- Serial.println("------Readchar start");<br/>
- for (int i = 0; i < ReadcharCounter; i++) {<br/>
- Serial.print(Readchar[i]);<br/>
- }<br/>
- Serial.println();<br/>
- Serial.println("------Readchar end");<br/>
- // tft.setCursor(0, 120); tft.print(Readstr);<br/>
- }<br/>
- <br/>
- <e>