Author Topic: STM32G030 / G031  (Read 7754 times)

0 Members and 2 Guests are viewing this topic.

Offline ag123Topic starter

  • Contributor
  • Posts: 39
  • Country: 00
STM32G030 / G031
« on: July 27, 2023, 07:59:59 am »
ok I'm a bit old school
but that AliX vendors are 'storming' the stores with those chips  ;D

Taking a look at STM32G0 series
https://www.stm32duino.com/viewtopic.php?t=1848


https://www.st.com/en/microcontrollers-microprocessors/stm32g030f6.html

https://www.stm32duino.com/viewtopic.php?p=11661#p11661


 

Offline ag123Topic starter

  • Contributor
  • Posts: 39
  • Country: 00
Re: STM32G030 / G031
« Reply #1 on: July 27, 2023, 08:02:45 am »
https://www.stm32duino.com/viewtopic.php?p=12748#p12748

I noted that in the G030 G031 series
https://www.st.com/en/microcontrollers-microprocessors/stm32g0x0-value-line.html
https://www.st.com/en/microcontrollers-microprocessors/stm32g0x1.html

the G031F8 has got a 20 pin TSSOP  chip that has got 64k flash and 8 k sram, those are 'less featured' among the AliX vendors as I'd guess most of them simply stock the G030F6 being the 'cheapest' possibly.
my guess is G031F8 is probably more suitable for C/C++ style development and is less prone to exhausting the flash program storage too quickly, i.e. can take some 'fat' lol.

one of those things I'm thinking of is try to bit bang usb full speed 12 Mbps. These days those usb 'full speed' transceivers are hard to get some of them marked obselete, e.g. the usb1t11a
https://www.mouser.com/datasheet/2/149/fairchild%20semiconductor_usb1t11a-320893.pdf
https://www.onsemi.com/products/interfaces/wired-transceivers-modems/usb1t11a
they literally cost more than microcontrollers for retail chips alone. I'd guess after all, socs with usb built-in are after all common these days and it 'isn't worth' the trouble patching another chip just to do that.

I'm thinking if I could 'abuse' things like the max3485 which purportedly can do up to 10 Mbps, trying to push 12 Mbps for usb full speed signals
https://www.analog.com/en/products/max3485.html
these are fairly abundant and rather low cost
https://www.aliexpress.com/w/wholesale-max3485.html
the idea is to 'drive' the max3485 at 12 mbps on SPI which seemed quite doable.
then for things like 'single ended zero' - a.k.a 'usb reset' , it'd probably take a transistor or try with a gpio pin to pull both the differential line to zero.

an alternative is to directly bit bang usb on the GPIOs and I kind of stumbled on how to generate the differential signals at the GPIOs, hence, looked at the max3485

there is still some incentive to bit bang usb on these 'no usb' chips as it dramatically expand the use cases, just that the small amount of flash and sram is going to prove to be a challenge.
 

Offline wek

  • Frequent Contributor
  • **
  • Posts: 538
  • Country: sk
Re: STM32G030 / G031
« Reply #2 on: July 27, 2023, 08:35:09 am »
> bit bang usb

Just.... why???

JW
 

Offline ag123Topic starter

  • Contributor
  • Posts: 39
  • Country: 00
Re: STM32G030 / G031
« Reply #3 on: July 27, 2023, 09:05:03 am »
> bit bang usb

Just.... why???

JW
well it doesn't have it (usb)  :-DD
the 'serial port' of today is simply it - usb
« Last Edit: July 27, 2023, 09:07:02 am by ag123 »
 

Offline wek

  • Frequent Contributor
  • **
  • Posts: 538
  • Country: sk
Re: STM32G030 / G031
« Reply #4 on: July 27, 2023, 09:08:49 am »
Yes, and...???

JW
 

Offline ag123Topic starter

  • Contributor
  • Posts: 39
  • Country: 00
Re: STM32G030 / G031
« Reply #5 on: July 27, 2023, 05:58:44 pm »
i played with the notion that MAX3485 is my 'USB transceivier'
https://www.analog.com/en/products/max3485.html
a thing is MAX3485 did not define the state at the receiver if both differential inputs are low, what is only documented is
A,B > +0.2v -> 1
A, B < -0.2v -> 0
inputs open -> 1

i'd risk a guess that if A,B is at GND, the input is  '1'  :P lol
this is needed to detect the 'single ended zero' condition where both differential inputs are low
https://www.beyondlogic.org/usbnutshell/usb2.shtml
https://www.usbmadesimple.co.uk/ums_3.htm
i.e. 'usb reset'

if 'single eided zero' is '1' at the receiver end, i'd guess a way is to probe D+ with gpio that it is after all 0
that would be the host signaling a 'usb reset'

another doubt though is that MAX3485 apparently has some slew rate limiting, filtering, that may have some implications transmitting the signals at 12 mhz and above.

« Last Edit: July 27, 2023, 06:56:28 pm by ag123 »
 

Online DavidAlfa

  • Super Contributor
  • ***
  • Posts: 6280
  • Country: es
Re: STM32G030 / G031
« Reply #6 on: July 27, 2023, 06:27:29 pm »
Why do you need a transceiver for bitbanging USB? Simply toggle the pins?
A 48MHz mcu will not be able to sustain 12Mbps even in your best dreams (Exception: Pi Pico, handling USB with PIO).
So, your only option will be USB 1.0 spec @ 1.5Mbps, at best.

You have several usb projects doing this:
https://github.com/IOsetting/py32f0-template/issues/12
« Last Edit: July 27, 2023, 06:33:24 pm by DavidAlfa »
Hantek DSO2x1x            Drive        FAQ          DON'T BUY HANTEK! (Aka HALF-MADE)
Stm32 Soldering FW      Forum      Github      Donate
 

Offline ag123Topic starter

  • Contributor
  • Posts: 39
  • Country: 00
Re: STM32G030 / G031
« Reply #7 on: July 27, 2023, 07:00:17 pm »
Why do you need a transceiver for bitbanging USB? Simply toggle the pins?
A 48MHz mcu will not be able to sustain 12Mbps even in your best dreams (Exception: Pi Pico, handling USB with PIO).
So, your only option will be USB 1.0 spec @ 1.5Mbps, at best.

You have several usb projects doing this:
https://github.com/IOsetting/py32f0-template/issues/12

a trouble with STM32 is that i've not figure out an 'easy' way to toggle 'complementary' differential signals. the timers can do it but that it isn't quite like transmitting a data stream.
a trouble with usb is that it isn't 'pure differential' as there are additional signals such as 'single ended zero' i.e. both D+ and D- at GND.
so that adds a little more 'complications'


sustaining 12 Mbps with SPI or even higher speeds like 20 Mbps or even higher is feasible. I've tried updating data in a spi flash chip of the Windbond W25Q64BVSIG type SPI flash ram and has been able to do that quite stably at 20 mhz off a stm32f103c8 device.

there is actually an (old) chip that does it well USB1T11A
https://www.onsemi.com/products/interfaces/wired-transceivers-modems/usb1t11a
https://www.onsemi.com/download/data-sheet/pdf/usb1t11a-d.pdf
it is 'made for purpose' - a usb 1.1 full speed transceiver
it perfectly fit the 'SPI' interfacing option.

apparently while this is marked 'obselete', it is apparently still 'widely' in use
https://www.lcsc.com/product-detail/span-style-background-color-ff0-USB-span-ICs_onsemi-USB1T11AMX_C464142.html

it is 'made for purpose', just that in the 'online flea markets' these days
https://www.aliexpress.com/w/wholesale-USB1T11A.html
this 'old chip' practically cost as much as many microcontrollers itself in the 'retail' small quantities markets.

it may still be worth getting though, as practically the large set of the stm32g03x series practically don't have usb, even if some of them have more sram and flash.

another way which is 'common;' is to simply patch a usb-uart chip, e.g. CH340
at 'retail' quantities, a CH340 completely built with a crystal, LDO, usb connector, a 5v, 3v switch, accessories components (smd caps, resistors) + PCB + header soldered can be about 'equal' in price to a single piece of USB1T11A
https://www.aliexpress.com/item/1005004824108230.html
https://www.aliexpress.com/item/1005005272826903.html

but of course with a USB1T11A, one is not limited to 'usb serial', one can practically 'bit bang' any USB protocol e.g. HID and make a keybboard, mouse etc

