openwch / arduino_core_ch32

Core library for CH32duino
252 stars 42 forks source link

Serial.available() does not work on CH32x035 #142

Open joraguero opened 2 weeks ago

joraguero commented 2 weeks ago

Hi everyone, when I call Serial.available() to see if there is any data in the reception buffer, it always returns -1.

maxint-rd commented 2 weeks ago

Hi, this is because it hasn't been implemented (yet).

For my CH32V003 projects I've implemented interrupt driven Serial1. Because I only have the v003 I couldn't test any other CH32 chips. Perhaps you want to test this? My changes add support for available() and peek() and improve read(0 by adding a buffer to avoid loosing bytes when doing other stuff.

To test it shoukd be sufficient to replace these two files:

Would be nice if it also works for the CH32x035, but I have not examined that, so no guarantees....

vuhazu commented 2 weeks ago

Hi, this is because it hasn't been implemented (yet).

For my CH32V003 projects I've implemented interrupt driven Serial1. Because I only have the v003 I couldn't test any other CH32 chips. Perhaps you want to test this? My changes add support for available() and peek() and improve read(0 by adding a buffer to avoid loosing bytes when doing other stuff.

To test it shoukd be sufficient to replace these two files:

  • cores/arduino/HardwareSerial.h
  • cores/arduino/HardwareSerial.cpp

Would be nice if it also works for the CH32x035, but I have not examined that, so no guarantees....

it works for CH32x035, I'm tested

maxint-rd commented 2 weeks ago

Good to read that CH32x035 works too. A moment ago I submitted PR #145 to add working Serial.available(), Serial.peek() and improve Serial.read(). Would be nice if that PR could also be tested for other CH32 chips.

atollminsk commented 1 week ago

Hi, this is because it hasn't been implemented (yet). For my CH32V003 projects I've implemented interrupt driven Serial1. Because I only have the v003 I couldn't test any other CH32 chips. Perhaps you want to test this? My changes add support for available() and peek() and improve read(0 by adding a buffer to avoid loosing bytes when doing other stuff. To test it shoukd be sufficient to replace these two files:

  • cores/arduino/HardwareSerial.h
  • cores/arduino/HardwareSerial.cpp

Would be nice if it also works for the CH32x035, but I have not examined that, so no guarantees....

it works for CH32x035, I'm tested

Hi, this is because it hasn't been implemented (yet).

For my CH32V003 projects I've implemented interrupt driven Serial1. Because I only have the v003 I couldn't test any other CH32 chips. Perhaps you want to test this? My changes add support for available() and peek() and improve read(0 by adding a buffer to avoid loosing bytes when doing other stuff.

To test it shoukd be sufficient to replace these two files:

  • cores/arduino/HardwareSerial.h
  • cores/arduino/HardwareSerial.cpp

Would be nice if it also works for the CH32x035, but I have not examined that, so no guarantees....

its work for CH32V208WB. tested.

maxint-rd commented 1 week ago

@atollminsk - Excellent. Thank you for testing.

atollminsk commented 1 day ago

Hi, this is because it hasn't been implemented (yet).

For my CH32V003 projects I've implemented interrupt driven Serial1. Because I only have the v003 I couldn't test any other CH32 chips. Perhaps you want to test this? My changes add support for available() and peek() and improve read(0 by adding a buffer to avoid loosing bytes when doing other stuff.

To test it shoukd be sufficient to replace these two files:

  • cores/arduino/HardwareSerial.h
  • cores/arduino/HardwareSerial.cpp

Would be nice if it also works for the CH32x035, but I have not examined that, so no guarantees....

I checked today with CH32V203C8T6 - it works. CH32V307VCT6 - it doesn't work.

maxint-rd commented 1 day ago

@atollminsk - thank you for your additional testing. Unfortunately I don't have a CH32V307VCT6 so I cannot do further analysis/debugging.

atollminsk commented 13 hours ago

I found the problem, the reason for not working with CH32V307 - I used the command pinMode(x, OUTPUT). With other controllers, the same code worked. I use pinMode(x, OUTPUT_OD). Mismatch pin map of real electrical circuit. EVT 307VCT6

maxint-rd commented 10 hours ago

@atollminsk - Hmm... So you have tested it working now? I'm not quite sure what you meant by "Mismatch pin map". Do you mean you used pinMode on the pin you also used for Serial? Or was it an unrelated pin that had an effect on serial communication. (I'm not quite familiar with the pinout of the CH32V307).

atollminsk commented 10 hours ago

@maxint-rd Yes, i used to pinMode pin also for Serial. working with CH32V307)