STM32C011 (WeAct) - first steps

Post here first, or if you can't find a relevant section!
STM32ardui
Posts: 45
Joined: Mon May 06, 2024 1:46 pm
Answers: 1
Location: Germany

Re: STM32C011 (WeAct) - first steps

Post by STM32ardui »

trimarco232 wrote: Fri May 17, 2024 10:03 am lots of answers here : https://github.com/stm32duino/Arduino_C ... 2/wiki/API
Do you read my posting???
User avatar
fpiSTM
Posts: 1780
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 93
Location: Le Mans
Contact:

Re: STM32C011 (WeAct) - first steps

Post by fpiSTM »

There is an issue in your setup as you used:

Code: Select all

Wire.setSDA(PA5);          
Wire.setSCL(PA4);
But they are not I2C pins based on the PinMap_I2C_SDA array you provide.

The "PYn_R" pin is remap pin that's all but when you remap some other "PYn" pins will not be available.

About D14/D15 it exists in the Arduino STM32 core.
For example if PA15 is defined as 15 then D15 is also PA15.
So using:

Code: Select all

digitalRead(PA15);
digitalRead(15);
digitalRead(D15);
do the same.

Finally
STM32ardui wrote: Fri May 17, 2024 8:19 am I tried it on PB6/PB7, but the I2scanner.ino tells me, there is not I²c-device.
Do you have Pullup on each I2C line ?
STM32ardui
Posts: 45
Joined: Mon May 06, 2024 1:46 pm
Answers: 1
Location: Germany

Re: STM32C011 (WeAct) - first steps

Post by STM32ardui »

Let me start with the last part:
fpiSTM wrote: Fri May 17, 2024 12:18 pm Finally
STM32ardui wrote: Fri May 17, 2024 8:19 am I tried it on PB6/PB7, but the I2scanner.ino tells me, there is not I²c-device.
Do you have Pullup on each I2C line ?
I took out a STM32F411CE board to compare.
I uploaded the i2scanner.ino via STLink.
Then I connected A9/A10 to an USB-TTL-adapter to see output to serial.
And SCL from sensor to PB6, SDA to PB7. The sketch recognizes the sensor at address 0x23 as aspected.
The sensor also worked some months ago with an ESP32 (also no additional pullup-resistor).

So I think that there are pull-up-resistors on the sensor board. I found schematic at Instructables It's not absolute correct for my board. R4 ist 10 kOhm, not 4,7 kOhm. Some resistors are 1 kOhm. And this diode should keep away 5V level from chip ...

So the sensor board is not the best design, but it works with BlackPill and ESP32. I don't see a reason, it shouldn't work with STM32C011F6P6 too.

fpiSTM wrote: Fri May 17, 2024 12:18 pm There is an issue in your setup as you used:

Code: Select all

Wire.setSDA(PA5);          
Wire.setSCL(PA4);
But they are not I2C pins based on the PinMap_I2C_SDA array you provide.
So what is the meaning of those lists in PeripheralPins.c?

a) First line for SDA is PA_10_R and for SCL PA_9_R - so I can use them together in Wire.setSDA() and Wire.setSCL()?

b) Second line for SDA is PB_7 and for PB_6 - so I can also use them together?

c) But I can't use PA5/PA6, because they are not in the list?
I thought, that "weak" means I can use each GPIOs I like? STM32 chips don't have a GPIO-switch matrix like an ESP32, where I'm (nearly) absolutely free to use any pins I want?

Do I always have to define such a combination for the first I2C interface on the STM32C011F6P6? Because on the STM32F411CE I could simply use PA6/PA7.

And: the PeripheralPins.c for STM32C011F6P6 shows only I2C1. It means, that I can't define a Wire2? That would fit to feature list at beginning of datasheet: "One I²C-bus interface supporting Fast-mode Plus ..."

fpiSTM wrote: Fri May 17, 2024 12:18 pm About D14/D15 it exists in the Arduino STM32 core.
For example if PA15 is defined as 15 then D15 is also PA15.
So using:

Code: Select all

digitalRead(PA15);
digitalRead(15);
digitalRead(D15);
do the same.
The tiny STM32C011F6P6 comes in a TSOP-20 package.
It has PA0 - PA8 and PA11 - PA14. (PA14 has the boot button)
Then PB6, PB7.
In datasheet is a remark: "Pins PA9 and PA10 can be remapped in place of pins PA11 and PA12 (default mapping), using SYSCFG_CFGR1 register."

