Closed ITstreet1 closed 1 year ago
SERIAL0_RX == PIN_WIRE_SDA shouldn't have happened. The problem is that all of these variant.h files are autogenerated by a script, gd32_genpinmap, and this script doesn't have a very sophisticated "pin allocator" to make sure there isn't a double-usage of a pin in two popular peripherals. It just has a "prefered" pin, and if that pin doesn't exist, it goes to the next preferred pin.
As a result of that, definitions like that can happen.
You're free to change the pins to whatever you want -- in limits with the peripheral, of course.
For I2C
For UART
Hah, I actually have to correct myself here. According to that, the only possibility for "Wire", mapping to I2C0
, really is PA9, PA10. Same as for USART0!
So, in the application, don't use Serial
and Wire
at the same time -- but you can use e.g. Serial
and Wire1
, or Serial1
and Wire
, since they're on different pins (mix+match of USART0, USART1, I2C0, I2C1).
Unfortunately I think if you design the hardware with a I2C device on the I2C0 pins (same as USART0 pins), then uploading firmware in the BOOT0 mode will fail, the I2C devices will react to edges of the UART RX and TX signal and screw with the signal, trying to pull it LOW various times.
From what I have seen, the same goes for most TSSOP20 chips.
I2C needs a pull-up. Yes, I see the problem. Maybe separate the I2C lines with a jumper? This way I can upload a sketch, then solder the I2C jumper and connect the lines...
I think you can use a double-throw, double-pole switch where, if the switch is UP, then PA9, PA10 lines are connected to the I2C devices, and if DOWN, they are disconnected (or connected to some UART pin headers). That way it's atleast easily switchable.
Space is the problem. Three-pad solder joint will do the same job. The same one I use as a BOOT selector. Besides, I shouldn't leave an option for a user to mess it up. :)
I see.
I think we then can we conclude the the definitions are okay for Serial and Wire because they're really the only pin choices for USART0 and I2C0? Users can still use Serial
, Serial1
, Wire
, Wire1
as needed to mix-match. Connecting the pins to different devices or headers is a hardware problem and can't be solved in this Arduino core.
Heh,
On GitHub, there is a support for this chip. It clearly says in variants. But, in Arduino IDE, there is none. Version I have installed is 0.0.1
How to add support for this one chip?
Arduino IDE 2.x or 1.x?
1.8.19
F330F8 does exist as a variant here and is referenced in the boards.txt
.
Are you sure you're using https://raw.githubusercontent.com/CommunityGD32Cores/GD32Core-New/main/package_gd32_index.json
as the package URL? If you have an older version of tis core previously installed, you need to uninstall + reinstall it in the Arduino IDE boards manager.
LOL. This did the trick. I just reinstalled it. I still get the 0.0.1 version, but this time with all the boards in the list.
Thank you.
We don't version the core yet, so it's been "0.0.1" forever -- a reinstall however will always install the latest version this git repository.
I believe it should have versions. I didn't get the update option to a newer version, so I didn't know what to do. I thought I have the newest version, and thought it was some kind of a bug.
Thank you anyway, and thank you for your effort.
This IC uses PA9 and PA10 as a UART RX and TX. But at the same time, they are the I2C0 pins. https://github.com/CommunityGD32Cores/ArduinoCore-GD32/blob/main/variants/GD32F330F8_GENERIC/variant.h
I wonder if can I use these pins as an I2C no matter if I use them for uploading the sketch in BOOT mode? My guess is it does not matter as long as I don't use them in Serial communication while in working mode. If so, do I need some specific design, or I just connect the I2C device to those pins, put it in BOOT mode, upload the sketch, exit the BOOT mode, and let it live its life?