esp32-c3 super mini and esp32-c2 xiao destroyed using serial1

sjorsvanrijn
Posts: 4
Joined: Thu Dec 28, 2023 8:51 pm

esp32-c3 super mini and esp32-c2 xiao destroyed using serial1

Postby sjorsvanrijn » 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>
  1. </s>
  2. /* test gps connect to uart rx1<br/>
  3.  * <br/>
  4.  * te doen :  * checksum nmea aftesten<br/>
  5.  * <br/>
  6.  * sd card en st7739 kunnen beide op dezelfde hw spi poort :<br/>
  7.  * mosi miso clk van sd en st7739 aan dezelfde pinnen van esp32c3<br/>
  8. */<br/>
  9. <br/>
  10. #include <SD.h><br/>
  11. #include <SPI.h><br/>
  12. File myFile;<br/>
  13. <br/>
  14. #include <ESP32Time.h><br/>
  15. //ESP32Time rtc(3600);  // offset in seconds GMT+1<br/>
  16. ESP32Time rtc(0);  // offset in seconds GMT<br/>
  17. <br/>
  18. // include library en instantieer --------------------------------------------<br/>
  19. #include <TFT_eSPI.h><br/>
  20. TFT_eSPI tft = TFT_eSPI();<br/>
  21. <br/>
  22. // serial port used rx0 tx0 pin 20 21<br/>
  23. #define GpsSerial Serial1  //NB Serial1 vernietigt de esp32c3 !!!!!!!!!!!!!!!!!<br/>
  24. <br/>
  25. <br/>
  26. // globale variabelen ------------------------------------------------<br/>
  27. const byte led0blauw = 0;<br/>
  28. const byte led2rood = 2;<br/>
  29. const byte led3geel = 3;<br/>
  30. const byte led8 = 8;<br/>
  31. const byte pin1 = 1;<br/>
  32. uint16_t ReadcharCounter;<br/>
  33. char   Readchar[1000];<br/>
  34. volatile byte TimerHit;<br/>
  35. String Readstr;<br/>
  36. String NMEAstrSplit[3][50]; //rmc = 0, gsv = 1, gga = 2<br/>
  37. char   FolderFileNamesSet;<br/>
  38. //const  int SDChipSelect = 7; //sd card<br/>
  39. char   FileNamechar[13];<br/>
  40. char   FolderNamechar[9];<br/>
  41. char   FolderFileNamechar[23];<br/>
  42. String FileNamestr;<br/>
  43. String FolderNamestr;<br/>
  44. String FolderFileNamestr;<br/>
  45. <br/>
  46. uint32_t starttime, endtime;<br/>
  47. byte   UseFont;<br/>
  48. char   str[80];<br/>
  49. String strhlp;<br/>
  50. byte   cardok;<br/>
  51. <br/>
  52. uint32_t StartMillis;<br/>
  53. uint32_t TimerValue;<br/>
  54. bool TimerIsRunning;<br/>
  55. <br/>
  56. <br/>
  57. // setup ---start objects en andere-----------------------------------------------------------<br/>
  58. <br/>
  59. void setup() {<br/>
  60.   // init variables<br/>
  61.   pinMode(pin1, OUTPUT); <br/>
  62.   digitalWrite(pin1,HIGH);<br/>
  63.   pinMode(led0blauw, OUTPUT);<br/>
  64.   digitalWrite(led0blauw,LOW);<br/>
  65.   pinMode(led2rood, OUTPUT);<br/>
  66.   digitalWrite(led2rood,LOW);<br/>
  67.   pinMode(led3geel, OUTPUT);<br/>
  68.   digitalWrite(led3geel,LOW);<br/>
  69.   pinMode(led8, OUTPUT);<br/>
  70.   digitalWrite(led8,HIGH);<br/>
  71. <br/>
  72.   ReadcharCounter = 0;<br/>
  73.   TimerHit = 0;<br/>
  74.   FolderFileNamesSet = 'N';<br/>
  75. <br/>
  76.   // blink<br/>
  77.   for (int i=0; i<5 ; i++) {<br/>
  78.     digitalWrite(led8, LOW);<br/>
  79.     delay(100);<br/>
  80.     digitalWrite(led8, HIGH);<br/>
  81.     delay(500);<br/>
  82.   }<br/>
  83.   <br/>
  84.   // serial monitor<br/>
  85.   Serial.begin(115200);<br/>
  86.   delay(2000);<br/>
  87. //  while (!Serial) { // wait for serial port to connect.<br/>
  88. //  }<br/>
  89. <br/>
  90.   Serial.println("started");<br/>
  91. <br/>
  92. <br/>
  93.   // display ST7739<br/>
  94.   tft.init(); // tft.begin(); zijn hetzelfde<br/>
  95.   tft.setRotation(0);<br/>
  96.   tft.fillScreen(TFT_DARKBLUE);<br/>
  97.   tft.setTextColor(TFT_YELLOW, TFT_DARKBLUE);<br/>
  98.   tft.setTextSize(1);<br/>
  99.   //tft.setTextWrap(false, true); //werkt niet met drawstring<br/>
  100.   UseFont = 4;<br/>
  101. <br/>
  102.   // serial 1 gps start met 9600 en veranderen naar 19200 baud; de zwarte gps modules slaan niets op dus telkens opnieuw zetten<br/>
  103.   GpsSerial.begin(9600);<br/>
  104.   GpsSerial.println("$PUBX,41,1,0007,0003,19200,0*25");<br/>
  105.   delay(2000);<br/>
  106.   GpsSerial.end();  <br/>
  107.   GpsSerial.begin(19200);<br/>
  108. <br/>
  109. }<br/>
  110. <br/>
  111. // loop ---------------------------------------------------------------<br/>
  112. <br/>
  113. void loop() {<br/>
  114.   CheckTimer();<br/>
  115.   if (TimerHit == 1) {<br/>
  116.     starttime = millis();<br/>
  117.     DisplayData(); //in de vorm van de gelezen string<br/>
  118.     <br/>
  119.     ReadcharCounter = 0;<br/>
  120.     TimerHit = 0;<br/>
  121.     endtime = millis();<br/>
  122. <br/>
  123.     sprintf(str, "%03d ", endtime - starttime);<br/>
  124.     tft.drawString(str, 198, 168, UseFont);  <br/>
  125.   } // end if(TimerHit = 1)<br/>
  126.       <br/>
  127.   if (GpsSerial.available() > 0) {<br/>
  128.   //  t1.trigger(5'000); // 5ms<br/>
  129.     digitalWrite(led0blauw,HIGH);<br/>
  130.     StartTimer(100);<br/>
  131.     byte Incomingbyte = GpsSerial.read();<br/>
  132.     if (isAscii(Incomingbyte)) {<br/>
  133.       Readchar[ReadcharCounter] = Incomingbyte;<br/>
  134.       ReadcharCounter++ ; //nog te doen : limiteer tot 999, array is 1000 chars<br/>
  135.     }<br/>
  136.     digitalWrite(led0blauw,LOW);<br/>
  137.   } // end gpsserial.available<br/>
  138.   <br/>
  139. } // end loop<br/>
  140. <br/>
  141. // overige functies ----------------------------------------------<br/>
  142. <br/>
  143. void StartTimer(uint16_t TimerValueParm) {<br/>
  144.   TimerValue = TimerValueParm;<br/>
  145.   TimerIsRunning = true;<br/>
  146.   StartMillis = millis();<br/>
  147. }<br/>
  148. <br/>
  149. void CheckTimer() {<br/>
  150.   if (TimerIsRunning) {<br/>
  151.     if ((millis() - StartMillis) >= TimerValue) {<br/>
  152.       TimerHit = 1;<br/>
  153.       //Serial.print("noofbytesread=");Serial.println(ReadcharCounter);<br/>
  154.       TimerIsRunning = false;<br/>
  155.     }<br/>
  156.   }<br/>
  157. }<br/>
  158. <br/>
  159. void DisplayData() {<br/>
  160.   Serial.print("no bytes read:"); Serial.println(ReadcharCounter);<br/>
  161.   Serial.println("------Readchar start");<br/>
  162.   for (int i = 0; i < ReadcharCounter; i++) {<br/>
  163.     Serial.print(Readchar[i]);<br/>
  164.   }<br/>
  165.   Serial.println();<br/>
  166.   Serial.println("------Readchar end");<br/>
  167. // tft.setCursor(0, 120); tft.print(Readstr);<br/>
  168. }<br/>
  169. <br/>
  170.  
  171. <e>