In the beginning I thought, that PA11/PA12 (remapped from PA9/PA10) would be UART1, because PA9/PA10 is Serial on BlackPill. But I received nothing. So I defined:

Code: Select all

HardwareSerial Serial2(PA3, PA2);  // RX, TX
It works. But it only works, because the combination PA2/PA3 is in the list inside PeripheralPins.c?

Datasheet has a "Table 12 pin assignment and description". In column "Pin name (function upon reset)" i only find port numbers PA0 - PA8. Does it means, that no function is predefined and I have always to define it by myself?



And as last question:
STMicroelectronics delivers a lot of PDFs. Difficult to understand. :cry:
Is there a tutorial or book, that explaines these hardware topics in a way, that newbies can understand?
ag123
Posts: 1709
Joined: Thu Dec 19, 2019 5:30 am
Answers: 27

Re: STM32C011 (WeAct) - first steps

Post by ag123 »

for this board, you are trying to 'fit an elephant in a small box'. :lol:
If I have to mess with this board/chip, I'd resort to cmake
https://github.com/stm32duino/CMake_workspace
it may take leaving out lots of components to fit things in there, especially the *sram* usage.
it takes *a lot more* than just *duino* skills to play with chips with extreme low amount of sram and flash, you need to figure out if after all your code and sram usage fits in there after all.

for something a lot more roomier, I prefer things like stm32f401, stm32f411
STM32ardui
Posts: 45
Joined: Mon May 06, 2024 1:46 pm
Answers: 1
Location: Germany

Re: STM32C011 (WeAct) - first steps

Post by STM32ardui »

fpiSTM wrote: Fri May 17, 2024 12:18 pm There is an issue in your setup as you used:

Code: Select all

Wire.setSDA(PA5);          
Wire.setSCL(PA4);
But they are not I2C pins based on the PinMap_I2C_SDA array you provide.

The "PYn_R" pin is remap pin that's all but when you remap some other "PYn" pins will not be available.
@fpiSTM: I'm still interested to learn, how to connect several interfaces at a new board, when there is no pinout graphic in internet and how to interpret files like PeripheralPins.c, also if it's possible to remap with ArduinoIDE.

But for the moment I can say:
1. I found out which pins are used for UART1.
2. Also I found out the pins for I2C1.
3. I2Scanner is working - a small problem with breadboard and jumper cables (quality of new parts is really worse since Corona :x ).
4. Also a library for BH1750VI light sensor written for Arduino is running on the small STM32C011F6P6 by simple copy&paste.

Bye, Jürgen
STM32ardui
Posts: 45
Joined: Mon May 06, 2024 1:46 pm
Answers: 1
Location: Germany

Re: STM32C011 (WeAct) - first steps

Post by STM32ardui »

trimarco232 wrote: Thu May 16, 2024 9:36 pm - DAPLink is for MBed , and will work for other IDEs , but for Arduino , I really fear it won't work , so far
The problem is not ArduinoIDE.
Problem is STM32CubeProgrammer. It doesn't recognize such a DAPLink.
So wasted time and wasted money.
Only thing working are the RX/TX-pins, so I see output of Serial.print() commands.
ag123
Posts: 1709
Joined: Thu Dec 19, 2019 5:30 am
Answers: 27

Re: STM32C011 (WeAct) - first steps

Post by ag123 »

for DAPlink, you may need to explore things like openocd
https://openocd.org/

STM32Cubeprogrammer is generally made for st-link v2 ++.
the main thing about STM32Cubeprogrammer is that it is from ST, and that if one are working in MS Windows, it saves one struggling with driver stacks issues.

as otherwise, even for st-link v2, there are open sourced programming software such as openocd and st-link etc
https://github.com/stlink-org/stlink

for the small chips, e.g. STM32C011, I've got instead a bunch of STM32G030
viewtopic.php?t=1848
if you are insterested in that (g030) I made a figure of the alternate functions and present them here:
viewtopic.php?t=1848&start=10

