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.0.4

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

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

== Release

* Added: Menu Settings->Set Pull-up input resistors.
All input pins try to set Pull-up registers by default.
Attention: Not all ports have a pull-up resistor.
See datasheets of the controller for details.

* Added: PIC12F683 8-pin.

* Added: ESP8266. ANSIC compiler only.

* Fixed: Pins PB6 and PB7 are available for general I/O use when
the internal clock source is selected.
MCU list: ATmega8, ATmega48, ATmega88, ATmega168, ATmega328.
Note: LDmicro not provided any clock source manipulation.
Discussion here: http://cq.cx/ladder-forum.pl?a...ent=8416&tt=1555027659

* Fixed: General variable name as Timer parameter, Issue #172

* Fixed: Quadrature Encoder, Issue #175
Output Dir can be Y (pin) or R (internal relay).

Sun Apr 14 2019, 06:12:28
(por Ihor Nehrutsa) (by Calubert)
Hola Ihor, ante todo date las gracias por todo el apoyo a LDmicro y al foro, no se si se puede agregar la pic-16f887-44TQFP. ya que consiguió una docena de ellas y cuando fui a programarlas me di cuenta que el TX-RX estan a partir delas patillas sobre 42-41.
forme un proyecto con la placa PCB y la tengo muerta en un rincón te adjunto foto ( Es una fuente de alimentación regulable de 0Vdc hasta 65Vdc,y ajustable los amperios de 0 a 65Amp con 2 salidas PWM. Pantalla LCD
estoy a que si se necesita en este foro para donarla para la gente que necesite de ello y averigüen para el aprendizaje. con todos esquema y materiales necesarios para la fabricación de cero.

saludos Paulino (Calubert)
Sun Apr 14 2019, 07:54:33, download attachment 20190414_134517.zip
(no subject) (by Calubert)
Estoy probando la versión y la simulación UART (Terminal) con el teclado no funciona. adjunto programa sencillo.
Sun Apr 14 2019, 08:14:53, download attachment test-UART-calubert.ld
(no subject) (by Alex)
thanks a lot Ihor :)

to Calubert:

Creo que eso ya lo reportaron aquí:

Sun Apr 14 2019, 10:47:19
by Alex (by Calubert)
No se reporto para otra versión anteriores 5.x.x.x- Es para la versión ultima versión
Sun Apr 14 2019, 12:38:07
(no subject) (by Tom J.)
I wish my hands weren't so full of other projects right now, looking forward to trying it when I can!
Thank you once again Ihor!
Sun Apr 14 2019, 13:30:30
(no subject) (by Ziggy)
When do You sleep?
Sun Apr 14 2019, 16:03:04
(no subject) (by Arturo)
Hello In Version LdMicro 5.2a Editing flashMcu.bat

SET GCCPATH=C:\Program Files\Atmel\Atmel Studio 6.0\extensions\Atmel\AVRGCC\\AVRToolchain
SET DUDPATH=D:\Programmation\Ladder\Programmes\Tests\AvrGcc\AvrDude

Yes, it works, create the HEX file
SET GCCPATH=C:\WinAVR-20100110
SET DUDPATH=D:\Programmation\Ladder\Programmes\Tests\AvrGcc\AvrDude

In The LdMicro build5304 Version
I modify flashMcu.bat and it does not work

SET GCC_PATH=C:\Program Files\Atmel\AVR-Gcc-8.2.0
@rem SET GCC_PATH=C:\Program Files\Atmel\Atmel Studio 6.0\extensions\Atmel\AVRGCC\\AVRToolchain

It does not work, does not create the HEX file
SET GCCPATH=C:\WinAVR-20100110
@rem SET GCC_PATH=C:\Program Files\Atmel\Atmel Studio 6.0\extensions\Atmel\AVRGCC\\AVRToolchain

Mon Apr 15 2019, 15:19:24
(no subject) (by Ziggy)

I would be interested to lear the process of compiling for GCC.
Typically a make file is required when compiling .
I would like to learn how and what it takes to get to a compiled output.
Can You please post the requisite files to achieve a HEX output?
Do You use any optimisation under GCC -O?

So much to learn ...
Mon Apr 15 2019, 22:13:57
(no subject) (by Alex)
hello, i have worked before with avr studio 5.0 compiling for GCC, it worked ok, now i want to try with I2C pics, since i most of time use microship mcu, as far as i undestand for pic it is needed "HIGH TECH C", said here by José GUILLES:


i only found "HI-TECH C" which is obsolte, i was renamed "XC8", said in this mmicroship forum:



if HIGH TECH C = HI-TECH C (due to corrector) are the same, then it is alias "PIC C" as José GUILLES said here again:


sorry if i get this messy but i am a little confused, i don´t really worked with these programs, i just want to use the right program and the right path from if it is HIGH TECH C or HI TECH C or PIC C or XC8
Mon Apr 15 2019, 22:38:52
(no subject) (by Arturo)

in LdMicro build5304 Version not work.

In The LdMicro build5304 Version
I modify flashMcu.bat and it does not work

SET GCC_PATH=C:\Program Files\Atmel\AVR-Gcc-8.2.0
@rem SET GCC_PATH=C:\Program Files\Atmel\Atmel Studio 6.0\extensions\Atmel\AVRGCC\\AVRToolchain

It does not work, does not create the HEX file
SET GCCPATH=C:\WinAVR-20100110
@rem SET GCC_PATH=C:\Program Files\Atmel\Atmel Studio 6.0\extensions\Atmel\AVRGCC\\AVRToolchain
Tue Apr 16 2019, 01:10:11
(no subject) (by José GILLES)

Hi everybody

Let's try to clarify the use of external libraries for PICs or AVRs.

I have introduced it in ldmicro32 fork, and it has been now merged with ldmicro 5.3 by Ihor. I haven't tested yet brand new version, but I have made last week long tests with previous and it worked fine (but not with previous 5.3 versions which had a few problems with it) under Windows 7 32 bits.

You can have information in HowTo txt files (in english french and spanish) lying in LIBRARIES_FOR directory.

So, to use external libraries, you must:

1) Install ldmicro (tested OK) or (not tested) version. Then, copy LIBRARIES_FOR directory and all its content in the same folder as ldmicro executable.

2) Download a supported C compiler according to your target:

- for PIC16F (only), you need HI-TECH-C from Microchip, also known as PIC-C. Yes its an old compiler, no longer supported, but it was the one used in ldmicro before...
As its not easy to find in Microchip archives, you can dowmload version 9.82 at this temporary personal link :


Install it and remember the place WHERE you install it, for instance:
"C:\Program Files\HI-TECH Software\PICC\9.82"
You DON'T need to install any other software like MPlab.

- for AVRs (Atmega), you need AVR-GCC free compiler. I have tested version 8.2.0 but it should work with another one.
You can also download the one I used (for x86) at this temporary link:


Just copy file hierachy in zip file in a folder, for instance:
"C:\Program Files\Atmel\AVR-Gcc-8.2"
You DON'T need either to install any other software, like AvrStudio.

3) Then you will need a tool and a software to program your target, for instance AvrDude, for AVRs, which recognizes many programming tools, or WinPic800 for PICs. Your hex file will be generated by ldmicro in the subfolder AVRGCC\bin of the folder where your source ld file lies.

If you want to use a command line tool and do all the job without exiting ldmicro, you must then edit flashMcu.bat file.
this script must be put in the same folder as ldmicro executable.

Anyway, you must at least edit flashMcu.bat to settle the path to your C compiler as above:

- for PIC16, edit :HTC section of this file and modify the line:
"SET PCC_PATH=C:\Program Files\HI-TECH Software\PICC\9.81"
to replace the path after "=" by yours (see above).

If you have installed a command line tool, you can place your instructions to download hex file to the target just after the line:
"REM Transfer of the program with ..."

Keep in mind that generated hex file has the generic name "AVRGCC\bin\%~nx2.hex" in this context

For the time being you can also download hex file at your usual manner from "AVGRGCC\bin".

- for AVRs, edit :AVRGCC section in flashMcu.bat and modify the line:
"SET GCC_PATH=C:\Program Files\Atmel\AVR-Gcc-8.2.0"
to replace the path after "=" by yours (see above).

If you want to use AvrDude to download automatically generated hex file to the target, edit the line:
"SET AVRDUDE_PATH=D:\Programmation\Ladder\Programmes\Tests\Avr\AvrDude"
and replace the path after "=" by yours
Then edit the line:
"avrdude.exe -p %4 -c avr910 -P %COMPORT% -b 19200 -u -v -F -U flash:w:AVRGCC\bin\%~nx2.hex"
and replace AvrDude options according to your programming tool
and Com port

Keep in mind that generated hex file has the generic name "AVRGCC\bin\%~nx2.hex" in this context

4) Try ldmicro + C libraries
Open a ld file and compile it in C with the right option HI-TECH C or AVR-GCC in Compile menu.
Then launch flashMcu.bat from compile menu too. There may be warnings in black window but there should be no error. If so, you must find the hex file in "AVRGCC\bin" subfolder created automatically. Note that libraries are also automatically copied into "AVRGCC\lib" subfolder. To save time you can remove from it unused libraries according to your ladder, but you must keep at least UsrLib and VerLib files. Verlib number should match your ldmicro version number to avoid problems.

If it doesn't work for you, its probably because you made something wrong... Once its well configured you save a lot of time !

Please report problems explaining your own context (hard ans soft), joining your own pathes, and your own flashMcu.bat if you want efficient help.

Tue Apr 16 2019, 04:28:55
(no subject) (by Ziggy)

SO Ldmicro will generate a hex file directly without a need to prepare a makefile?

Of course once the hex file exists there are other options to upload it...

AVR studio..even the existing Arduino installation could be pressed into service, after all it too uses AVRDUDE
Tue Apr 16 2019, 07:08:03
(no subject) (by José GILLES)

You can generate Hex file via C compiling and even program your target without exiting ldmicro.

The equivalent of your makefile is contained into flashMcu.bat.
It requires a few skill to configure it perfectly.

I don't use Arduino, but I suppose that installed compiler and involved AvrDude can be used, provided you find the path to them. I have some AtMega328 on another board (Myavr).
Tue Apr 16 2019, 08:16:09
(no subject) (by Arturo)
Hola error ver foto.
Tue Apr 16 2019, 13:23:35, download attachment 1.jpg
(no subject) (by José GILLES)
To Arturo:

Your image is not sufficient for a diagnostic.

If you want me to help you, you must help me !
Please follow requirements (see above):

- hardware: AtMega328 ; Arduino ?
- LCD on I2C ?
- software: Which Avr-Gcc ? ; which ldmicro ?
- post your flashMcu.bat


For your information, I have tested ldmicro with current libraries and LCD on I2C compiles and works on my AtMega328.
Tue Apr 16 2019, 14:34:33
(no subject) (by José GILLES)
PS to Arturo:

Did you copy LIBRARIES_FOR as required (see above) ?
Have you got UsrLib.c and UsrLib.h in AVRGCC\lib ?
Tue Apr 16 2019, 14:37:27
(no subject) (by Arturo)
Hello José GILLES look at the image
Tue Apr 16 2019, 15:40:12, download attachment 2.jpg
(no subject) (by Arturo)

- hardware: Arduino AtMega328 ;
- LCD on I2C ?
- software: AVR-Gcc-8.2.0
Tue Apr 16 2019, 15:48:57, download attachment flashMcu.rar
(no subject) (by Alex)
hello i have followed steps for flash mcu for 16f in HOW TO PIC16, i have made a video of that, ldmicro generated BIN file but inside it there are other files but no HEX file, watch video please, P.D. i installed HI TECH from link above, but i only installed limited version HI TECH C, i also attach CMD report in pdf file.

Tue Apr 16 2019, 17:30:39, download attachment CMD .exe - report flash mcu bat for pic16f.pdf
(no subject) (by José GILLES)
To Arturo:

You didn't answer to PS questions above...
You don't indicate which version of ldmidro ?

Your flashMcu.bat seems to be OK - AvrDude is not configured but that's not the pb for the time being.

Maybe you're trying to use old libraries with ldmicro or 4 ? If it's the case, it can't work because some little things have changed.

You MUST copy the LAST version of LIBRARIES_FOR (on github) in the same directory where ldmicro executable lies.
Wed Apr 17 2019, 05:29:18
(no subject) (by José GILLES)
To Alex:

Your Video is a good way to diagnose the pb !
But please scroll black window (flashMcu.bat) so that I can see everything.

At the end of this flashMcu black window (1:25 in video) you have a compiling error: the compiler can't find I2C_Init(), I2C_MasterGetReg(), I2C_MasterSetReg() and bcd2bin() functions.
Although these functions are in libs...

In your video, I can see a pb at point 5):
You have some files in I2C DS3231 (.ld, .c, .h, ladder.h) AND some other files in subfolder CCS\I2c_ds3231 (.c, .h, ladder.h)
Why ???

Maybe it explains the pb.
Here's what I advocate:

1) Remove all SPACES in your folder names (ie I2C DS3231) and in all your file names because command line tools don't like SPACES

2) Use only 1 folder to store project files (you have 2)

Retry and let me know


This problem may be solved but you'll have another one next due to a bug in last versions 5.3.0.x on PICs, not because of I2C which I tested and worked, but in the management of Look Up tables (stored in flash memory to save RAM) used in lcdI2c16x2.

Ihor may have changed something somewhere because I think it worked in ldmicro32. I don't know exactly where it comes from, but I know how to solve it in ldmicro source code (tested). I'll see it with him for next version.

To avoid this second pb, you'll just have to edit - for the time being - generated i2clcd16x2.c file before calling flashMcu.bat and modify the lines at the beginning:

#ifdef __GNUC__
const unsigned char Ui_name[7] PROGMEM = {72, 101, 108, 108, 111, 32, 33};

1) replace __GNUC__ with __PICC__
2) and remove PROGMEM to get:

#ifdef __PICC__
const unsigned char Ui_name[7] = {72, 101, 108, 108, 111, 32, 33};

do the same in any other similar declaration if need be.
Wed Apr 17 2019, 06:42:40
(no subject) (by Tom J.)
"* Added: PIC12F683 8-pin."

WOW! I glanced over this the other day and didn't even see that!!

Ihor, you were already a hero to me, now you're moving into diety status!
Sitting down to order a bunch of 12F683 right now.
Wed Apr 17 2019, 19:30:13
(no subject) (by Alex)
thanks for your reply i keeps the same, actually i am not good at this, i´ll be patient for next release :) about I2C and SPI for mcu
Wed Apr 17 2019, 21:52:00
(no subject) (by Tom J.)
Now that 12F683 is supported is there any chance of supporting PWM? :)
Wed Apr 17 2019, 23:19:25
(no subject) (by José GILLES)
To Arturo:

No news, good news ?

To Alex:

Try joined ld file which is more simple (no Look-up table)
with joined executable which is a corrected version of
in zip file

It perfectly compiles to hex for PIC16F877 on my computer !
Why not on yours ?

Thu Apr 18 2019, 04:13:00, download attachment ldmicro.zip
(no subject) (by Alex)
thanks for your reply José GUILLES, i generated hex file :) with i tested on my pic 16f877a with old lcd with i2c module but there is nothing printed, what does it have to be printed on lcd? 0XA0

, i will test ds3231 with wit
Thu Apr 18 2019, 09:44:40
(no subject) (by Alex)
Thu Apr 18 2019, 10:24:08
(no subject) (by Arturo)
Hello José GILLES problem solved.

I had renamed the LdMicro folder with the name of LdMicro 5304.
I have changed the name to LdMicro_5304 and it works.

Thank you so much for everything.
Thu Apr 18 2019, 11:16:37
(no subject) (by José GILLES)
To Arturo:

Perfect !!!

To Alex:

I can't test on a True PIC because my board is not working.
But I tested the same ladder on a true AtMega328, it works and displays:

XXXXXXXXXX on the 1st line
0 on the 2nd line

As expected !
0xA0 is a move command (read LcdI2cLib-xx.txt in lib folder)

It also works in ldmicro simulator.
I'll test in a PIC simulateur as soon as possible...

But :
YOU MAY HAVE TO CHANGE I2C ADDRESS of your module in the
ladder I2C instructions ; mine is 0x20, yours may be 0x27 or somthing else according to ist documentation !

Test it with MY executable not with official version.
Thu Apr 18 2019, 13:55:50
(no subject) (by Alex)
thanks , i tried to change I2C ADDRESS to 0x27, but ldmicro doesn´t store that value, it is even not showned 0x20 , should i change to 0x27 in library?

Thu Apr 18 2019, 15:40:29
(no subject) (by José GILLES)
To Alex:

I think I know what's wrong for you with LCD16x2...

I suppose you didn't modify LCD_I2C_ADR in I2cLib.c
It's explained in LcdI2cLib-xx.txt that you must set this value
(0 by default) to the I2C address of your I2C Expander
ie the same address used in the ladder (0x20 or 0x27 maybe)

First modify it in HTC\lib\I2cLib.c, run flashMCU.bat again
and test new hex file
If you modify this value in LIBRARIES_FOR\PIC16\I2cLib.c, change will be permanent for future projects.

Anyway, you MUST read LcdI2cLib-xx.txt in lib folder (theres's a spanish version) to understand how it works.
You just don't have to copy files because it's automatic now.
Thu Apr 18 2019, 15:46:04
(no subject) (by Alex)
i am using
Thu Apr 18 2019, 15:56:32
(no subject) (by Arturo)
Hello José GILLES, you can use i2c_lcd16x2 with variables type counters.

Thank you.
Thu Apr 18 2019, 17:18:35
(no subject) (by José GILLES)
To Alex:

There a bug in 5.3.0.x concerning I2C parameters for PICs.
That's why I send a modified version to you...
Try with this one.
Fri Apr 19 2019, 07:02:45
7 segmet (by s.meiyazhakan)
how to use 7segmet example
Sat Apr 20 2019, 02:09:43
7 segmet (by s.meiyazhakan)
how to use 7segmet example
Sat Apr 20 2019, 02:11:18
(no subject) (by MGP)
S.meiyazhakan, there is no topic that has been written about so much, including examples, than about 7segment displays and how to program them but you have to make some effort to search this forum.

A simple example can be found here:
Sat Apr 20 2019, 02:40:45
(no subject) (by Alex)
thanks José GUILLES it stores my 0x27 address reg :) it compiles hex , but nothing printed:

in "HTC\lib\I2cLib.c" address reg is with 0x27, it is ok generated lib


backlight is turned off, how can i turn it on?
Sat Apr 20 2019, 03:59:28
(no subject) (by José GILLES)
To Alex:

Can you remind me of your display harware ?

- I2C Expander PCF8574 ? (that's what I use)
- Display 16x2 ? (Idem)

Something like in attached doc ?

1) I think backlight is not important for the time being.
You can light it with 5V power between pins 15-16.
But is your display well powered between pins 1 and 2 ?

2) Did you have it working with Arduino environment (and LiquidCrystal library) ?
There's an example in attached file.

3) Are you sure that its I2C address is 0x27 ?
Sat Apr 20 2019, 11:43:42, download attachment Gotronic-lcd16x2.pdf
(no subject) (by Alex)
Hello José GUILLES :

-My module is pcf8574at
-My lcd is Hitachi HD44780


1) Yes, my pic module has 5vdc output for pcf8574at which energizes lcd hitachi

2) Yes, i have used it before with arduino


3) Yes, i have tested with "I2C scanner" code to see REG ADDRESS

Sat Apr 20 2019, 22:34:55
(no subject) (by José GILLES)
Thanks Alex for these informations.

I think I have an idea of the pb !

Pin assignment in my library doesn't seem to match arduino's one (although I thought it did)

In your project, open the file lib\LcdI2cLib.h
and modify the first lines of the file to have the values:

#define BIT_LCD_RS 0 // bit ... pin RS du LCD
#define BIT_LCD_E 2 // bit ... pin E du LCD
#define BIT_LCD_D4 4 // bit ... pin D4 du LCD
#define BIT_LCD_D5 5 // bit ... pin D5 du LCD
#define BIT_LCD_D6 6 // bit ... pin D6 du LCD
#define BIT_LCD_D7 7 // bit ... pin D7 du LCD

Then run flashMCU.bat again, flash your target and let me know if something appears !

I Hope it should work...
Sun Apr 21 2019, 04:20:38
(no subject) (by Alex)
Hello José GUILLES, you said "Pin assignment in my library doesn't seem to match arduino's one" but i am using pic16f877a, i tested arduino uno anyway with modified pins in file lib\LcdI2cLib.h as you said but i think it has same problem when i coulnd´t generate bin file for pic with, your modified version generates hex file in bin when usin pic16f877a but when i use atmega328 it generates empty bin file and 0x27 in ladder is not stored in library in lib file, it does with pic:

P.D. i "only" changed:

@rem SET GCC_PATH=C:\Program Files (x86)\Atmel\AVR Studio 5.0\AVR Toolchain (my path for atmel studio)

video for lcd and atmega328 arduino uno:


in lib\LcdI2cLib.h for pic i changed those values you told me to, it looked like the same file (same default lcd pins as in atmel)

video for lcd and pic16f877a:

Sun Apr 21 2019, 15:44:54
(no subject) (by Alex)
sorry if i confuse things, i try to do what manual says as far as i understan, and with help of ldmicro comunity
Sun Apr 21 2019, 15:46:16
add Stm32f103c8 (by Alejandro Montagna)
Add Stm32f103c8 chip to this project would be a bomb that pumps.
  greetings to all and felisitasioness for this great project
Alejandro Montagna
Sun Apr 21 2019, 18:38:17
(no subject) (by José GILLES)
To Alejandro:

You can use STM32F407 with ldmicro...

To Alex:

Your Lcd-I2c-16x2 module is designed for use with Arduino ; and it works with it as you said. In LiquiCrystal libraries I had found some default values for pin assignment between PCF8574 outputs (P0-P7) and LCD display inputs (E, RS, RW and Data).

BUT in fact these stupid default values are not the ones really used ! Right values must be the ones I told you above. If you want to be sure, check your module and verify which ouputs of PCF8574 are bound to which input on LCD display (and tell me).

DON'T go back to AtMega328 for the time being !

I think we're not so far from the solution with PIC16F877.
You video shows that you have modified lcdI2cLib.c
BUT nobody told that !!!
you MUST restore these two lines as they were:

static unsigned char port = 0; // ...
static int lcd_i2c_adr = 0; // ...

You should even delete the file and get it back from original in LIBRARIES_FOR\PIC16F

Modifying "port" value is catastrophic, and it can't work with your value àf 0x27 !!!

Retry and I guess it'll be OK...
Mon Apr 22 2019, 03:25:33
(no subject) (by bfwolf)

Supporting STM32F103C8 dirctly would be great! ;-)
It's very common and very cheap with the "Blue Pill" board:

You could even make the board's pins available by menue-configuration..
Mon Apr 22 2019, 06:51:17
(no subject) (by Alex)
Thanks for your reply José GUILLES, i deleted all generated files and left only ladder program for lcd i2c , did it all again, but this time i "only" changed pin assigment in PIC16\LcdI2cLib.h to generate in lib\LcdI2cLib.h:

#define BIT_LCD_RS 0 // bit ... pin RS du LCD
#define BIT_LCD_E 2 // bit ... pin E du LCD
#define BIT_LCD_D4 4 // bit ... pin D4 du LCD
#define BIT_LCD_D5 5 // bit ... pin D5 du LCD
#define BIT_LCD_D6 6 // bit ... pin D6 du LCD
#define BIT_LCD_D7 7 // bit ... pin D7 du LCD

it also generated files in lcdI2cLib.c with:

static unsigned char port = 0; // ...
static int lcd_i2c_adr = 0; // ...

here is a video of what i dit, i still can´t print on my lcd, maybe i could change to "hello world" message:


I also attach my pcf8574at module scheme
Mon Apr 22 2019, 14:49:22, download attachment PCF8574T pinout scheme.pdf
(no subject) (by José GILLES)

OK Alex

Your pinout is OK (as expected now)
But it was only necessary to reset LcdI2clib.c ...

Your LcdI2cLib.h seems ok (matches your pinout)

But what about I2cLib.c:
Is your I2c address at 0x27 ? (Probably back at default 0x20).
You must have in I2cLib.c:

#ifndef LCD_I2C_ADR
#define LCD_I2C_ADR 0x27 // ...

If not, modify and retry...
If yes => I don't understand what may still not work !
Mon Apr 22 2019, 16:07:42
(no subject) (by Alex)
thanks for your reply José GUILLES. i have made the 2 important changes at the end, tha´s all i could do:

1) changed pinout (OK)
2) changed in I2cLib.c to:

#ifndef LCD_I2C_ADR
#define LCD_I2C_ADR 0x27 // ...

i think i have found a problem, not main problem but a problem,
i have always been compiling for Hi Tech and flashing mcu.bat and finally testing with my pic 16f877a
everytime i made some change in some library, i found this:

- if i compile for High Tech and call flashMcu.bat "WITHOUT JUST" openning MCU parameters option, config bits in i2c_lcd16x2bis ansi c code is "0x0" (i have always been testing like this in my pic...)

- if i compile for High Tech and call flashMcu.bat "WITH JUST" openning MCU parameters option, config bits in i2c_lcd16x2bis ansi c code is "0x3F72"

It's worth say that after loading hex to my pic with 0x3F72 config bits, my lcd at least was with backlight OFF, so at least in changed, with 0x0 nothing happened, lol

Here is a video explanation of what i said, watch please:

Mon Apr 22 2019, 23:11:14
(no subject) (by Alex)
I have tested with all main changes that i did in your ldmicro version José GUILLES,

1)changed pinout for my module

2)then changed:

#ifndef LCD_I2C_ADR
#define LCD_I2C_ADR 0x27 // ...

Ldmicro version generated hex file :)

and after loading hex to my lcd is doing like this :


it is like your version using

i want to try on arduino uno board, using
Mon Apr 22 2019, 23:36:37
(no subject) (by Alex)
thanks for all your help and patient José GUILLES,i don´t know what happens, i´ll be patient till some release or someone make a tutorial o till i can figure it out what´s wrong
Tue Apr 23 2019, 00:04:32
(no subject) (by José GILLES)

Hi Alex

1) You're right, there's a bug in __CONFIG() for PICs in .c and also the same in CFG_WORD for PICs in ladder.h

I have identified the pb ; its due to a modification made by Ihor on configuration bits handling in version or 2.
I'll notice him changes to make to correct this !

2) I don't know why your LCD does still not work with I2C...
BUT, I have ordered on eBay such a module, so that I can test it by myself, and hope make it work !
I'll get it within a few days...
Tue Apr 23 2019, 03:26:50
(no subject) (by José GILLES)
To Alex:

I have verified ldmicro source code ; in fact __CONFIG() pb is not really due to a bug in configuration bits handling as I thought !
The pb is just that Config panel doesn't reflect what is stored in ld file if value is 0...

It's just that in i2c_lcd16x2bis.ld, config bits are 0.

It's abnormal, but probably due to the fact that this file was derived from an AVR file, in which config bits are 0 by default.
That's my fault.

To correct this you just have to open the ladder in ldmicro, go to MCU parameters to get 0x3F72 value and then SAVE the ladder.

Of course display couln't work with such a value ...
Tue Apr 23 2019, 04:15:43
(no subject) (by Ihor Nehrutsa)
to Alex
Try looking at the LCD from a different angle.
At 5V power supply, the contrast should be slightly reduced.
Tue Apr 23 2019, 08:36:53, download attachment 8316dd65fc484fd48d2f599c5d010520.JPG
(no subject) (by Alex)
thanks for your reply Ihor Nehrutsa, i saw in different angle at my lcd, still the same, generates files correctly, every time i plug and unplug my module for 5vdc my lcd turns off bakclight inmediatly


pleas someone could test José GUILLES´s ladder for I2C module unsing pic16f877a, ladder attach
Wed Apr 24 2019, 00:43:17, download attachment i2c_lcd16x2bis_PIC_5.3.0.4.ld
(no subject) (by Ihor Nehrutsa)
to Alex
Can you check the pinout connection between PCF8574 and
Thu Apr 25 2019, 03:20:06, download attachment Shema.png
(no subject) (by Alex)
To Ihor

Yes, i have checked continuity, it is different from image above:

RS ->P0 (pin4)
RW ->P1 (pin5)
EN ->P2 (pin6)
Not connected ->P3 (pin7)
D4 ->P4 (pin9)
D5 ->P5 (pin10)
D6 ->P6 (pin11)
D7 ->p7 (pin12)
Thu Apr 25 2019, 10:18:53
(no subject) (by José GILLES)

To Alex and Ihor:

I'm testing I2C with a new PIC board equiped for the time being with a PIC18F4520 (waiting for PIC16F877, which is pin compatible with this one) and Hi-Tech-C.

Peripherals are very similar and libraries are quite identical for these two targets

1) I2C library works fine with a DS1307.

2) I2C-LCD doesn't work at this moment, confirming our problems...
But I think I know what's wrong: Hi-Tech-C (alias PIC-C) doesn't support recursivity because it uses "compiled stacks" instead of a true stack in function calls.

In fact there is just in LCD-I2C library a pseudo and indirect recursive call by I2C_MasterSetReg() to itself when sending LCD commands.

In Hi-Tech-C for PIC18, it generates an error => no possible test ; I'm presently testing a way to override the problem...

In Hi-Tech-C for PIC16, recursivity only generates warnings, which you can see in ldmicro when calling flashMcu.bat ; I thought these warnings were not important, but in fact they are ! And they probably explain our problems !
We can test resulting program, but it can't work because of these stack problems.

3) An identified problem is half solved...

Thu Apr 25 2019, 16:34:26
(no subject) (by José GILLES)
To Alex:

I2C-LCD16x2 display problem with PICs is solved !

I have made it work with a PIC18F4520 (see attached jpg) by overriding pseudo recursivity problems in Hi-Tech-C.

It should work as well with PIC16F877 and others, but I'll wait to have the required hardware to test it with ldmicro before publishing sources...
Fri Apr 26 2019, 03:51:18, download attachment I2C-LCD-PIC18F.jpg
(no subject) (by Alex)
thank your very much José GUILLES, can´t wait to test it when release, but i´ll be patient.

P.D. your PCF8574 is in the back of your PCB?
Fri Apr 26 2019, 08:47:11
(no subject) (by José GILLES)
To Alex:

Yes, PCF8574 is not visible, at the back of my PCB.

I've just received today a couple of PIC16F877A, so that I'll be able to test my new version of I2C-LCD library.
I'll let you know if it works on this thread...

I'm still waiting for a "true" I2C-LCD Display for Arduino, but I think it won't be very usefull now.

To be continued...
Fri Apr 26 2019, 13:47:16
(no subject) (by Alex)
i´ll wait :)

I have tested i2c ds3231 with ldmicro32 for arduino in the past and i printed values using serial lcd, worked ok:


this time i did it with pic16f877a and using same ladder, i just changed crystal to 20mhz and pic of course,but when compiling for pic i got message again about warning in cmd box and serial lcd doesn´t work either, it should be cleared at least, in my lcd just shows up default message" SERIAL LCD V2.2" but in my ladder i delete that message with delete command but nothing happens either.

Ladder attach
Fri Apr 26 2019, 22:44:45, download attachment test-i2c-hour-min-test2-
(no subject) (by Alex)
here is serial lcd interface if you want to try in on proteus
Fri Apr 26 2019, 22:46:27, download attachment serial_lcd_proteus.pdsprj
(no subject) (by Alex)
and here hex for 16f628a lcd interface
Fri Apr 26 2019, 22:47:53, download attachment LCDSERIAL628-v2_2_MCLRE.hex
(no subject) (by José GILLES)
To Alex (and Ihor):

Let's first solve I2C-LCD display pb, and then we'll have a look at your DS3231...

I2C-LCD now WORKS on PIC16F877 (and probably some others...) under Ldmicro !!!

To achieve this I have had to modify deeply I2C libraries for PICs, because of stack problems explained above.
There remains one warning about a possible stack collision during compiling with Hi-Tech C, but it doen't prevent programs to work.
To eliminate this warning I'll have to modify Ldmicro sources to reduce stack depth usage in generated C file ; because Hi-Tech C also uses in fact a very little true stack, but only to store return addresses in function calls...
I'll see it with Ihor for version

For the time being, you can test I2C-LCD on PIC16F877 with Ldmicro, by replacing all I2C libraries by the ones attached in zip file (in lib and LIBRARIES_FOR folders)

Don't forget to modify LCD_I2C_ADR (0x27) to match your module address, now in I2cLib.h instead of I2cLib.c
If you modify it in LIBRARIES_FOR, I2C-LCD functions will be activated in any project using I2C (but take some memory !)

Please try with i2c_lcd16x2bis and let me know !
It has worked for me juste 5 min ago...
It displays 10 'X' on the first line and a 0 one the second one.
Sat Apr 27 2019, 13:06:27, download attachment LCdI2C-Pic.zip
(no subject) (by José GILLES)
To Alex:

For your DS3231:

When you don't use I2C-LCD functions, but only I2C, you should disable them by resetting LCD_I2C_ADR to 0 in library.

I have tried my DS1307 with new I2Clibraries on PIC16F877, and I2C-LCD library activated or deactivated ; it works anyway in both cases ; but it takes of course more memory if activated (but unused) !!!
Sat Apr 27 2019, 13:19:23
add 12f629 (by Najib Elyenyari)
if you can for add 12f629 8pin
Sat Apr 27 2019, 18:00:13
(no subject) (by Alex)

You were right, it works, thanks :)
Sat Apr 27 2019, 20:47:29
(no subject) (by Alex)
i wanted to use a reset button, that set timer to 0: 0: 0 , i used I2C write, i can set value 0 but i can´t set reg address, do i have to set in library too?

watch video please:

Sat Apr 27 2019, 21:04:27
(no subject) (by José GILLES)

Alex, remember... there's a bug in I2C dialog box of version 5.3.0.x which prevents users from modifying fields...

1st solution:

Edit your ladder file in text mode and modify the values,
and then reopen it in ldmicro (boring)

2nd solution:

Use modified executable of last version joined here, in which the bug is rectified ; I've just tested it OK on PIC16F877 with IC2-LCD and DS1307.

We'll solve all these pbs on I2C for PICs with Ihor in next version.
Sun Apr 28 2019, 03:20:51, download attachment LdMicro-
(no subject) (by Alex)
thanks José GUILLES i been late because i was trying to do it well,

1) I used libraries from your attach file above "LCdI2C-Pic.zip"

2) I set 0x27 in LcdI2cLib.c which is in zip file too, i coulnd´t find:

#ifndef LCD_I2C_ADR
#define LCD_I2C_ADR 0x27 // ...

So instead i change 0x27 here (i am just a ldmicro user):

unsigned char port= 0x27; // adaptation pour IO-Expander I2C

3) Pinout of my lcd and pcf8574at are ok

3) Compiled ok, generated hex

4) test in my lcd:

Mon Apr 29 2019, 20:10:56
(no subject) (by José GILLES)
Hi Alex

Please read again instructions above carefully...

1) #define LCD_I2C_ADR 0x27 // ...
is to set in I2CLIB.H not in any other file

2) don't touch, as already said:
unsigned char port= 0;

3) retry
Tue Apr 30 2019, 02:16:12
(no subject) (by Alex)
Thanks for your help José GUILLES, it worked, it printed
values as made in ladder you gave as example:


P.D. if i want to print "hello", do i have t do it in send variable: 'hello' ?
Tue Apr 30 2019, 10:36:00, download attachment print hello.jpg
(no subject) (by José GILLES)
To Alex:

I2C_WR can only write one char at a time.

To write a string you must do several writes ; you can use a Look-Up table to simplify, as in attached example (tested OK)

BUT: Only use my version because of a bug with look-up tables for PICs in C mode in standard versions...
Wed May 1 2019, 05:48:10, download attachment i2c_lcd16x2.ld
(no subject) (by Oleksiy)

I think you should join to LDmicro team in GitHub because in opposite we always will have such issues with multiple versions.
Thu May 2 2019, 10:08:33
(no subject) (by José GILLES)

Hi Oleksiy

I'm in contact yet with Ihor on Github.
The temporary version above is just made to test some functionalities and try to publish a new version of ldmicro which will work fine.
I have sent to Ihor required modifications, and I hope he'll publish a official release soon...

Fri May 3 2019, 03:07:04
(no subject) (by Oleksiy)

I know that you in contact with Ihor.
I invite you to start to send your changes through a pull request and synchronise your development repo with the main one.
Fri May 3 2019, 03:30:23
(no subject) (by José GILLES)

When it's only a few lines to modify, I generally send info to Ihor, who updates his files on Github.
Sat May 4 2019, 01:36:44
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):