CH32V003-J4M6 understanding pins as per datasheet - Page 1
Forum section: electronics / beginners

author: sairfan1
author_rank: Frequent Contributor
timestamp: August 15, 2025, 07:54:38 pm
content: I was looking at datasheet of MCU CH32V003 J4M6 at page 12 (datasheet attached) please refer to attached image cropped from datasheetif we see pin1 it has PD1 and PA1 so two different io pins are labled to same physical pin.Refer to pin 8, it has PD4, PD5 and PD1 assigned to it.I wanted to understand how it actually works in the code, as per pin label can we use all those function ie. on pin8?or its something i can write code for any of these internal pin ie. PD4, PD5 and PD1 and then physical Pin8 will act accordingly

author: ataradov
author_rank: Super Contributor
timestamp: August 15, 2025, 08:47:45 pm
content: They are just double or triple bonded pads. Normally pins would be configured as inputs, so it is fine to connect multiple of them together. You pick the one you want to use as an output and leave the rest as inputs. There is nothing special you need to do in the code, just pick the way you want to use this pin and ignore the remaining mappings.And in some scenarios you can take advantage of this internal shorting.

author: Nominal Animal
author_rank: Super Contributor
timestamp: August 16, 2025, 09:47:57 am
content: Like ataradov wrote, you can use any and all functions among the bonded pins, but at most one of them should be an output at the same time. You can have all as inputs, or all but one inputs and one as output. But never two or more as outputs at the same time — and that includes peripherals — or you risk breaking the CH32V003!For example, if you set both PD4 and PD5 as GPIO outputs, with say PD4 low and PD5 high, you'll essentially have the two outputs fighting each other with no current limiting, which most likely burns out one or both pins (or more!), because they're essentially trying to short VCC to GND. Even if you carefully keep the outputs in sync, e.g. PD6 and PA1 are in different banks, so just cannot be switched simultaneously.One practical multiple-use case with CH32V003-J4M6 is to use USART default configuration, where PD5 is TX (bonded to pin 8) and PD6 is RX (bonded to pin 1). Additionally, you can set PA1 as an analog input, to use the ADC to check the actual voltage on the RX pin; and PD4 as an analog pin, to use the ADC to check the actual voltage on the TX pin. You will need to set PD1 as a GPIO input (or analog input external trigger for ADC injection group, if you wanted to sample the shape of the TX signal on a falling edge), because TX is already an output, and you don't want to have PD4 and PD1 fight each other burning out the pin.When changing any of the bonded pins' functionality, always set the pin that was an output, if any, as an input first, before changing any of the others' function. This is for the same reason: so that the pin output driver transistors don't try to fight each other.Note that CH32V003 (and other CH32V- and CH32X03-series microcontrollers) select pin functions by selecting a peripheral configuration. Per pin, you can only select between analog input, digital input (without pull-ups or -downs, "floating", digital output ("push-pull", or open drain that can only pull the output low), or peripheral ("multiplexed" output, either push-pull or open-drain). The actual peripheral pin use is determined by peripheral configuration, not by per-pin, as is more common on other microcontrollers. This does make it somewhat harder to decide which pins are used for what, especially when you only have 6 I/O pins like on the CH32V003-J4M6.