I've not played with them yet. A thing I'm rather aware is the sram and flash constraint, that would make it a challenge to simply compile and fit a binary unlike those 'generous' socs like F401/F411, for STM32F411CEU6 they have like 128k sram and 512k flash
https://www.st.com/en/microcontrollers- ... 411ce.html
that is 'very generous' by microcontroller standards, and you can literally 'optimize for speed' and simply *waste flash and memory*, to the extent of simply having some 'fat' build into the binary consisting binary blobs that one may not even call/use.
while on chips like c011 and g030, every byte counts.

'optimize for speed' e.g. compile with gcc -O2, really made a difference on stm32f4xx (and possibly g4xx), and f7, h7 series.
whetstone benchmarks has been explored. There have been 'figures' like 200 Mflops (single precision) to even like 500 Mflops 'world record' on stm32f407 overclocked to 250 Mhz trying out those stuff with gcc -O2.
830 Mflops on stm32f743 running at 480 Mhz
viewtopic.php?p=8887#p8887
I'm not too sure if -O3 etc would make any difference, but that there is a notion that the optimization is *fake*, e.g. as the benchmark 'do nothing' other than count cycles, the simplest way to get maximum speed is to simply 'optimize away' (remove) the math and just count cycles, so that is cheat.
But that it may nevertheless be real, no one 'ever' verified it. Just that stm32f4xx with gcc -O2 optimization is 'fast', that is about it.

for the stm32g030 there are vendors offering pre-made boards for it
https://www.aliexpress.com/w/wholesale-stm32g030.html
but I decided to do away with pre-made boards for it.
Instead I ordered chips
https://www.aliexpress.com/w/wholesale- ... 0f6p6.html
and sop20 'adapter boards'
https://www.aliexpress.com/w/wholesale-sop20-pcb.html
intending to hand solder them

the idea is that with only 20 pin available, every pin counts, hence simply using adapter boards means that all the pins are up to you to wire them.
even for that matter temporary connections, rather than say wired to a LED etc.
STM32ardui
Posts: 45
Joined: Mon May 06, 2024 1:46 pm
Answers: 1
Location: Germany

Re: STM32C011 (WeAct) - first steps

Post by STM32ardui »

ag123 wrote: Sat May 25, 2024 3:07 pm for DAPlink, you may need to explore things like openocd
https://openocd.org/
I heard about it. It's a CLI-program right?
Can ArduinoIDE call it instead of STM32CubeProgrammer CLI?

WeActStudio tells me "You can use another ST link to brush the daplink into ST link". I only find in internet how to modify a STLink into a DAPLink not vice versa ...

ag123 wrote: Sat May 25, 2024 3:07 pm for the small chips, e.g. STM32C011, I've got instead a bunch of STM32G030
viewtopic.php?t=1848
I wonder how I was able to run test sketches with SD-card using SdFAT on an Arduino UNO with 32 kB Flash and 2 kB RAM ... :roll:

The STM32C011 was able to read values from a BH1750 light sensor, but:
Sketch uses 30524 bytes (93%) of program storage space. Maximum is 32768 bytes.
Global variables use 1504 bytes (24%) of dynamic memory, leaving 4640 bytes for local variables. Maximum is 6144 bytes.


A STM32G031 has 64 kB Flash and STM32G070/71/80/81 have 128 kB Flash/36 kB RAM.
At 64 MHz or 16 MHz current consumption is half of a STM32F411.
Or a STM32G0B1CBT6 with 128 kB Flash and 128 kB RAM.

TSSOP20 is a problem, with LQFP48 (or larger) there is a VBAT-pin. With less than 600 nA RTC can survive.

I found STM32G070-boards for about 4 € as next step.
ag123
Posts: 1709
Joined: Thu Dec 19, 2019 5:30 am
Answers: 27

Re: STM32C011 (WeAct) - first steps

Post by ag123 »

STM32ardui wrote: Sat May 25, 2024 4:37 pm
ag123 wrote: Sat May 25, 2024 3:07 pm for DAPlink, you may need to explore things like openocd
https://openocd.org/
I heard about it. It's a CLI-program right?
Can ArduinoIDE call it instead of STM32CubeProgrammer CLI?

WeActStudio tells me "You can use another ST link to brush the daplink into ST link". I only find in internet how to modify a STLink into a DAPLink not vice versa ...
what I normally do is I goto Sketch > export compiled binary, then the bin file would be left in your project folder.
You can flash that bin file with any tools you prefer.