the other thing is there are probably 'other' chips which bundle a usb function on chip but is probably not in the stm32g03x series.
e.g. stm32f103c8, cost a little more but is probably what it cost to add that usb functionality.
« Last Edit: July 27, 2023, 07:44:43 pm by ag123 »
 

Offline bingo600

  • Super Contributor
  • ***
  • Posts: 2034
  • Country: dk
Re: STM32G030 / G031
« Reply #8 on: July 27, 2023, 07:46:59 pm »
Hello ag123  :)

Why would you bitbang USB ??
I'm quite sure i saw one of the new CHxxx USB->Serial chips, that needed no Xtal.

And i know you have a "bag full" of F411's , from when we did wheatstone tests on the 'duino forum ;)

If you need USB, either get one of the new CHxxx , or use a Fxxx with builtin USB.

/Bingo
 

Offline ag123Topic starter

  • Contributor
  • Posts: 39
  • Country: 00
Re: STM32G030 / G031
« Reply #9 on: July 27, 2023, 07:52:18 pm »
well, stm32g030* is kind of a 'fad of the moment'
many AliX vendors are stocking them
https://www.aliexpress.com/w/wholesale-stm32g030f6p6.html
not surprising as it is after all 'cheap' costing well less than a dollar
is a 'recent' stm32 series
https://www.st.com/en/microcontrollers-microprocessors/stm32g0-series.html
the TSSOP20 chip can be easily soldered on DIP to SOP20 'adapter boards'
sram is 8k flash is 32k for stm32g030f6p6 - decent
then if one goes for the stm32g031F8 that becomes 8k sram and 64k flash
https://www.st.com/en/microcontrollers-microprocessors/stm32g0x1.html
ideal for a 'keyboard'
just that 'no usb'

it takes to go up to the series numbers STM32G0B1K8 128 KB flash and 144 KB sram
https://www.st.com/en/microcontrollers-microprocessors/stm32g0b1kb.html
then you see USB in there. 144 KB sram to do a keyboard? well what a waste of transistors  :-DD

for now the more promising stm32 G* series is the G4 series
a lot of features in a little package
https://www.eevblog.com/forum/microcontrollers/blackpill-stm32g431cbu6-170-mhz-32k-ram-128k-rom-12-bit-adc-and-dac/
but apparently quite different 'use cases' vs the stm32g0 series.
« Last Edit: July 27, 2023, 08:03:28 pm by ag123 »
 

Online DavidAlfa

  • Super Contributor
  • ***
  • Posts: 6280
  • Country: es
Re: STM32G030 / G031
« Reply #10 on: July 27, 2023, 09:17:03 pm »
The problem is not toggling pins at 12MHz, but parsing fast enough, and you must also calculate CRC.
Not all USB is differential, there're states where only one pin changes.

Don't you know how to toggle differential signals in sync?
That's what BSRR allows, setting and resetting any number of pins at once.
Syncing two different SPI peripherals will be much harder (If you have 2 to begin with).
Wasting most mcu resources to make USB makes no sense, you can get actual USB-enabled MCUs for a bit more.
« Last Edit: July 28, 2023, 01:29:22 am by DavidAlfa »
Hantek DSO2x1x            Drive        FAQ          DON'T BUY HANTEK! (Aka HALF-MADE)
Stm32 Soldering FW      Forum      Github      Donate
 

Offline thm_w

  • Super Contributor
  • ***
  • Posts: 7263
  • Country: ca
  • Non-expert
Re: STM32G030 / G031
« Reply #11 on: July 27, 2023, 11:12:36 pm »
the other thing is there are probably 'other' chips which bundle a usb function on chip but is probably not in the stm32g03x series.
e.g. stm32f103c8, cost a little more but is probably what it cost to add that usb functionality.

The STM32F103C6T6A is a few pennies more and includes USB hardware. Unless you are making 10 million devices its not worth it.

You can probably source some F103 clones for sub 60c if you want to as well. Just that they are often not code compatible with the STM32F103 in terms of USB (geehy, gigadevices, etc.).
Profile -> Modify profile -> Look and Layout ->  Don't show users' signatures
 
The following users thanked this post: ag123

