atmega4809 HD44780

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

Hey Guys

 

I've really tried to figure this out with no luck. 

I'm trying to configure this library to work with the atmega4809.

https://github.com/Moji14/megaAVR-0-Series-LCD-library

 

I've set my pins to the correct pins in the header file but it doesn't seem to be working. 

Seems like something else in the library isn't working right. 

 

Just trying to get the example working with no luck. 

Please help!! 

 

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

To start post YOUR code and maybe a diagram of the board you are working with.

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

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

What is F_CPU set to?

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

I'm just trying to get the example code in the link I provided. 

 

I have this set to

#define F_CPU 1000000

 

DB4-7 is assigned to PD1-4

 

E and RS are assigned to PA4 & PA5

 

I've confirmed the physical layout is correct with a arduino test code but when I try to use this library 

it doesn't work. 

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

matthews effects wrote:
#define F_CPU 1000000

you micro runs at 16 or 20MHz so this needs to match your actual speed.

 

jim

 

Click Link: Get Free Stock: Retire early! PM for strategy

share.robinhood.com/jamesc3274
get $5 free gold/silver https://www.onegold.com/join/713...

 

 

 

 

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

Good Point! 

Changed it still doesn't work unfortunately. 

 

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

matthews effects wrote:

Good Point! 

Changed it still doesn't work unfortunately. 

 

 

Doesnt work is not helpful problem description.

 

LCD displays are fussy about timing, so if I remember correctly the 0 series has a fuse setting that divides the clock by 6, and is set by default. You need to know what the actual clock speed is.

once you know that then getting the display to work is easy.

jim

 

Click Link: Get Free Stock: Retire early! PM for strategy

share.robinhood.com/jamesc3274
get $5 free gold/silver https://www.onegold.com/join/713...

 

 

 

 

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

The first thing that you need to do to get AVR working with any external device is to use an Arduino UNO/Nano with one of the example programs that will be found in the library that you downloaded for that device. Review the example program to find the hardware pin-out needed to get the device connected to the Nano module board.  Usually, if you connect the device according to the description in the example code, it will start functioning correctly.

 

The next to ask is why are you not going to simply use the Nano board for your design instead of the new AVR-whatever when the Nano sells on eBay for about $3 which is more-or-less the device  price of the CPU IC from any of the electronics distributors.  Consider all the working code, libraries, and integrated development expertise that is available for the Nano that you won't be getting when you decide to use the AVRmega-whatever instead.  Need more memory and I/O?  Go with the Arduino Mega.  Need integrated USB?  Use a Leonardo. Need more speed?  Use a ARM or WeMOS Arduino.

 

Now you are ready to spend hours trying to get standard and simple library code working on the AVRmega-whatever that you decided for some reason to use instead of the Nano.

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

Simonetta wrote:

The first thing that you need to do to get AVR working with any external device is to use an Arduino UNO/Nano with one of the example programs that will be found in the library that you downloaded for that device. Review the example program to find the hardware pin-out needed to get the device connected to the Nano module board.  Usually, if you connect the device according to the description in the example code, it will start functioning correctly.

 

The next to ask is why are you not going to simply use the Nano board for your design instead of the new AVR-whatever when the Nano sells on eBay for about $3 which is more-or-less the device  price of the CPU IC from any of the electronics distributors.  Consider all the working code, libraries, and integrated development expertise that is available for the Nano that you won't be getting when you decide to use the AVRmega-whatever instead.  Need more memory and I/O?  Go with the Arduino Mega.  Need integrated USB?  Use a Leonardo. Need more speed?  Use a ARM or WeMOS Arduino.

 

Now you are ready to spend hours trying to get standard and simple library code working on the AVRmega-whatever that you decided for some reason to use instead of the Nano.

 

 

ummmm no. Arduino is too bloated and was too inaccurate for my project. The physical layout has been verified using arduino and its library so it should simply be a setting. Hoping its the timing as previously mentioned. 

 

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

LCD displays are fussy about timing

The 44780 controller is only fussy if you try to go too fast....you can send chars & commands every hour & it will be happy....but if you issue a reset & don't wait xxx ms, you will be  in the dumpster. 

so go slow for initial hookup...it will avoid any issue (other than slow displays of messages).

 

Have you done any scoping to see that anything is actually happening with all of the lines?  Ensure LCD power, gnd,& contrast are all set up as well....some old display's require a negative contrast voltage to make things visible.

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

Last Edited: Sat. Dec 14, 2019 - 10:44 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The 4809 will not run at 16MHz or 20MHz by default since the reset value of the chip will /6 so the default F_CPU is 2666666 or 3333333.

Note the "Reset" value below.

 

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

F_CPU is set to  3333333

 

No editing of the cpu has produced anything yet with the sample software. 

I'm out of ideas on what to do with it. 

 

I'm not even sure this library works the way its written with the 4809. 

 

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

matthews effects wrote:

F_CPU is set to  3333333

 

 

F_CPU does NOT change the speed/clock of the MCU (cpu).

It informs the compiler/libraries what speed the MCU is running, in order for the compiler/libraries to generate correct delays etc.

 

So you MUST match F_CPU to the speed your AVR is running , NOT assume that you can change the MCU frequency via that variable.

 

What speed is your avr running ??

 

Is it a board you bought or is it something you have built ?

 

 

Last Edited: Sun. Dec 15, 2019 - 08:10 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Bingo600 wrote:

matthews effects wrote:

 

F_CPU is set to  3333333

 

 

F_CPU does NOT change the speed/clock of the MCU (cpu).

It informs the compiler/libraries what speed the MCU is running, in order for the compiler/libraries to generate correct delays etc.

 

So you MUST match F_CPU to the speed your AVR is running , NOT assume that you can change the MCU frequency via that variable.

 

 

 

Yeah thats not what I said i did. Previous people stated it would work fine if you set it so it ran slower. I played with that for a couple moments to try to 

get any kind of reaction with no luck. 

 

Cant get the example code to work at all. 

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

The problem is also that as-is from the github files, the F_CPU is defined in the test file, but nowhere else.

 

Setting F_CPU in main does nothing for the use of delay in the lcd.c file, so you get the default 1MHz and a warning. Since you are at 3.33MHz, the delay used in the lcd.c file will be 3 times too fast.

 

As a temp fix, you can define F_CPU in lcd.h, which will then require the include "lcd.h" be before include <util/delay.h> in both lcd.c and main.c, which will then get you one F_CPU value for everyone. A better solution is to use a compiler option like -DF_CPU=3333333 where everyone gets the same value and no longer needs to be set in file(s).

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

Ohhhhhhh that might be it then!

I'll give that a try! 

Thank you! 

 

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

it seems the library is trying to read/write the lcd and I had rw tide to ground on the lcd. 

Thanks guys.