for stm32f103 ( I use 'roger's' bootloader https://github.com/rogerclarkmelbourne/ ... bootloader) and stm32f4xx
i use dfu-util (supported in stm core as well)
https://dfu-util.sourceforge.net/
and mainly only in linux, for stm32f4xx the usual way is set boot0, toggle reset then

Code: Select all

dfu-util -a 0 -s 0x8000000 -RD sketch.bin
for 'roger's bootloader' it is -a 2 and without the -s
if I need 'more convenience' I resort to st-link v2 dongle, no boot0 setting etc, connect wires just flash away, each time every time
https://www.adafruit.com/product/2548

If you really want to try integrating it, try looking in platform.txt to see how that is done
https://github.com/stm32duino/Arduino_C ... m.txt#L187
STM32ardui wrote: Sat May 25, 2024 4:37 pm
ag123 wrote: Sat May 25, 2024 3:07 pm for the small chips, e.g. STM32C011, I've got instead a bunch of STM32G030
viewtopic.php?t=1848
I wonder how I was able to run test sketches with SD-card using SdFAT on an Arduino UNO with 32 kB Flash and 2 kB RAM ... :roll:

The STM32C011 was able to read values from a BH1750 light sensor, but:
Sketch uses 30524 bytes (93%) of program storage space. Maximum is 32768 bytes.
Global variables use 1504 bytes (24%) of dynamic memory, leaving 4640 bytes for local variables. Maximum is 6144 bytes.


A STM32G031 has 64 kB Flash and STM32G070/71/80/81 have 128 kB Flash/36 kB RAM.
At 64 MHz or 16 MHz current consumption is half of a STM32F411.
Or a STM32G0B1CBT6 with 128 kB Flash and 128 kB RAM.

TSSOP20 is a problem, with LQFP48 (or larger) there is a VBAT-pin. With less than 600 nA RTC can survive.

I found STM32G070-boards for about 4 € as next step.
a good thing about buying ready made boards is that many components are prebuilt on board e.g. crystals, leds, buttons, header pins etc.
but go for higher pin count chips vs the low pin count ones, and in particular check for the vendor release of board schematic and pinouts for the boards. I'd in particular look for published schematic and preferably detailed board pinouts drawings with components drawn.

stm32g0 is cortex M0+, which accordingly has less instructions compared to even stm32f103c8 - cortex m3.
the missing instructions is recreated by using extra codes which makes the binaries more verbose than is necessary.

oh and to really stinch on every *byte* so that the bin file has *no fat*, one may need to resort to cmake based builds, and to cut so much stuff so that only really bare minimum gets compiled from the sources, i.e. no arduino, pure skeleton bare metal programming, but still in c/c++ codes.

if you can make do with little sram like 20k sram, try getting those 'blue pill' stm32f103c8 type boards, those has usb on chip as an additional convenience, and quite often the aliexpress vendors place an 8 mhz crystal + a 32k rtc crystal on board, which means you can use the rtc with an external 32k crystal, useful at times.

I simply prefer stm32f401/f411 and g4xx chips and boards, more sram, more flash, has fpu, has 'art accelerator' more performance for same hz.
I'd make do with stm32f103c8 for 'simple' apps, and only simply because it has *usb*, I think it is a critically important factor.
stm32f103 is a 'usb swiss army knife', e.g. you can practically make 'any' usb devices out of a stm32f103 usb-serial (usb-CDC serial) most common,
and any other protocols if you bother to program (e.g. usb HID device (e.g. keyboard, mouse, etc)), usb audio, usb mass storage , etc ... list goes on)
most (all?) f4xx g4xx have usb is faster / higher performance, more sram and flash + fpu just that they cost more.
STM32ardui
Posts: 45
Joined: Mon May 06, 2024 1:46 pm
Answers: 1
Location: Germany

Re: STM32C011 (WeAct) - first steps

Post by STM32ardui »

STMicroelectronics have a large portofolio of microcontrollers. So everybody can use what's best for a project.

Often I'm using sensors, there have typical 8bit-registers and library concatenate 2 of them. So the last step may be a division. Sometimes a 1/100 or a 1/65536 (which is a shifting). So FPU is not really important for me.

May be I will use a STM32F4xx in future for larger display ...
Post Reply

Return to “General discussion”