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

LDmicro Forum - LDmicro.GitHub news v5.3.1.0

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

LDmicro.GitHub news v5.3.1.0 (by Ihor Nehrutsa)

== Release

* Fixed flashMcu.bat and LIBRARIES_FOR ARM,AVR, PIC by Jose GILLES

* Modified "St ARM STM32F40X 144-LQFP" by Jose GILLES

* Added "St ARM STM32F10X 48-LQFP / Bluepill" by Jose GILLES

* Fixed OSR, OSF, OSL, OSC show error.

* Fixed AVR compilation stack overflow error.

* Fixed flashMcu.bat for AVR

* Fixed LUT index range in simulation.

* Fixed PIC UART baud rate calculation.

* Fixed PICs PORTA outputs still stay in analog mode in generated C source code.
Added setPortDigitalIO()

* Fixed When compiling Hex/Asm with PIC target and then calling FlashMcu, the window still closes
immediately without a word...

Thu May 30 2019, 12:40:28
(no subject) (by Alex)
great work, thanks both of you, Ihor and José
Thu May 30 2019, 15:24:10
(no subject) (by José GILLES)
To Alex:

16x2 Lcd displays driven by I2c are now fully operationnal under all targets (PIC16, ATMega, ARM), as you can see in attached zipped examples (PIC16F877 and ATMega328).


A new special command allows users to activate /deactivate backlight from ldmicro ; see doc in LIBRARIES_FOR and attached ld file.
Don't forget to modify I2c address in I2cLib.c for AVRs and in I2cLib.h for PICs (Only one address to modify !!!) to match the one in ld file and in hardware module (generaly 0x27 by default).

Fri May 31 2019, 03:22:05, download attachment I2cLcd16x2.zip
(no subject) (by Alex)
thanks for the information José GUILLES i will test :)
Sat Jun 1 2019, 23:23:35
(no subject) (by Ihor Nehrutsa)
Are there any bug reports?
Tue Jun 4 2019, 16:21:47
(no subject) (by Alex)
lcd backlight is on :), i just set path for hi tech in flashMcu,that´s all i had to do, it seems easy, now i want to try words.

btw, is it possible to do like video link, i am using a serial lcd there or is i2c function in early development yet?

Tue Jun 4 2019, 22:05:44, download attachment lcd i2c test.jpg
(no subject) (by José GILLES)
Hi Alex

Normaly you should be able to do the same as on your video with your I2C lcd.

Available commands for lcd 16x2 displays are explained in LcdI2cLib.txt in LIBRARIES_FOR:

- values between 0 and 0x10 are commands :
0x00= Erase display
0x01= Cursor home
0x02= Blinking display
0x03= Normal display

0x0F= Backlight off (if available)
0x10= Backlight on (if available)

Other values / functions can be added in libraries

- values above 0x80 are move commands to move cursor to line y, col x:
bit 7= 1
bits 6-5= y-1 allows 4 lines 1->4
bits 4-0= x-1 allows 32 columns 1->32

Example: 0xA5 = 1 01 00101 will move cursor to line 2, column 6

- other values between 0x11 and 0x7F are standard chars to display at cursor position

Examples (if I2C address is 0x27):

I2C_WR (0x27 255 'X') displays an X at current cursor position
I2C_WR (0x27 255 chr) displays chr at current cursor position if chr is a regular character (alphanumeric or puntuation for instance)

I2C_WR (0x27 255 0x00) erases display
I2C_WR (0x27 255 0x01) moves cursor home (line 1 col 1)
I2C_WR (0x27 255 0x10) sets backlight on

I2C_WR (0x27 255 0x83) moves cursor at line 1 (8) col 4 (3+1)
I2C_WR (0x27 255 0x87) moves cursor at line 1 (8) col 8 (7+1)
I2C_WR (0x27 255 0xA0) moves cursor at line 2 (A) col 1 (0+1)
I2C_WR (0x27 255 0xA5) moves cursor at line 2 (A) col 6 (5+1)

You can use a LUT to display strings char by char as in this example (replace 0x20 by 0x27).

Let me know if you need help.

Wed Jun 5 2019, 04:18:24, download attachment i2c_lcd16x2.ld
(no subject) (by Alex)
thanks for your reply,first i wanted to try the hello world with backlight on, i think i did well:


1)btw everytime i use i2c function there is a ldmicro error window that shows up only if it is named "I2C1" , watch video please, everything is ok, there is no problem just the window error it is a little annoying but it is ok

2) i have to always name ladder with no spacebar, no problem with that, what about if i don´t use lcd but in my librarie it is set 0x27, does is uses more memory?, i first tried using main library with address 0 i thought it would be generated with 0x27 as set in ladder, i had to set in main library 0x27, i think main library could be default 0 in address for lcd as it is now and then if i set in ladder 0x27 generated lib file that contains lcd library should be the 0x27 because i use lcd, it is only an idea.

My question is if i use backlight command for example how should i set it in ladder?, with an OSR for been used once or without osr?
Wed Jun 5 2019, 20:11:24
(no subject) (by Alex)
thanks for your work, we have i2c in ldmicro :)
Wed Jun 5 2019, 20:12:51
(no subject) (by José GILLES)
To Alex:

- Your hello is OK

- Ldmicro can manage several I2C busses on ARMs (ICD1, 2 or 3). On other targets its only I2C. If you modify ALL I2C names to be correct and SAVE the ladder you shouldn't be anoyed again.

- there musn't be spaces or minus (-) and generally no special symbols in folder / file names for compiling reasons

- to save compiling time, you can remove in each lib subfolder the libraries that you don't use in a ladder, EXCEPT UsrLib. c and .h

- to know if it saves memory, it may depend on the compiler efficency ; try and have a look at hex size ?

- if you never intend to user some libraries, you can remove them from LIBRARIES_FOR folder, EXCEPT Usrlib too

- it's difficult to set I2cLcd address in files from ladder because some displays have different addresses and another I2C peripheral can also have an address at 0x27 !
You're the only one to know that you're using this special I2C peripheral..

- to switch on / off backlight, it is sufficient to send the command once, but if you send the same command several times it shouldn't (doesn't) matter

Thu Jun 6 2019, 06:46:11
(no subject) (by Alex)
Thank for your reply i will try
Thu Jun 6 2019, 13:50:38
(no subject) (by Ahmad sakr)
To Alex
I want to try 16x2 Lcd displays driven by I2c with Atmega, could you please give us the wiring diagram and the steps for making Hello program and the program.
Best regards
Thu Jun 6 2019, 16:22:26
(no subject) (by José GILLES)
To Ahmad:

To try I2cLcd 16x2, you must download the last version of ldmicro ( and ARMGCC compiler from this site for instance:


Then connect your display to I2C bus (4 wires VCC,GND,SDA,SCL)
and follow explainations in:

- HowTo-Avr.txt in LIBRARIES_FOR directory
- LcdI2cLib.txt in LIBRARIES_FOR\AVR directory

Here's attached a working ld example for ATmega328.

Fri Jun 7 2019, 03:04:22, download attachment i2c_lcd16x2bis.ld
(no subject) (by suat)
great work, thanks both of you, Ihor and José
Sat Jun 8 2019, 12:30:28
Como reparar errores de programación. How to fix programming errors. (by Calubert)
Adjunto archivo de como hacer la programación correcta, de las entradas y salidas de LDMicro, de errores de programadores y no es un error de LDMicro (Programa).
Esto sucede porque los Bit de salida son 0 o 1, si en la salida le decimos que tenga el bit 0, nunca se activara en el bit 1 (en otras lineas), por eso tenemos que usar los (R) reles internos y sobre todo con nombres de variables diferentes.
Para mas detalles pueden contactar con migo por este mismo foro y daré las explicacion necesaria. no soy partidario de hacer escaleras ya que lo correcto es hacer uno mismo la escalera para luego no se tengan errores al modificar cualquier parte de programa ya que cada uno tiene una forma de programación.

Attached file of how to do the correct programming, of the inputs and outputs of LDMicro, of programmer errors and it is not an error of LDMicro (Program).
This happens because the output bits are 0 or 1, if in the output we say that it has bit 0, it will never be activated in bit 1 (in other lines), so we have to use the internal (R) relays and over all with names of different variables.
For more details you can contact me through this same forum and I will give the necessary explanation. I am not a supporter of making stairs because the correct thing is to make the staircase yourself so you do not have mistakes when modifying any part of the program since each one has a programming form.

Fichier joint expliquant comment programmer correctement, des entrées et des sorties de LDMicro, des erreurs de programmation et ce n’est pas une erreur de LDMicro (programme).
Cela se produit parce que les bits de sortie sont 0 ou 1, si dans la sortie nous disons qu'il a le bit 0, il ne sera jamais activé dans le bit 1 (sur d'autres lignes), nous devons donc utiliser les relais internes (R) et plus. tous avec des noms de variables différentes.
Pour plus de détails, vous pouvez me contacter via ce même forum et je donnerai les explications nécessaires. Je ne suis pas partisan de la fabrication d'escaliers, car la bonne chose à faire est de créer l'escalier vous-même afin d'éviter toute erreur lors de la modification d'une partie du programme, car chacun a une forme de programmation.

File allegato su come eseguire la corretta programmazione, degli ingressi e delle uscite di LDMicro, degli errori del programmatore e non è un errore di LDMicro (Programma).
Questo accade perché i bit di uscita sono 0 o 1, se nell'output si dice che ha il bit 0, non sarà mai attivato nel bit 1 (in altre righe), quindi dobbiamo usare i relè interni (R) e oltre il tutto con nomi di variabili diverse.
Per maggiori dettagli puoi contattarmi attraverso questo stesso forum e darò la spiegazione necessaria. Non sono un sostenitore di fare scale perché la cosa giusta è fare da soli la scala in modo da non avere errori quando si modifica qualsiasi parte del programma poiché ognuno ha una forma di programmazione.

Прикрепленный файл о том, как правильно программировать входы и выходы LDMicro, ошибки программиста, и это не ошибка LDMicro (Программа).
Это происходит потому, что выходные биты равны 0 или 1, если на выходе мы говорим, что он имеет бит 0, он никогда не будет активирован в бите 1 (в других строках), поэтому мы должны использовать внутренние реле (R) и более все с именами разных переменных.
Для более подробной информации вы можете связаться со мной через этот же форум, и я дам необходимые объяснения. Я не сторонник создания лестниц, потому что правильная вещь состоит в том, чтобы сделать лестницу самостоятельно, чтобы у вас не было ошибок при изменении какой-либо части программы, поскольку каждая из них имеет форму программирования.

प्रोग्रामर त्रुटियों की LDMicro के इनपुट और आउटपुट की सही प्रोग्रामिंग कैसे करें, इसकी संलग्न फाइल और यह LDMicro (प्रोग्राम) की त्रुटि नहीं है।
ऐसा इसलिए होता है क्योंकि आउटपुट बिट्स 0 या 1 होते हैं, अगर आउटपुट में हम कहते हैं कि इसमें बिट 0 है, तो यह बिट 1 (अन्य लाइनों में) में कभी भी सक्रिय नहीं होगा, इसलिए हमें आंतरिक (आर) रिले और ओवर का उपयोग करना होगा विभिन्न चर के नाम के साथ सभी।
अधिक जानकारी के लिए आप मुझे इसी मंच के माध्यम से संपर्क कर सकते हैं और मैं आवश्यक स्पष्टीकरण दूंगा। मैं सीढ़ियाँ बनाने का समर्थक नहीं हूँ क्योंकि सही बात यह है कि सीढ़ी को स्वयं बनाना है ताकि कार्यक्रम के किसी भी हिस्से को संशोधित करते समय आपसे कोई गलती न हो क्योंकि हर एक के पास प्रोग्रामिंग फॉर्म है।
Sun Jun 9 2019, 09:51:59, download attachment saverprogramar.ld
sigue del anterior. Follow from the previous (by Calubert)
Sigue del anterior.

Follow from the previous
Sun Jun 9 2019, 09:54:47, download attachment temp.pl
(no subject) (by Alex)
excuseme, for setting path in mcuflash wich one do i have to change or both of them?

@rem SET PCC_PATH="C:\Program Files (x86)\HI-TECH Software\PICC\9.82"

SET PCC_PATH=C:\Program Files (x86)\HI-TECH Software\PICC\9.82
Wed Jun 12 2019, 15:17:47
(no subject) (by Alex)
and so with avr?

SET GCC_PATH=C:\Program Files\Atmel\AVR-Gcc-8.2.0
@rem SET GCC_PATH=C:\Program Files (x86)\Atmel\AVR Studio 5.0\AVR Toolchain
Wed Jun 12 2019, 15:19:10
(no subject) (by Alex)
the one with "@rem" and withut it
Wed Jun 12 2019, 15:19:44
(no subject) (by Alex)
oh it is a remark, so it is like comment? then i have to set path in path without "@rem"
Wed Jun 12 2019, 15:42:25
(no subject) (by José GILLES)

Yes, @rem means "remark" = "comment"

The true path is in SET PCC_PATH ... or SET GCC_PATH ...

Wed Jun 12 2019, 17:00:12
(no subject) (by Alex)
To Ahmad sakr:

Here is a basic tutorial for i2c lcd with pic and avr, hope it helps you: (btw hope audio english speaker is understandable at least most of it)



Thanks for your reply
Thu Jun 13 2019, 00:45:22
bug report (by MGP)
Ihor, after version 4430 LDmicro has no pwm-pin for a 16F628a.
Can you have a look at it, thanks.
Fri Jun 14 2019, 09:10:54
(no subject) (by Ihor Nehrutsa)
to MGP
to all
Are there any more bug reports?
Fri Jun 14 2019, 11:28:30
(no subject) (by MGP)
Also, all 16F8xx have only 1 pwm-pin instead of 2.
Fri Jun 14 2019, 11:51:46
(no subject) (by Ihor Nehrutsa)
to MGP
Select Timer 0 as PLC cycle timer.
Fri Jun 14 2019, 15:33:37
(no subject) (by MGP)
Yes it works, I was using the new download and there timer 1 is default.
And then it works on the 16F88 also, great..thanks.
Fri Jun 14 2019, 17:00:38
(no subject) (by Alex)
could you give an example how to use a servomotor using 16f88 with internal oscilator?
Sat Jun 15 2019, 01:25:21
(no subject) (by MGP)
Alex, here you have a program that's NOT tested because the lack of time today.

The program is taken from Ihor's wiki list with a slight change and it uses the 500kHz intosc.

Change the IO-pins as you like.
Sat Jun 15 2019, 03:05:40, download attachment servo pwm Pic16f88_test.ld
(no subject) (by Ihor Nehrutsa)
Sat Jun 15 2019, 15:52:30
(no subject) (by Alex)
thanks MGP i will try.

Thanks Ihor, i guess i can use link example using 16f88 intead with internal oscilator
Sun Jun 16 2019, 00:47:13
(no subject) (by MGP)
I made an error in my LDmicro file.
The value of rung 5 must be 0x3E.

When I have time I will update the wiki page as Ihor Has requested, but first I will setup a test.
Sun Jun 16 2019, 03:08:16, download attachment 16F88_osccon_settings.jpg
OS interno (by paulino)
Hola Alex, te adjunto Microsoft-Word par que veas como hacer la pantalla LCD y cambiar el oscilador de las PIC.

Hi Alex, I'll attach Microsoft-Word, so you can see how to do the LCD screen and change the internal oscillator of the PIC.
Mon Jun 17 2019, 04:25:09, download attachment Binario para lcd.doc
possible bug (by Alex)
to paulino:

gracais, es para el lcd i2c?

to MGP:

thanks MGP, i compiled, i changed to 0x3E as you said, watch video please, but i couldn´t make it work with my servo, then i realized that it says #0x87, do i have to change to #0x8F?


to Ihor:

when i press "OK" in mcu paramters window using MGP´s ladder, it says that 0 mhz crystal is not possible (it is 0.5Mhz actually) it changes to 16 Mhz, but if i press close window instead error window doesn´t show up, whatch video please:


BTW : in https://github.com/LDmicro/LDmicro/wiki/Servo-PWM

it is ok to use arduino with 16mhz for servo motor control as Ihor did, it is like arduino board is making things easy, i don´t have to change the crystal, but in pic i have to change my 20 mhz to less than 819 kHz, why is it that pic16 can´t use for example 16 mhz for servo , in that way i could use other options, timers, serial lcd, with 16 mhz and servo like arduino does
Wed Jun 19 2019, 20:28:32
(no subject) (by MGP)
To Alex, sorry but you are right, but....

For now I don't have time because we are busy cleaning up a shacke from a deceased radio amateur at the request of his wife.
All devices must be inventoried and tested for sale ... and there are a lot of devices and parts, he was a real collector, old and new equipement.
Thu Jun 20 2019, 01:23:31
(no subject) (by paulino)
For alex, It is not for UAR and write in the bit you want, note that you have to add to the lines 2,3,4. 128 and in line 0 do not add them.

NOTE you always have to place 128 and add the digit, example LINE 2 64 + 128 = 192 Decimal = hex. = c0 On line 1, it is not necessary to add the 128.

Para alex, No es para UAR y escriba en el bit que quieras, date cuenta que hay que sumar a las lineas 2,3,4

NOTA siempre hay que colocar 128 y sumar el dígito, ejemplo LINEA 2 64+128 = 192 Decimal = hex. = c0 En la línea 1 no hace falta sumar el 128.
Fri Jun 21 2019, 09:33:30
(no subject) (by Alex)
about the comma, i had to change in control panel, it works ok, forget about the comma problem:

Sat Jun 22 2019, 21:42:21
(no subject) (by Alex)

i have changed #0x8F, i set to use comma in crystal option, i am using pull down resistor, then compiled, when i test in proteus it says that mcu is reseting due to watchdog timer, am i using the wrong register?, watch video please:

Sat Jun 22 2019, 22:06:38
(no subject) (by Alex)

WOW!! that is a lot of work, fortunately Ihor gave an example how to use internal oscilator, i had to change config word to 0x33F50, it doesn´t reset anymore, but still can´t make it work with 0,5Mhz:

Sat Jun 22 2019, 22:27:50
(no subject) (by Alex)
btw here is a link where Ihor gives an example using internal OSC with 16f88:

Sat Jun 22 2019, 22:28:51
(no subject) (by Alex)
finally i made it work, i had to change config bits to "0x2F12"
I hor example had "0x33F50" wich i wasn´t able to set that in proteus, proteus said "value not in range, 0 to 16383", but it is not as accurate as Ihor´s example from wiki ldmicro page, i think i have to use a lesser value crystal , decrease and increase buttons don´t work, i´ll have a loot at it:

Sat Jun 22 2019, 23:03:11
(no subject) (by Alex)
increase and decrease buttons work ok
Sat Jun 22 2019, 23:10:07
oscilador interno (by paulino)
Hola Alex no puedes hacer el oscilador interno 5MHz ya que no existe, mírate la tabla.

Hi Alex you can not do the 5MHz internal oscillator since it does not exist, look at the table.

111 = 8 MHz
110 = 4 MHz (predeterminado)
101 = 2 MHz
100 = 1 MHz
011 = 500 kHz
010 = 250 kHz
001 = 125 kHz
000 = 31 kHz (LFINTOSC)
Mon Jun 24 2019, 07:55:17
clock for the STM32F10X Bluepill (by Alejandro Montagna)
for the STM32F10X Bluepill as I have to set the clock to be in a time relase for ldmicro
Thank you
Sat Jun 29 2019, 23:04:43
Reloj para el STM32F10X Bluepill (by Alejandro Montagna)
what cycle time values and
crystal frequency I have to put for a STM32F10X Bluepill, as standard values

Sat Jun 29 2019, 23:12:52
osc_interno para ATMEGA328 (by paulino)
Hola alguno sabe o a realizado como poner el oscilador interno en el micro Atemega328

Hello, someone knows or has done how to put the internal oscillator in the micro Atemega328
Sun Jun 30 2019, 08:13:39
(no subject) (by José GILLES)
To Alejandro Montagna:

In the C file generated by LdMicro, SystemInit() function is automatically called, which sets STM32F10X Bluepill frequency to 72 MHz by default.

Then its up to you to set your cycle time in ldmicro config panel...

Best regards
Sun Jun 30 2019, 14:01:39
(no subject) (by Alejandro Montagna )
thanks for the information you just have to set the fabulous cycle time
thank you very much José GILLES
Sat Jul 6 2019, 15:36:33
no generate the *.hex files (by Alejandro Montagna)
hello the ldmicro does not generate the *.hex files from the
*.elf , that these are generated and I use them to record the STM32F10X by means of another program (STM32CubeProgrammer) with this rebusque works ok.
Question this can be by using a 64bit Windows, and that's why I do not generate the Hex files?
we talk about the "arm-none-eabi-objcopy.exe"
greetings to all
Sun Jul 7 2019, 22:19:45
(no subject) (by José GILLES)
To Alexandro Montagna:

The line in FlashMcu.bat which converts *.elf into *.hex is:

REM Convert Elf to Hex
arm-none-eabi-objcopy -O ihex ARMGCC\bin\%~nx2.elf ARMGCC\bin\%~nx2.hex

It uses arm-none-eabi-objcopy.exe as you said and %~nx2 is the name of the generated file

- Is your path to this executable OK ?

- Can you post your FlashMcu.bat output concerning this line so that we can see the error ?

Tue Jul 9 2019, 04:48:09
the theme of * .hex (by Alejandro Montagna)
hello this is the output that says "flashMcu". (I send it in a file flashMcu.txt)
I clarify on a 64 bit windows 7 platform.

Another thing. Try installing arm-gcc on linux 64bit with
"arm-none-eabi-objcopy -O ihex ARMGCC \ bin \% ~ nx2.elf ARMGCC \ bin \% ~ nx2.hex".
about linux if I generate the * .hex file

Awaiting your response, yours sincerely
Alejandro M.
Tue Jul 9 2019, 07:32:22, download attachment flashMcu.txt
(no subject) (by José GILLES)
Hi Alejandro

It seems to be a known bug in your version of armgcc toolchain
version "8 2018-q4" (in windows 64 bit )


You should use a previous version of the toolchain !
Or try to just replace this arm-none-eabi-objcopy.exe by the one taken in a previous version...
Or try to use a 32 bit version...

Let us know if it solves the pb ?

Best regards

%~nx2 shortcut may not work under linux...
Tue Jul 9 2019, 07:54:13
(no subject) (by José GILLES)

Here's my version of objcopy.exe (to rename from .ex to .exe for security reasons) working in W7 32 bits
Tested virus free with AVG...

Tue Jul 9 2019, 08:03:36, download attachment arm-none-eabi-objcopy.ex
by José GILLES (by Alejandro Montagna)

new version of gcc-arm for Windows version 8.2019
Resine output from the furnace and fuses well in Windows 7 64 bits
    with this the * .hex files are generated in



best regards
Wed Jul 10 2019, 11:04:25
to José Gilles What's new in 8-2019-q3-update (by Alejandro Montagna)
confirmed the new version of GNU Arm for windows works very well in ldmicro generating the files
    (* .hex) and (* elf)
Version 8-2019-q3-update
    Released: July 10, 2019

best regards
Wed Jul 10 2019, 11:27:10
(no subject) (by José GILLES)

That's fine.
Enjoy Ldmicro with your ARMs !

Thu Jul 11 2019, 10:51:49
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):