Offline Sacodepatatas

  • Regular Contributor
  • *
  • Posts: 105
  • Country: es
Re: STM32G030 / G031
« Reply #12 on: July 27, 2023, 11:58:06 pm »
You can code for the STM32G031F8P6 and then program the flash binary into an STM32G030F6P6 (using the ST-Flash utility with the option "--flash=64k"). They both have the same die and the only difference is that the F6P6 doesn't have F2 connected to the reset line.

You are right. These MCUs are awesome. I purchased 100 STM32G030F6P6 for about 36€, and they all have the hidden flash and undocumented features (128MHz timer, 16bit hardware oversample ADC...).
 
The following users thanked this post: thm_w, DavidAlfa

Offline PCB.Wiz

  • Super Contributor
  • ***
  • Posts: 1955
  • Country: au
Re: STM32G030 / G031
« Reply #13 on: July 28, 2023, 12:21:18 am »
Wasting most mcu resources no make USB makes no sense, you can get actual USB-enabled MCUs for a bit more.

Yes, the USB addition is 'almost free' on new MCUs these days.

lcsc have STC USB MCUs from 27k/1k TSSOP20 64k
 

Online DavidAlfa

  • Super Contributor
  • ***
  • Posts: 6280
  • Country: es
Re: STM32G030 / G031
« Reply #14 on: July 28, 2023, 01:30:39 am »
The STM32F103C6T6A is a few pennies more and includes USB hardware.
Or even the cheaper 101x, which also includes the USB hardware though not officially.
Hantek DSO2x1x            Drive        FAQ          DON'T BUY HANTEK! (Aka HALF-MADE)
Stm32 Soldering FW      Forum      Github      Donate
 
The following users thanked this post: thm_w

Offline langwadt

  • Super Contributor
  • ***
  • Posts: 4781
  • Country: dk
Re: STM32G030 / G031
« Reply #15 on: July 28, 2023, 01:50:19 am »
> bit bang usb

Just.... why???

JW

because then you don't need a usb2serial adapter, and low speed 1.2Mbit is probably plenty what you would do with such a small part
 

Offline ag123Topic starter

  • Contributor
  • Posts: 39
  • Country: 00
Re: STM32G030 / G031
« Reply #16 on: July 28, 2023, 05:10:22 am »
The problem is not toggling pins at 12MHz, but parsing fast enough, and you must also calculate CRC.
Not all USB is differential, there're states where only one pin changes.

Don't you know how to toggle differential signals in sync?
That's what BSRR allows, setting and resetting any number of pins at once.
Syncing two different SPI peripherals will be much harder (If you have 2 to begin with).
Wasting most mcu resources to make USB makes no sense, you can get actual USB-enabled MCUs for a bit more.

BSRR is a good idea and I'd probably try that as an experiment., toggling pins fast can likely be achieved using DMA. Using DMA it is quite likely toggling them at 12 Mhz may be feasible.
Initially I'm thinking of using 'cheap' MAX3485 transceivers to do the job, which according to specs drives up to 10 Mhz, but that the slew rate limiting and filtering is likely to cause signal problems at those Mhz in particular the transmit side.

the idea with SPI is to drive the transceiver the substitute being MAX3485 and the 'real' on is that 'old' chip USB1T11A which is a real usb 1.1 full speed transceiver.
I did some 'thought experiments' and kind of think that driving USB1T11A via SPI and DMA is likely pretty feasible, thereby achieving a full USB 1.1. full speed PHY.
the rest of the 'bit banging' becomes dealing with the protocol stuffing the buffer with USB frames including CRC etc.
I think this is pretty feasible with the stm32g0 or the cortex M0 chips.

Just that USB1T11A  is pretty costly as it is 'infrequently used' costing as much or more than a microcontroller in 'retail quantities'
in fact USB1T11A is deemed 'obsolete', but apparently it is still quite widely used given the availability.

lets just say that we are "stuck" with stm32g0xx (well less that stm32g0b1 which has usb 128k flash 144k sram, sometimes a bit 'overblown' for that sram and extra price)
everyone, what would be a 'nice' plug in for USB1T11A  as a transceiver ? e.g. like MAX3485 - just that this may have serious limits at 10 Mhz and beyond.
basically a differential signalling transceiver
« Last Edit: July 28, 2023, 05:45:46 am by ag123 »
 

