Atmega8 and i2c to an LCD display

Go To Last Post
11 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I really did look around this forum but I don't see exactly what I am looking for. I want to use CVAVR with its native libraries if possible.  I have atmega 8s and an atmega 328, plus a bunch of the attinys.  I'd like to use the mega8 for this.

I am looking for the absolute minimalist, simplest way to just print anything to the i2c dispay , Hello world would be fine. The LCD I have PCF8574T enabled for the I2C 0x27 is the address.  This is my first look at i2c , in "C" and I really don't want to use any audreno sketches.

Can some one share this information with me?

 

Thanks

This topic has a solution.
Last Edited: Tue. Jun 28, 2022 - 04:35 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

CVAVR has libraries for the LCD e.g.

#include <alcd_twi.h>

 

and it has examples for you.   As well as comprehensive Help.

 

You can either adapt the snippets from the Library Help.

Or let the CodeWizard do everything for you.

 

Either way you will find that you can reduce the program down to a few lines.

e.g. #include, init(), print("Hello World");

 

I suggest that you run as many of the CVAVR example programs as you can.

Ask if you need help for porting to mega8 or mega328

 

Ask if you need assistance with adapting the snippets from the Library Help.

 

Life is not as easy as Arduino but it is much quicker to get up and running than with GCC.

 

David.

Last Edited: Tue. Jun 28, 2022 - 02:07 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Any reason for using PCF8574T i2c port expander? When atmega8 has i2c built it.

“Everyone knows that debugging is twice as hard as writing a program in the first place. So if you're as clever as you can be when you write it, how will you ever debug it?” - Brian W. Kernighan
“Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away.” - Antoine de Saint-Exupery

Last Edited: Tue. Jun 28, 2022 - 02:26 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Heisen,

 

The LCD I bought for this is a 1602 type with an i2c adapter glued on. The adapter uses the PCFxx part.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

If your lcd is hd44780, then you can try this library.

 

Davide Gironi's I2C LCD library based on  PCF8574

 

http://davidegironi.blogspot.com/2013/06/an-avr-atmega-library-for-hd44780-based.html#.YrsTqnZByUk

“Everyone knows that debugging is twice as hard as writing a program in the first place. So if you're as clever as you can be when you write it, how will you ever debug it?” - Brian W. Kernighan
“Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away.” - Antoine de Saint-Exupery

Last Edited: Tue. Jun 28, 2022 - 02:50 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Heisen wrote:
Any reason for using PCF8574T i2c port expander? When atmega8 has i2c built it.

You waste 6 GPIO pins on a Character LCD.   You only use 2 TWI pins when there is an I2C backpack.

 

Whether it is Arduino or CVAVR there are libraries that look after both types of LCD.   Easy to configure GPIO pins via a GUI in CVAVR or via a constructor statement in Arduino.

 

Whereas there are plenty of GCC libraries and examples they all require time and effort to get them working in your project.

 

David.

 

p.s.  please post a link or a photo of your backpack.   It is probably YwRobot type.   You need to tick the correct box in CV GUI.

Last Edited: Tue. Jun 28, 2022 - 02:51 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

David,

Thanks for the reply. I started out looking for simple examples at HPinfo example site, as far as I could see there were no examples of i2c with an LCD, there are plenty of examples of i2c to other devices and I can extract master and slave concepts , i mean I already have done this years ago with temperature sensors but I was using Bascom basic then so same concept. Thats why I came here for help. Every where I look they want me to use Arduino stuff.   So if you could give a hint where I might start looking for the examples and compressive help, that would be great! I am looking specifically for CVAVR examples

 

Thanks,

 

Alan

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

David,

 

This is what I am using

 

https://www.amazon.com/ALMOCN-Di...

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The library in post #5 will do the job.

“Everyone knows that debugging is twice as hard as writing a program in the first place. So if you're as clever as you can be when you write it, how will you ever debug it?” - Brian W. Kernighan
“Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away.” - Antoine de Saint-Exupery

This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0


Have you looked in the examples directory installed on your PC under your CVAVR installation?

 

#1 Hardware Problem? https://www.avrfreaks.net/forum/...

#2 Hardware Problem? Read AVR042.

#3 All grounds are not created equal

#4 Have you proved your chip is running at xxMHz?

#5 "If you think you need floating point to solve the problem then you don't understand the problem. If you really do need floating point then you have a problem you do not understand."

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

Brian,

 

Holly carp! you wont believe this , I looked there and nothing useful, so I moved on.  Then I saw your post and double checked, nope. But having seen it on your screen shot I knew instantly.  I am on my main PC a win 8 desktop.  I jumped over to my win 10 laptop .

 

CVAVR 3.25 on win 8.1 CVAVR 3.48B on win 10.

 

The example on my laptop is EXACTLY what I was looking for right smack down to the "Hello World" msg.  And just using the native CVAVR Lib.

 

Thanks, just what I was looking for,

 

Alan