Prox / RFID
Ladder Logic
[interfacing] †
Tube Joints
Key Code From Photo
SolveSpace (3d CAD)
SketchFlat (2d CAD)
Resume / Consulting
Contact Me

LDmicro Forum - ldmicro on ARM ST 32 bits (Discovery, Olimex...)

(you are viewing a thread; or go back to list of threads)

ldmicro on ARM ST 32 bits (Discovery, Olimex...) (by José GILLES)

After using a few PICs and several ATMegas with my students,
I'm now working with STµElectronics ARM STM32F407 on Olimex board (also used on well known ST Discovery board).

As I'm interested in teaching a few ladder language without buying expensive PLCs, I have downloaded ldmicro, release 2.3 first, and now release 4.4.3 sources, and rebuild it in VC++.

French language was not fully supported in 4.4.3, so I have completed and rebuilt the fr table.

And I have implemented in ldmicro my STM32F407 (32 bits with 16-bit ports). That's not finished but I yet have ports and ADCs working with example ladders. PWM, UART and SPI will follow.

A specific menu was added to generate a fully operational C program for this target (using existing additional libraries) and a modified flashMCU script based on ARMGCC enables the user to get an hex file, which is automatically downloaded to the target via Jlink emulator.

No need to quit ldmicro from ladder programming until testing results on hardware !

I think it may be an interesting improvement for a new release of ldmicro, knowing that all changes to source programs are marked with "JG" tags to be easily localised, and compatibility with other target has of course been respected.

So, I'd like to know if Ihor is interested in it ?
I can post a video demo if need be.
Attached image shows ldmicro interface + flash output.

Best regards
J. Gilles
Mon Dec 3 2018, 13:47:57, download attachment ldmicro1.jpg
(no subject) (by Alex)
I think it is a good upgrade, with this will terminate ldmicro bug(simulación) be fix?
Mon Dec 3 2018, 15:19:20
(no subject) (by José GILLES)

Well, almost no comment about STM32 under ldmicro...
It looks as if the boss (Mr Ihor) were either on holidays or not interested at all ? What a pity.

I'll keep on my way, since I wanna use ldmicro with my STM32.
I/O Pins, cycle timing, ADCs, PWMs are finished and UART is almost ready.

SPI will be the next step (I need it), and why not I2C, as some users claim on another post !


To Alex: what is the bug in simulation you noticed above ?

Can you also repost your image (as pdf ?) about ATMega328 memory usage ? Couln't open it on forum.
Mon Dec 10 2018, 01:41:06
interesante (by Calubert)
No creo que haya jefes ya que es abierto, yo creo que toda ayuda que se haga en ldmicro es interesante y si eres profesor de niños creo que el sistema de programación en escalera es mucho mas interactivo que no C++ ya que se lo toman como un juego. aquí tienes un apoyo en lo que yo te pueda aguda y como creo no solo yo habrá muchos mas en el Foro, gracias por tu ayuda.

I do not think there are bosses since it is open, I believe that any help that is done in ldmicro is interesting and if you are a teacher of children I think that the system of programming in stairs is much more interactive than not C ++ since they take it as a game. here you have a support in what I can sharpen you and as I believe not only there will be many more in the Forum, thanks for your help.

Je ne pense pas qu’il y ait des patrons puisque c’est ouvert, je pense que toute aide apportée dans ldmicro est intéressante et si vous êtes enseignant pour enfants, je pense que le système de programmation dans les escaliers est beaucoup plus interactif que le C ++, car ils le prennent comme un jeu. ici vous avez un soutien dans ce que je peux vous aiguiser et comme je crois que non seulement il y aura beaucoup plus dans le forum, merci pour votre aide. [email protected]
Mon Dec 10 2018, 04:46:56
(no subject) (by MGP)
The bug is when you have an empty row, normally LDmicro generates an error, now it closes the window and you lost your work if not saved before.
Mon Dec 10 2018, 05:00:33
Go ahead (by Ahmad sakr)
Go ahead and make it interesting program not only for arm but you can provide more for pic and avr like parallel lcd, modbus and others.
There is another program flprog. You can make ldmicro have features that flprog have.
Mon Dec 10 2018, 05:29:25
(no subject) (by Alex)
Thaks for your reply José GUILLES, i want to talk about some points made in this thread:

1)i think that as ldmicro forum has always been about pic´s and avr´s there is not enough people that is here for STM32, i think that when you will post your ldmicro for STM32 people will come here for asking about that, even your students for ladder tricks.

2)pdf file attach about memory usag, see please.

3)I made a video showing what i think is the bug terminate in ldmicro and, see please


also there were issues post in Ihor´s repository related to this bug:



4)i think that many ldmicro users has always wanted I2C or SPI for pic and avr for using other peripheral components such as lcds, sensors, etc, a way to use i2c in ladder, i don´t know how difficult could be to implement that i am just a simply ldmicro user.

5)Ihor made a good improvement in ldmicro he said that he could made connect divices VIA I2C.

but he is been out for a while, as i said i am just a simply ldmicro user and i think that ldmicro 2.3 and 2.4 functions were ok that needed to improve functions they already have like ansi c or I2C, make ldmicro to use less space memory, Ihor made good improvement and added a lot fo them but wasn´t that a lot fo work for just 1 person? there were persons that helped him.
Mon Dec 10 2018, 12:46:52, download attachment memory used.pdf
(no subject) (by Alex)
Mon Dec 10 2018, 13:02:36
Terminate bug (by José GILLES)
Several kinds of "Terminate bugs" are reported above.

I've also been a victim of this amazing end of program:
for instance, open a ladder with UART functions and select a target which doesn't support it (ie Controllino Maxi) : ldmicro terminates immediately without any warning, and some work can be lost...

I've tracked this bug, mine is caugth in "Exception Execute Handler" at the very end of ldmicro.cpp and according to the call stack it is due to a pb in a Windows system DLL.
Such a bug may be hard to fix !

To Alex:
I'll try to have a look at your memory used display and your I/O list size, but I don't intend to make much more developments in ldmicro 2.x. I'd rather use my energy to improve version 4 around STM32.

I have for instance modified "instruction" menu to make more submenus by categories because it has become too heavy
in 4.x
And I'd like to rebuild lang tables, which are very incomplete in all languages.
Help would be welcome in almost all languages to translate titles ?

See you soon
Mon Dec 10 2018, 15:18:59
(no subject) (by Alex)
thanks for your reply José GUILLES, it is ok, keep working in 4.x , take your time :)
Mon Dec 10 2018, 16:44:05
(no subject) (by MGP)
José, can you compare the LDmicro.ccp with an earlier versions of LDmicro.cpp because it's not the first time we have this bug and Ihor always solved this.
Tue Dec 11 2018, 07:27:08
(no subject) (by José GILLES)
It would be interesting to know how Ihor fixed the bug in the past ? But he doesn't seem to be online...

Does any one know how to use "UART SENDn variable" ? I don't know what to do with this function in my STM32 Uart !
If you have an example or an explaination, let me know.

Tue Dec 11 2018, 13:20:18
(no subject) (by Calubert)
He fabricado una placa con un ATmega 2560Qft Para si a alguien le interesa
Mon Dec 31 2018, 08:41:29, download attachment Atmega2560.jpg
ATmega2560 (by Calubert)
el programa se hace en LDmicro, el programa que le he cargado para las pruebas a sido un reloj a tiempo real y 30 programaciones de diferentes, puede ser en una hora como en días, semanas ( las semanas la e echo para no hacer el año bisiesto), meses años. esta pensado para seguidores solares por tiempos. también es una formula para hacer funciones a diferentes horas dias para que se vea que en casa hay gente (digamos anti ocupas hasta la mente llegue. hesta preparado par una pantalla Lcd por TX-RX (Serial)
Mon Dec 31 2018, 08:50:03
(no subject) (by LDmicro For STM)
Hello Jose. Thank you for enhancing the LDMicro IDE with the new microcontroller models. Advance very considered. I used the Mega2560 for a while, I noticed that some pin positions have been fixed. Also noticed the pins ADC0 to 7 are not available (PF0 to PF7), I had to migrate to Pins ADC8 to 15 (PK0 to PK7). However Everything works without bugs, including RX-TX1 with BLE. The real-time bug anti-bug has also been eliminated, making it much easier to view the program. Now I will break the STM series. I would like to check if the attached photo (with microcontroller code of my new hardware) will be able to use either of the STM32-40 or STM32-144 models, will be compatible with the pin addressing available in the IDE with the example photo microcontroller attached . If so, can I use my microcontroller pinout that will be functionally addressed? If not, would it be possible to include? It is a new project that will add society with interesting benefit. Thank you in advance for your attention.
Wed Nov 20 2019, 09:18:00, download attachment Screenshot_20191119-190629.png
(no subject) (by José)

You picture shows some STM8S207 µC in LQFP-64, which are 8 bit STM, not at all compatible with 32 bit STM that I have included in ldmicro. It only works at 24 MHz and only has 128 Bb of flash. It' not really better than your AtMega250.

Why don't you try to use STM32F103 ? It's very cheap and much powerfull...

Wed Nov 20 2019, 12:49:07
(no subject) (by José)

That's all, folks ?
Fri Nov 22 2019, 17:18:44
(no subject) (by LDmicro For STM)
Hello Jose.

I will have to continue the project with the micro STM8 (previous photo) need of my board.

I noticed that ldmicro compiles the program into ANSIC, GCC, and others for C language.

Can I sport the C language program with any of the compile tools, then copy and paste the generated program and tweak the Delays and IOs into some IDE that supports the ST that will run the program like in the LDmicro IDE with no problems in routines.

Would you have any tips?

Grateful so far.
Wed Nov 27 2019, 17:55:20
(no subject) (by José)

Everything is possible, but C code generated by ldmicro is very ugly and awful to understand. You'll need some libraries for I/Os and peripherals, timer etc.

You'd better develop directly in C.
There seems to be several tools to do it.

have a look at:

Best regards
Thu Nov 28 2019, 15:19:48
How to compiler file c to hex (by Nadi)
How to made project can upload to stm32.. What program need to make it posible...
Thu Feb 6 2020, 10:55:20
(no subject) (by Ihor Nehrutsa)
JLink.exe is used to flash hex file to stm32f4xx MCU's
ST-LINK_CLI.exe is used to flash hex file to stm32f1xx MCU's

in flashMcu.bat
..... line 490
REM Transfer of the program with J-Link Commander
JLink.exe -device stm32f407zg -if JTAG -speed 1000 -CommanderScript ARMGCC\bin\cmdfile.jlink
..... line 529
REM Transfer of the program with ST-Link CLI
ST-LINK_CLI.exe -c SWD -P ARMGCC\bin\%~nx2.hex -V "after_programming" -Run

You should set proper paths in JLN_PATH and STL_PATH variables.
..... bellow line 428

SET JLN_PATH=C:\Program Files\SEGGER\JLink_V502j

SET STL_PATH=C:\Program Files\STMicroelectronics\STM32 ST-LINK Utility\ST-LINK Utility
@rem SET STL_PATH=C:\Program Files (x86)\STMicroelectronics\STM32 ST-LINK Utility\ST-LINK Utility
Thu Feb 6 2020, 13:17:58
how to copile c to hex (by Nadi)
usually I use pic16fxxx ..... it's very easy ... the file already has a hex ..... but for stm32 mode there are only C files .... with what I can conpile the file to be a hex file .. thank you "Ihor Nehrutsa"
Thu Feb 6 2020, 20:56:05
(no subject) (by José)
Please tell us first:

- Which Stm32 you have ; there are hundreds of models ?
- On which development board is it ?

And we may answer your question.

Its far away from a Pic16F...

Fri Feb 7 2020, 13:33:29
Stm32F103C8T6 (by Nadi)
thanks for your reply José .. Stm32F103C8T6 and or stm32f103RB....
Fri Feb 7 2020, 18:49:46
(no subject) (by José)


Is it a bluepill board ?

The way to upload program depends on the interface available on the board ; it can be JTAG, ST-link ...

Join a picture of your board if neeb be.

Sat Feb 8 2020, 08:12:36
How to get hex file from c file arm gcc mide (by Nadi Radiana)
Here José i sent your photo.... Sory for my langue if very ugly.... I sent 2 photo.... My project usualy with pic16f887 and new project with stm32

Thank very much...
Mon Feb 10 2020, 21:11:40
Picture (by Nadi Radiana)
file photo
Mon Feb 10 2020, 21:14:21, download attachment 1581387172493-1168428136.jpg
Photo pic16 usualy project (by Nadi Radiana)
usualy im use pic16f887....it easy because hex file already on program
Mon Feb 10 2020, 21:18:58, download attachment 1581387410133-1479491004.jpg
(no subject) (by Nadi Radiana)

LDMICRO really helped me who wanted to make a micro control but could not langue c program
i could be electronic and its application
and when LDMICRO was upgraded to the stm32 arm ...
i was very interested ...

nadi from indonesia
Mon Feb 10 2020, 21:27:29
(no subject) (by Nadi Radiana)
the question that I ask a lot is ... with what program you compile c langue files ... by keil, by coocox, by eclip, and how to do it

because for pic16fxxx ic it's easy .... hex file already exists when compiling
Tue Feb 11 2020, 06:18:17
(no subject) (by José)
Hi Nadi

Your board is a Bluepill similar to mine.

To program this board in C, you can:

1) Install EmIde 2.20 from their download link.

2) Copy Bluepill basic libraries from ldmicro\LIBRARIES_FOR\ARM\STM32F1 and create a project.

3) Compile your project.

4) Download hex or elf file created in bin directory to your bluepill board with your st-link v2 key

Here's an example of ready made project to play with leds.


PS: to get full libraries for Bluepill, have a look at my Github repository:

Tue Feb 11 2020, 13:07:46, download attachment Bluepill-Leds.zip
(no subject) (by Nadi Radiana)
thanks again jose ....... 1 week ahead I will try to practice ... the results will be uploaded ...
Tue Feb 11 2020, 20:35:05
emide 2.20 (by Nadi Radiana)
Hi José ..... I am having trouble downloading Emide 2.20 ... their site is down ... does anyone have an address to download the program
Fri Feb 14 2020, 01:54:10
emide 2.20 (by Nadi Radiana)
I compiled using segger ... for transfers to stm32 I have to be patient waiting for jlink to come from the store

emide.org cannot download the program ...
Fri Feb 14 2020, 01:59:40
(no subject) (by José GILLES)
You don't need to have a Segger J-Link to program your bluepill ; you can do it with an st-link v2 (less expensive)

Have you got it ?
Fri Feb 14 2020, 07:08:20
(no subject) (by Nadi Radiana)
Yes José I understand ... thanks for your explanation ... with EMIDE it's easy to do it ... but where can I get emide .... because the website is down
Fri Feb 14 2020, 09:18:42
(no subject) (by José)
I don't understand why EmIde's web site is partially down...

You can download the installer of EmIde 2.20 uploaded by me at this temporary link:


Fri Feb 14 2020, 12:58:40
(no subject) (by Nadi Radiana)
JOSE you really helped me ..... but I still have a problem ....
I attach a picture
Sun Feb 16 2020, 00:21:18, download attachment eab error.JPG
(no subject) (by José)
CortexM3.S file is originally in LIBRARIES_FOR\ARM\STM32F1

In must be copied into ARMGCC\lib in your project directory
and CortexM3.ln too
Sun Feb 16 2020, 03:48:40
Thank you very much to José GILLES (by Nadi Radiana)
everything works normally ... with my mcu arm stm32 I can set the speed of 0.050 ms cycle plc ... very far away with a microchip that can only be 0.400 ms at 200 steps ladder

How can I support LDmicro?
Sun Feb 16 2020, 06:03:30, download attachment sucses upload.JPG
(no subject) (by José)

That's fine if it works for you with your STM32 Bluepill board !

Mon Feb 17 2020, 02:53:24
Building a new version (by CHERGUI Abdelmadjid)
Hello, currently i am working in a project using LdMicro with STMF407 micro-controller and i want to integrated another family from the same micro-controller and do some modification in the F4 series already implemented in the app, but the problem i don't have any basic knowledge how to use the source code of the app and how to build the app that suite me using the old versions, it would be helpful if someone made a video about how to do simple modification and build a new version of the app that suite him
thank you in advanced
CHERGUI Abdelmadjid
Sun Mar 13 2022, 07:41:10
(no subject) (by José)
Ldmicro is built with Visual C++.

But adding a new target is not a "simple" modification at all...
What do you want to add exactly ?

Best regards
Sun Mar 13 2022, 08:26:05
Building a new version (by CHERGUI Abdelmadjid)
thank you for the reply,
I did rebuild the app using the Microsoft visual studio 2013 following the steps in the README, i want to add the H7 family for STM32 may you tell the process to add a new target please, i wanna learn how it could be done.
Thu Mar 17 2022, 04:30:46
(no subject) (by José)
To add a new target you must create a menu entry, add a new target type, create descriptors for your device, manage C code generation, configure timer(s), furnish adapted C libraries and so on...

There's no tuto about it ; it requires to understand source code and modify several files...

I can't tell you any more.
Fri Mar 18 2022, 02:35:52
(no subject) (by CHERGUI Abdelmadjid)
HELLO José, I am using the ladmicro 5.5c version and i am trying to connect my STM32F407 board with my HC-05 Bluetooth Module using UART and it's not working could you please help me debugging the problem, i did try it on Arduino Uno and it worked very well, here's an attachement with the LD code
Sun Jun 12 2022, 11:54:29, download attachment stm32BL.ld
(no subject) (by José)
Ok Abdelmadjid

I'll try to have a look at your program (but I don't have any bluetooth module).

Mon Jun 13 2022, 14:40:54
(no subject) (by CHERGUI Abdelmadjid)
I appreciate it josé i think it's a problem with the uart library beacause the communication between two cards stm worked fine but between card any other device ( bluetooth esp ...) didn't work
Tue Jun 14 2022, 08:07:03
(no subject) (by CHERGUI Abdelmadjid)
Hello again I also tried the version ldmicro32.6 and there is a problem of read out protection here's is an screenshot of the problem i am using the stm32f407
Tue Jun 14 2022, 13:18:45, download attachment 2022-06-12.png
(no subject) (by CHERGUI Abdelmadjid)
hello José is there any news about the bluetooth- UART communication
Mon Jun 20 2022, 12:33:46
Post a reply to this comment:
Your Name:
Your Email:
(no HTML tags; use plain text, and hit Enter for a line break)
Attached file (if you want, 5 MB max):