Author Topic: Improved performance 5V Arduino Nano/Mega compatible  (Read 12153 times)

0 Members and 2 Guests are viewing this topic.

Online pcprogrammer

  • Super Contributor
  • ***
  • Posts: 3917
  • Country: nl
Re: Improved performance 5V Arduino Nano/Mega compatible
« Reply #100 on: March 09, 2023, 09:37:04 am »
Oh, wow, well good to hear you are recovering.

Damn, already forgot the setup of the boot process with this one. If I recall correctly it does not have the external select pins and a build in boot rom, so yeah SWD will be the way to go. I doubt that Nuvoton loads them with a bootloader, but since you have a bunch of them you will find out once you solder them to a board.

As I'm not really interested in using Arduino for this I'm not volunteering, sorry.

Happy to do work on schematic and pcb though.

Online bingo600

  • Super Contributor
  • ***
  • Posts: 2002
  • Country: dk
Re: Improved performance 5V Arduino Nano/Mega compatible
« Reply #101 on: March 10, 2023, 04:30:34 pm »
I just got 4 x CH32F103 boards (Dual USB-C) from Ali , "Blinky" & USB "Hello world works fine" (Linux).
Next ... Rip out the 3v3 regulator and run 5v   ;D

/Bingo
 

Offline DC1MCTopic starter

  • Super Contributor
  • ***
  • Posts: 1882
  • Country: de
Re: Improved performance 5V Arduino Nano/Mega compatible
« Reply #102 on: March 10, 2023, 05:45:01 pm »
I just got 4 x CH32F103 boards (Dual USB-C) from Ali , "Blinky" & USB "Hello world works fine" (Linux).
Next ... Rip out the 3v3 regulator and run 5v   ;D

/Bingo

Uhmmm... OK, say, how is this relevant to the topic ?
 

Online bingo600

  • Super Contributor
  • ***
  • Posts: 2002
  • Country: dk
Re: Improved performance 5V Arduino Nano/Mega compatible
« Reply #103 on: March 10, 2023, 08:24:23 pm »
I just got 4 x CH32F103 boards (Dual USB-C) from Ali , "Blinky" & USB "Hello world works fine" (Linux).
Next ... Rip out the 3v3 regulator and run 5v   ;D

/Bingo

Uhmmm... OK, say, how is this relevant to the topic ?

Well
They were mentioned several times above, and according to the DS they can run 5v , and they can run "Arduino".
I thought it would be nice for the forum to know if they could run 5v wo. letting the magic smoke out.

Why so grumpy M  :-\

/Bingo
« Last Edit: March 10, 2023, 08:36:46 pm by bingo600 »
 

Offline DC1MCTopic starter

  • Super Contributor
  • ***
  • Posts: 1882
  • Country: de
Re: Improved performance 5V Arduino Nano/Mega compatible
« Reply #104 on: March 11, 2023, 05:46:36 am »
I just got 4 x CH32F103 boards (Dual USB-C) from Ali , "Blinky" & USB "Hello world works fine" (Linux).
Next ... Rip out the 3v3 regulator and run 5v   ;D

/Bingo

Uhmmm... OK, say, how is this relevant to the topic ?

Well
They were mentioned several times above, and according to the DS they can run 5v , and they can run "Arduino".
I thought it would be nice for the forum to know if they could run 5v wo. letting the magic smoke out.

Why so grumpy M  :-\

/Bingo