</e></CODEBOX></r>

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

Re: esp32-c3 super mini and esp32-c2 xiao destroyed using serial1

Postby ESP_Sprite » Fri Dec 29, 2023 9:16 am

I doubt the boards are destroyed; it's likely that the Serial1 instantiation somehow used GPIO18 and/or GPIO19, which reconfigures the USB port to something else, meaning you can't connect to it anymore as soon as the firmware runs. You can always get it into download mode by holding the BOOT button and then pressing the RESET button; the board should show up again and you should be able to program it.

sjorsvanrijn
Posts: 4
Joined: Thu Dec 28, 2023 8:51 pm

Re: esp32-c3 super mini and esp32-c2 xiao destroyed using serial1

Postby sjorsvanrijn » Sat Dec 30, 2023 11:56 am

Hi thanks for response, I will give it a try and let the result know.

sjorsvanrijn
Posts: 4
Joined: Thu Dec 28, 2023 8:51 pm

Re: esp32-c3 super mini and esp32-c2 xiao destroyed using serial1

Postby sjorsvanrijn » Sat Dec 30, 2023 12:17 pm

Hi, it loaded the program using Serial1, it loaded and ran and next windows did not recognise the device anymore.
I holded down boot, pressed reset and could load snother program again.

Thanks for the answer.
Best regards.

Who is online

Users browsing this forum: No registered users and 123 guests