Offline ataradov

  • Super Contributor
  • ***
  • Posts: 11785
  • Country: us
    • Personal site
Re: STM32G030 / G031
« Reply #17 on: July 28, 2023, 06:16:32 am »
Toggling the pins is the easiest part with software USB stacks. Receiving the bits is hard.

You can absolutely forget about bit-banging USB FS, it is just not going to happen with a generic MCU.

And as far as transceivers go, it was already pointed out that USB will require single-ended signalling for bus reset and EOP. And in case of USB LS keep-alive signals, but those generally can be ignored.  There is no getting away from SE0 for the EOPs, which you need to be able to receive and transmit.

For USB1T11A you will have to drive VPO and VMO/FSEO pins, so two pins either way, might as well just drive D+/D- directly. If you are adding an IC anyway, just add a USB to serial and be done with it.
« Last Edit: July 28, 2023, 06:21:51 am by ataradov »
Alex
 

Online DavidAlfa

  • Super Contributor
  • ***
  • Posts: 6280
  • Country: es
Re: STM32G030 / G031
« Reply #18 on: July 28, 2023, 07:39:51 am »
Toggling BSRR with DMA would require:
- Timer to drive DMA @12MHz
- DMA Channel
- 64bytes packet = 512bits, x2 bytes of BSRR = 1KB memory for sending the packet

For a similar price as the transceiver's you can get a usb-serial converter and make your life much easier, but with the added cost, now you can buy a much better mcu.
The only way to justify this is by not using any external parts, again 1.5Mbit/s of the USB 1.0 will be enough for most applications, you have existing software doing so, it's the logical way to go.
« Last Edit: July 28, 2023, 07:45:20 am by DavidAlfa »
Hantek DSO2x1x            Drive        FAQ          DON'T BUY HANTEK! (Aka HALF-MADE)
Stm32 Soldering FW      Forum      Github      Donate
 

Offline ag123Topic starter

  • Contributor
  • Posts: 39
  • Country: 00
Re: STM32G030 / G031
« Reply #19 on: July 28, 2023, 11:34:47 am »
for USB1T11A
https://www.onsemi.com/download/data-sheet/pdf/usb1t11a-d.pdf
the truth table in pin descriptions
Code: [Select]
mode 0
VPO   VMO    Result
  0    0     logic '0'
  0    1     /SE0
  1    0     logic '1'
  1    1     /SE0

from here, it is quite visible that VP0 determines the logic '0' and logic '1'. hence, VPO can simply be driven by MOSI out of SPI
and an additional gpio to drive VM0 if you want to signal SE0 (single ended zero) to the host.

then at the receiving end the single pin RCV is the decoded logic '0' and '1', that goes to MISO

additional inputs these can possibly be monitored via GPIO
Code: [Select]
VP    VM    Result
  0    0     SE0
  0    1     low speed
  1    0     full speed
 

it seem fairly complete as a USB 1.1 full speed PHY and the main data streams is driven on SPI which can be in turn driven by DMA.
hence, it'd seem fairly doable even for stm32g0 series chips.

an interesting 'feature' is CLK signal in SPI is 'redundant' maybe a use could be found somewhere for it. my guess is that it may be possible to recover clocks from usb SYNC blocks but that it'd likely be some 'complicated' hardware PLL & all.
« Last Edit: July 28, 2023, 12:35:20 pm by ag123 »
 

Offline ag123Topic starter

  • Contributor
  • Posts: 39
  • Country: 00
Re: STM32G030 / G031
« Reply #20 on: July 28, 2023, 11:56:45 am »
while checking out the chips
apparently ST has its own too
STUSB03E USB Transceiver Compliant to USB V2.0 for full-speed (12Mb/s)
and low-speed (1.5Mbps) operation
https://www.st.com/resource/en/datasheet/stusb03e.pdf

STOTG04E USB-OTG Full-speed Transceiver
https://www.st.com/resource/en/datasheet/stotg04e.pdf

just that these are seldom featured in the 'online flea markets' or that they are expensive in the 'online flea markets'.
what is featured in the 'online flea markets' is the 'obselete' USB1T11A  and apparently there is probably a 'moderate' demand for it
https://www.aliexpress.com/w/wholesale-USB1T11A.html

for RS485 transceivers apparently there is the max3460-max3464 series which does 20 msps
https://www.analog.com/en/products/max3460.html
and MAX13450E
https://www.analog.com/en/products/max13450e.html

from ST STR485 3.3V RS485 compatible with 1.8V I/Os and selectable speed 20Mbps or 250kbps
https://www.st.com/en/interfaces-and-transceivers/str485.html

these are seldom featured in the 'online flea markets' or that they are expensive in the 'online flea markets'.
in the 'online flea markets' instead there are a 'bunch' of '485' style chips from various sources, a thing about those '485' chips is if they put some filters or limits the slew rates which would 'handicap' usb performance in the 12mhz ranges, mainly at the transmitting side. accordingly it is to reduce reflections for 'poorly terminated' lines.

so the 'solution' in the 'online flea markets' remains as that 'old' (fairchild) USB1T11A
https://www.onsemi.com/download/data-sheet/pdf/usb1t11a-d.pdf


« Last Edit: July 28, 2023, 12:17:03 pm by ag123 »
 

Online DavidAlfa

  • Super Contributor
  • ***
  • Posts: 6280
  • Country: es
Re: STM32G030 / G031
« Reply #21 on: July 28, 2023, 12:07:03 pm »
for USB1T11A
Costs 2x the STM32. You can get now a MCU with USB.

STUSB03E USB Transceiver Compliant to USB V2.0 for full-speed (12Mb/s)
Costs 5x the STM32. Now you can get even better MCU.

STOTG04E USB-OTG Full-speed Transceiver
Costs 10x the STM32. You can get the USB MCU and have a beer!

« Last Edit: July 28, 2023, 12:11:10 pm by DavidAlfa »
Hantek DSO2x1x            Drive        FAQ          DON'T BUY HANTEK! (Aka HALF-MADE)
Stm32 Soldering FW      Forum      Github      Donate
 

Offline ag123Topic starter

  • Contributor
  • Posts: 39
  • Country: 00
Re: STM32G030 / G031
« Reply #22 on: July 28, 2023, 12:22:13 pm »
I think I may nevertheless play with a USB1T11A
https://www.onsemi.com/download/data-sheet/pdf/usb1t11a-d.pdf
as in part it is 'available in the online flea markets'

the attractiveness for 'bit banging' USB is in part as mcus like stm32g0xx series, which is quite 'modern' but lacks usb. They do have usb ones just in the 'higher end' part numbers with more sram and flash and comparatively pricier.

but that if one do not insist on g0 series and say use an 'older' series say the 'old' stm32fxx series, there are many with usb and for a little more than the g0. e.g. the stm32f103 series
then of course there is the 'feature packed' g4 series with usb and much more.

doing usb still wins over some 'crappy' usb-uart dongles as one has the whole usb protocol at your disposal, you can make 'any' device that fit in 'any' usb device class be they serial (CDC ACM), HID (keyboard and mouse), audio, ethernet, and practically thousands of 'usb' use cases ever defined. of course the easier way would be to get one with the usb hardware, only that currrenntly the 'lower' g0 series don't feature usb as part of it.
« Last Edit: July 28, 2023, 12:28:11 pm by ag123 »
 

Online DavidAlfa

  • Super Contributor
  • ***
  • Posts: 6280
  • Country: es
Re: STM32G030 / G031
« Reply #23 on: July 28, 2023, 12:29:00 pm »
There's no attractiveness in bit banging USB, consuming 40% of the MCU resources, and spending the same (Or more)  in USB transceivers as a much better MCU.
It's like buying a 50hp Kia and spendign $5000 in engine mods, while you could have gotten a much better car to begin with.
Hantek DSO2x1x            Drive        FAQ          DON'T BUY HANTEK! (Aka HALF-MADE)
Stm32 Soldering FW      Forum      Github      Donate
 

Offline wek

  • Frequent Contributor
  • **
  • Posts: 538
  • Country: sk
Re: STM32G030 / G031
« Reply #24 on: July 28, 2023, 01:20:47 pm »
Or, use MAX3420E . It's even more expensive...

JW
 
The following users thanked this post: ag123


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf