I tried the sketch on the GD32 and I tried pulling each pin to GND, individually and it was fine.
The strange thing however is that to read PA0 (pin 0) I have to connect GND to PA7, and pin 1 is PA0 pin 2 is PA1 etc, i.e its all shifted down by own.
I've looked in the PIN MAP and the ADC channel number is being defined correctly i.e Channel 0 is PA0, but this is not what the code is reading.
I've not tried this on a red pill to see if it has the same effect, or even on a Maple Mini by addressing the pin by its STM32 name i.e PA0
The code that reads the ADC is quite straight forward
Code: Select all
adc_reg_map *regs = dev->regs;
regs->SQR3 = channel;
regs->CR2 |= ADC_CR2_SWSTART;
while (!(regs->SR & ADC_SR_EOC))
return (uint16)(regs->DR & ADC_DR_DATA);
i.e it puts the channel number in register SQR3 and it doesn't appear to be masked or shifted etc
Anyway, I've just managed to locate the GD32 programming manual from here
http://qd2.cache.baidupcs.com/file/a4d6 ... llid=0.1.1
And I can't see ant difference between the STM32 register layout and the GD32 layout.
So I'm not sure why I'm seeing the PIN shifted along by one