'cause I'm a grumpy old man, be merciful ;), btw, if you run these guys at 5V and use USB, it seems to need a "magic" register to be set.
In the end, I do apologize because your post was looking like some previous posts "hey, I've got some RISC-V totally unrelated stuff...", kindly please let us know how good are they working at 5V, including the USB part (if you can measure some voltages on the USB side and see if they're in spec, that will be great).
And finally do try to programmatically bit-bang an I/O (or more) as fast as possible at 5V and scope it (eventually with a bit of load) to see how it looks like. That will be indeed helpful and it will strongly attenuate my grumpiness  ^-^

 Cheers,
 DC1MC
 

Online bingo600

  • Super Contributor
  • ***
  • Posts: 2002
  • Country: dk
Re: Improved performance 5V Arduino Nano/Mega compatible
« Reply #105 on: March 11, 2023, 06:38:02 am »
if you run these guys at 5V and use USB, it seems to need a "magic" register to be set.
Yupp saw that  ....

I would also love to get a "Trustworthy" schematic of that board ...
I see several versions out there ...
Well my POI is especially the USB C connection to the regulator and/or MCU.


The RM (Ressource Manual) has me a bit "worried" as it states that the USB5VSEL will be set to 1 , if the system is powered by 5v.
I'm a bit afraid if this is a "translation error" .... Does that chip really have a 3v3/5v detection , and set USB5VSEL automatically ??
Or is it a translation error where "will be set" should have been "must be set" ??

I guess i'll have to connect it via Serial and read that bit a few times , using 3v3 & 5v VCC.


kindly please let us know how good are they working at 5V, including the USB part (if you can measure some voltages on the USB side and see if they're in spec, that will be great).
And finally do try to programmatically bit-bang an I/O (or more) as fast as possible at 5V and scope it (eventually with a bit of load) to see how it looks like. That will be indeed helpful and it will strongly attenuate my grumpiness  ^-^
Will do , but might take a week or two.

/Bingo
« Last Edit: March 11, 2023, 06:42:39 am by bingo600 »
 

Online bingo600

  • Super Contributor
  • ***
  • Posts: 2002
  • Country: dk
Re: Improved performance 5V Arduino Nano/Mega compatible
« Reply #106 on: March 17, 2023, 12:27:04 pm »
Well i just made m first 5v run on the CH32F103 board.

I removed:
R10 - USB Pullup Resistor , that goes to VCC 
U1  - 3v3 Regulator   - Didn't survice the pin lifting ... I did the surgery after soldering pins on the board, leaves very little working (solder) space.

Hotglued a MIC2920-3v3 to some Kapton on the back, for the "Orange 3v3 wire".
Fed the 2920 from the 5v Ceramic (C5) and soldered the "Red 5v wire to the cap to"  - Yes i see the pointy solder blop on C5 plus side....


I then connected a 3v3/5v switchable usb-ttl adapter to usart1 , and made a program using the CH32F103 StdPeriph lib - They had a program that could detect if you run 3v3 or 5v on VCC.
Rewrote the serial output rotine , and printed the below stuff...

As you can see the MCU does NOT automatically set the EXTEN-->USB5V bit in the register , despite the RM saying so ... (I suspect xlate error)

Code: [Select]
SystemClk:72000000
Exten Reg:0x00000200
USB5V Flag :0x00000000
ADC Value: 961
5V
SystemClk:72000000
Exten Reg:0x00000200
USB5V Flag :0x00000000
ADC Value: 962
5V
SystemClk:72000000
Exten Reg:0x00000200
USB5V Flag :0x00000000
ADC Value: 963
5V
SystemClk:72000000
Exten Reg:0x00000200
USB5V Flag :0x00000000
ADC Value: 962
5V
SystemClk:72000000
Exten Reg:0x00000200
USB5V Flag :0x00000000
ADC Value: 963
5V
SystemClk:72000000
Exten Reg:0x00000200
USB5V Flag :0x00000000
ADC Value: 959
5V


USB has not yet been tested on VCC 5v.

I have tested it on VCC 3v3 , using standard STM32duino.
I had to do one mod though ... After removing R10 USB wouldn't be reckognized by Laptop (missing 1k5 USB+ pullup) - But you can enable the builtin USB Pullup in the EXTEN register.
VCC 3v3 still works fine w. STM32duino, after enabling the builtin pullup.

Next ....

Connect an old USB HUB to the Laptop (Laptop USB port saver) - Connect ARM to HUB
Set VCC 3v3
Measure USB Data+ levels on 3v3
Do some port toggling wo. load , and w 1K load.

Switch to 5v
Set USB5V-bit in EXTEN
Repeat above measurements.

Then:
It would be nice to autodetect 3v3 vs 5v , and set the USB5V-bit on startup , before enabling the USB periph.

So ...
Convert the attached CH32F103 Main.c to STM32 register & lib naming, so it can be used w. STM32Duino.
The MCU might be compatible , but the STDPeriph naming is not ... It won't build in STM32Duino.

Edit:
The CH32F103 - Has a weird "encrypted"   :-- USB programming protocol, that has already been hacked 

Programming MCU
USB
Use isp55e0 -f Main.bin  - https://github.com/frank-zago/isp55e0         (udev script also in there ...)  - USE Lower/Bottom USB plug
Watch out when on VCC 5v - Since the chip didn't set the USB5V flag, chances are that the bottom USB in "Boot0" mode will not either ..... And you have no programming control in "Boot0" mode.

SWD
I haven't tried it yet, but if VCC 5v - Then it might blow your ST-Link clone unless the ST-Link pins used are 5v tolerant.
DON'T connect USB & SWD VCC pin at the same time - You will have dual PSU's figthing or blow the SWD thingy if running 5v on the CH32


Edit2:
Arduino replacement ... depends ...

The MCU has a Max powerusage of 50mA ob VCC & GND pins.
And a pindrive of ??? - 5..8mA  - Though they mention 20mA w relaxed timing ... But remember the 50mA total usage.

I suppose it might be somewhat the same as a "Bluepill, haven't checkked though.


Bought mine on ALI for $2.6 - USB-C version
https://www.aliexpress.com/item/1005001936761405.html

Make sure to get the "DUAL USB PLUG" version, no matter where you get it.
TOP USB = Normal USB (STM compatible) - Works w STM32duino
BTM USB = USB Boot0 ISP + USB HOST (ST Doesn't have that one)

I ordered 4 , and one is missing the top usb-c plug , the other 3 are fine.
I have decided not to complain, what would i want in compensation ..... ?
I got the board in a closed static bag from seller , must be a factory error.


/Bingo
« Last Edit: March 17, 2023, 01:24:24 pm by bingo600 »
 
The following users thanked this post: DC1MC

Offline DC1MCTopic starter

  • Super Contributor
  • ***
  • Posts: 1882
  • Country: de
Re: Improved performance 5V Arduino Nano/Mega compatible
« Reply #107 on: March 17, 2023, 04:29:37 pm »
@bingo600 . now do the tightest loop ever and show us what a 5V capable pin is capable of doing  ;D
 

Online bingo600

  • Super Contributor
  • ***
  • Posts: 2002
  • Country: dk
Re: Improved performance 5V Arduino Nano/Mega compatible
« Reply #108 on: March 17, 2023, 04:50:16 pm »
Will do in a short while

Just ran a STM32duino test on 5v , w. usb output

Code: [Select]

[b]PRE-Exten Reg:0x00000200[/b]

[b]Exten Reg:0x0000020a[/b]

USBPU Flag :0x00000002
USB5V Flag :0x00000008
Hello loop = 54
**** EXTEN ***
PRE-Exten Reg:0x00000200

Exten Reg:0x0000020a

USBPU Flag :0x00000002
USB5V Flag :0x00000008
Hello loop = 55
**** EXTEN ***
PRE-Exten Reg:0x00000200

Exten Reg:0x0000020a

USBPU Flag :0x00000002
USB5V Flag :0x00000008


Important part ...
Pre exten = EXTEN register at boot
Exten = Exten register after running my modified (own added)   -
void SystemClock_Config(void) - Routine , that sets USB PU + 5V bits.


So "duino is working on 5v"
And the "Green Blinky LED" is mega bright now ...

/Bingo
 

Online bingo600

  • Super Contributor
  • ***
  • Posts: 2002
  • Country: dk
Re: Improved performance 5V Arduino Nano/Mega compatible
« Reply #109 on: March 17, 2023, 07:37:09 pm »
I just diid a quick

Code: [Select]
     do
      {
        digitalWriteFast(PA_0, HIGH);
        digitalWriteFast(PA_0, LOW);
      } while(1);

And grabbed a scope pict - Some ringing , prob due to the ground clip well ....

Seems like it uses  6 instructions for the "toggle + Loop"

/Bingo



Since DC1MC was pushing so hard for a "Fast blinky" he's prob. going to Absolutely Kill the CH32F103 performance with the Nuvo ....  8)
Well for $2.60 it's still a fun board, that can run 3v3 or 5v

But i might get a few of DC1MC's Nuvo's if they have the same form factor as a Nano3

I have only used a micro subset of the chip, w. STM32duino v 2.4.0.
USB.Serial print & some blinky stuff.
DON'T blame me if there are "quirks" in the ST/CH compatibility  :-//


Seems like i found a "quirk"  - w. input from serial.usb   - output works fine  :-//
Serial(USB) read doesn't work.
And - Ie.  while(!SerialUSB.available()); // Wait for USB Connect 
Hangs ..... Even if i can do serial print fine wo. probs.

/Bingo
« Last Edit: March 18, 2023, 12:20:09 pm by bingo600 »
 
The following users thanked this post: DC1MC

Offline DC1MCTopic starter

  • Super Contributor
  • ***
  • Posts: 1882
  • Country: de
Re: Improved performance 5V Arduino Nano/Mega compatible
« Reply #110 on: March 17, 2023, 07:48:13 pm »
I just diid a quick

Code: [Select]
     do
      {
        digitalWriteFast(PA_0, HIGH);
        digitalWriteFast(PA_0, LOW);
      } while(1);

And grabbed a scope pict - Some ringing , prob due to the ground clip well ....

Seems like it uses  6 instructions for the "toggle + Loop"

/Bingo



Uuuuu, 12MHz and nice flanks, where are the "assembly astronauts"  ::) to optimize this and reach 20MHz :).

Thanks and cheers,
DC1MC
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf