Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CH32x033F8P6 How to use multiple serial ports #159

Open
vuhazu opened this issue Oct 13, 2024 · 6 comments
Open

CH32x033F8P6 How to use multiple serial ports #159

vuhazu opened this issue Oct 13, 2024 · 6 comments

Comments

@vuhazu
Copy link

vuhazu commented Oct 13, 2024

i redefined serial pin ( PA10, PA11 )
it works, but can't use Serial2 or Serial3

// UART Definitions
#ifndef SERIAL_UART_INSTANCE
#define SERIAL_UART_INSTANCE 1
#endif
// Default pin used for generic 'Serial' instance
// Mandatory for Firmata
#ifndef PIN_SERIAL_RX
#define PIN_SERIAL_RX PA11
#endif
#ifndef PIN_SERIAL_TX
#define PIN_SERIAL_TX PA10
#endif

@maxint-rd
Copy link
Contributor

Interesting!

In the past days I've been testing my CH32X033F8P6 chips. I made a new variant within the CH32X035 board to improve use of digitalWrite, analogWrite and analogRead. (intend to make that a PR sometime soon).

I tested Serial only on pins PA2/PA3 by setting PIN_SERIAL_RX and PIN_SERIAL_TX near line 113 in the file variant_CH32X033F8P6 .h, deep down the /variants folder. A few lines higher there is a definition for SERIAL_UART_INSTANCE. It is set to 1. I have not dived into that yet, but maybe that definition affects the available serial ports or perhaps only the active port. I've seen that the V203 QT PY sets SERIAL_UART_INSTANCE to 2...

BTW. My PR #145 for interrupt driven Serial1 (with available() peek() and improved read()) was developed for the V003, but other people confirmed it working on several others, including the X035. I haven't tested that functionality on the X033 yet (currently testing EEPROM emulation). However, that PR only affects Serial1.

@vuhazu
Copy link
Author

vuhazu commented Oct 14, 2024

Interesting!

In the past days I've been testing my CH32X033F8P6 chips. I made a new variant within the CH32X035 board to improve use of digitalWrite, analogWrite and analogRead. (intend to make that a PR sometime soon).

I tested Serial only on pins PA2/PA3 by setting PIN_SERIAL_RX and PIN_SERIAL_TX near line 113 in the file variant_CH32X033F8P6 .h, deep down the /variants folder. A few lines higher there is a definition for SERIAL_UART_INSTANCE. It is set to 1. I have not dived into that yet, but maybe that definition affects the available serial ports or perhaps only the active port. I've seen that the V203 QT PY sets SERIAL_UART_INSTANCE to 2...

BTW. My PR #145 for interrupt driven Serial1 (with available() peek() and improved read()) was developed for the V003, but other people confirmed it working on several others, including the X035. I haven't tested that functionality on the X033 yet (currently testing EEPROM emulation). However, that PR only affects Serial1.

i modified the CH32x035 file to use for CH32x033
can you share the variant file for CH32x033F8P6?

@maxint-rd
Copy link
Contributor

i modified the CH32x035 file to use for CH32x033 can you share the variant file for CH32x033F8P6?

Yes I will. Let me do some cleanup and then I'll submit a PR that you can test. I modified multiple files, also to have logical numeric pin numbering and have working PWM and ADC on most pins. (I shall post a link here when ready)

@maxint-rd
Copy link
Contributor

FYI I've uploaded a first version of my CH32X033F8P6 variant files in this branch. It may need some more cleanup here and there...

@vuhazu
Copy link
Author

vuhazu commented Oct 15, 2024

FYI I've uploaded a first version of my CH32X033F8P6 variant files in this branch. It may need some more cleanup here and there...

yes i will try it and will let you know.

@maxint-rd
Copy link
Contributor

Okay. Next to the variant files I changed boards.txt and added a chip specific readme. Have fun!

(As soon as I find some more time, I want to test out the serial stuff this issue actually is about...)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants