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

LDmicro Forum - New I2C functions in ldmicro for ARMs and AVRs

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

New I2C functions in ldmicro for ARMs and AVRs (by José GILLES)
Here's a new version of my ldmicro, which supports I2C via C programming for ARMs and AVR targets (ATMegas).

There are two new I2C functions, to read or write one byte in an I2C peripheral register. Peripheral can be selected by its I2C address.

For the time being I have just had time to test it with a true DS1307 I2C real time clock, and it worked... but it needs to be tested further more.

The principle is the same as for previous versions (see HowTo in zip file), with external I2C libraries.

Be aware that I2C peripherals (ie DS1307) can be very slow even at high speed (100 KHz), and have a look at cycle timing !!!

Try and let me know about your experience.

Sat Dec 29 2018, 17:49:32, download attachment LdMicro32.zip
(no subject) (by John)
Hi, you could put a simple example hello world in 12C.

Thank you great job.

Sun Dec 30 2018, 04:22:30
(no subject) (by José GILLES)
Yes, but I2C is not really made to communicate with displays ; rather with sensors, expanders...
Sun Dec 30 2018, 12:15:20
(no subject) (by John)
OK thanks.
You know how I could connectSerial I2C 1602 16×2 Character LCD Module
Sun Dec 30 2018, 12:41:00, download attachment 1.jpg
(no subject) (by José GILLES)

I suppose you want to connect this display to an arduino board ?

Theoritically, it shoudn't be very difficult because:

- 16x2 LCD displays are well known and many libraries are available to make them work
- PCF8574 is just an 8-bit I2C IO expander connected to pins
E, RW, RS (command lines) and D4-D7 (data lines in 4-bit mode)
of the display
- I2C wiring is available on the Net

But I think itsn't worth trying to do it because these displays are very slow (all the more in 4-bit mode), and I2C interface will make it slower, so that it won't work in ldmicro, unless you have a huge cycle time !

Sun Dec 30 2018, 16:15:07
(no subject) (by John)
OK thanks.
Sun Dec 30 2018, 22:19:39
(no subject) (by Ahmad sakr)
To jose
Is it possible to make ldmicro work directly with parallel lcd. As I know that ldmicro deal only with serial lcd.
Mon Dec 31 2018, 02:10:14
(no subject) (by José GILLES)

I guess you can use directly a parallel 16x2 LCD display, but it remains the same pb: it needs wait states between commands and it's very slow.

To avoid it you may have another µC driving the display, to which you send formatted text (from time to time) via Uart, Spi, I2c...
Mon Dec 31 2018, 02:42:08
(no subject) (by Ahmad sakr)
I am using parallel lcd with ldmicro by compiling the sketch to arduino then in arduino ide I add the message by using arduino instructions and it works good.
What I need and asking for is to make ldmicro deal with parallel lcd like arduino ide without using any other software or microcontroller or shift register.
Thanks for your great work
Mon Dec 31 2018, 11:52:12
(no subject) (by José GILLES)

Yes, its possible, but needs to had new functions for LCD16x2...
in ldmicro => much work

In your case, do you send many messages to your display, or just from time to time ?
And what is your cycle timing ?

Mon Dec 31 2018, 12:09:00
(no subject) (by Tami Duke)
Hi..LDmicro allow you to make your ladder schematic then to generate HEX code which does the ladder logic implementation in program code which you program to your AVR or PIC and got the ladder logic functionality.
Wed Jan 9 2019, 13:22:43
Example I2C (by EDAM)
Hi you could put a simple example to communicate with other arduino in 12C.
Thank you.
Wed Mar 6 2019, 18:32:42
(no subject) (by José GILLES)
I2C under ldmicro works only in master mode.
To communicate, you must have a master and a slave...

It's designed here to drive sensors.

Fri Mar 8 2019, 02:58:49
i2c (by Segar Segar)
HI,Any have example i2c progarmming with 16X2 LCD display

Tue Apr 23 2019, 02:28:30
i2c (by Segar )
HI,Any one have example i2c progarmming with 16X2 LCD display

Thank you
Tue Apr 23 2019, 02:29:43
(no subject) (by José GILLES)

I'm dealing on another thread with driving 16x2 LCD via I2C.
It works for me on ARM and AVR (AtMega 16, 328) and I'll test on PIC16F as soon as possible.

It requires to compile via C libraries.

I have some examples, but tell me before:

- your MCU target ?
- your LCD-I2C hardware ?

Tue Apr 23 2019, 06:13:30
New I2C functions in ldmicro for ARMs and AVRs (by José GILLES) (by Moin ud din)
José GILLES please make a video for installation procedure as you mention in you file i could not understand.
Fri Jul 12 2019, 08:54:53
(no subject) (by José GILLES)
Sorry but I don't have time to make videos now.

First explain your pb:
What do you want to do ? MCU Target ? I2C Hardware ?

Sat Jul 13 2019, 16:18:48
RTC (by Mayo)
HI,Any one have example i2c progarmming with DS1307.
Sat Jul 20 2019, 14:37:16
(no subject) (by José GILLES)

I have some examples working with DS1307 ; but for which kind of target ? ARM, AVR or PIC ?

Yesterday, 02:42:10
RTC (by Mayo)
Thanks to reply
My target Pic ,876,877
Yesterday, 11:28:18
(no subject) (by José GILLES)

Here's an example for Pic16F877 on ldmicro
It just reads seconds in register 0 and sends values over UART ;
minutes and seconds can be read in registers 1 and 2 and date in the following ones in the same manner...

Don't use another version, and download corresponding C libraries if you want it to work fine:


Yesterday, 12:59:33, download attachment i2c_ds1307.ld
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):