MEGA2560 and LCD problem

  • 1
  • 2
  • Page 1 of 2
SCART_PL
 
Avatar
 
Subject:

MEGA2560 and LCD problem

 · 
Posted: 10.11.2016 - 13:44  ·  #1
Hello everybody,

I have a new account on the forum but I am not new to AVRco.
I decided to renew my older designs and I have a problem with MEGA2560 and LCD display.
In this case, I use the standard library for HD 44780 display, 4x20 characters. Instruction LCDOUT ('A') is working properly but Write (LCDOUT, 'ABC') is no longer. After following the instruction the whole screen is black (black block instead of characters). After many hours of testing (even with logic analyzer) and many e-mails with Rolf (Rolf, thank you for your help) still nothing explained. The last test was a compilation of the program to other processors such as MEGA640 and 1280 and loading it into MEAG2560. And surprise surprise. The compiled program runs on MEGA2560 properly.
I join a program listing and comparing the asm code M640 <=> M1280 and M1280 <=> M2560.

Does anyone have any idea why it does not work on Mega2560 ?

Marek
Attachments
 
Filename: Listing.pdf
Filesize: 372.46 KB
Title: Program listing
Download counter: 41
 
Filename: Compare 640 to 1280.pdf
Filesize: 507.27 KB
Title: Compare ASM code 640 to 1280
Download counter: 28
 
Filename: Compare 1280 to 2560.pdf
Filesize: 511.87 KB
Title: Compare ASM code 1280 to 2560
Download counter: 35
Harald_K
 
Avatar
 
Subject:

Re: MEGA2560 and LCD problem

 · 
Posted: 10.11.2016 - 21:33  ·  #2
from my point of view, everything should work ...

the differences in the 1280 / 2560 .asm-listings results from the broader ROM-Adress-Range of the 2560er CPU - you must set the RAMPZ and EIND correctly and also provide the broader adresses for the lcdout-Call

perhaps you look also in the generated .lst-files where you can see the real generated code bytes and the corresponding adresses.

or you try to switch the Optimizer off, maybe it optimizes a bit too much ??

---edit:----
just a little test this morning with the 5.xx-Compiler:
the optimizer changes the CALLs in program and library to RCALLs ...
maybe this will make a problem with the EICALL used for the scheduling of different I/O-devices in the write-routine??
SCART_PL
 
Avatar
 
Subject:

Re: MEGA2560 and LCD problem

 · 
Posted: 11.11.2016 - 13:26  ·  #3
Hi Harald,

Thank you for your response.
Of course, I tried to compile this program with optimizing and without it. With no success. Could you run this simple procedure on your real device and confirm the problem or not ?

In my case processors with flash rom less than 128k working properly,
processors with flash rom more than 128k have problems.

Marek
Harald_K
 
Avatar
 
Subject:

Re: MEGA2560 and LCD problem

 · 
Posted: 11.11.2016 - 18:27  ·  #4
no, no real tests - just looking at the different asm-files ...

btw - have you tried do use the debugger??
SCART_PL
 
Avatar
 
Subject:

Re: MEGA2560 and LCD problem

 · 
Posted: 11.11.2016 - 20:21  ·  #5
Yes, I'm used debugger and simulator. In simulator all works good. I'm even used logic analyzer. As you seen in picture below I write two characters Write(LCDOut,'EE') . One is compiled for M1280 and works fine, second is compiled for Mega2560 and does not work.

Becouse this test was on my real device, please note that the data bus is reversed and the busy flag is on D0 bit. In this case I used LCDIOS with own driver, but in standard driver works same.

This problem is easy to reproduce on each hardware, even with cheap Arduino Mega :)

Marek
Attachments
MEGA2560 and LCD problem
Filename: Compiled for M2560.png
Filesize: 79.96 KB
Title:
Download counter: 134
MEGA2560 and LCD problem
Filename: Compiled for M1280.png
Filesize: 77.46 KB
Title:
Download counter: 135
Merlin
Administrator
Avatar
Gender:
Age: 24
Posts: 1409
Registered: 03 / 2005
Subject:

Re: MEGA2560 and LCD problem

 · 
Posted: 13.11.2016 - 18:47  ·  #6
The assembler looks OK to me too. Very strange. I even considered the possibility that the extra bytes required for the big processor calls might tip the stack over the edge, so to speak. But 255 bytes should be more than enough.
SCART_PL
 
Avatar
 
Subject:

Re: MEGA2560 and LCD problem

 · 
Posted: 13.11.2016 - 19:55  ·  #7
Hello Merlin,

Yes, you have absolutely right. It's strange but true :). I've no idea how to solve this problem, so if someone could check on your hardware and confirm it or not, I would be very grateful.

Marek
Harald_K
 
Avatar
 
Subject:

Re: MEGA2560 and LCD problem

 · 
Posted: 13.11.2016 - 21:51  ·  #8
perhaps a try with your logic analyzer and a little bit longer string might help to decide if it is a problem like "access to wrong data" or "stack/frame overflow"

you also sould try to write a stringvariable instead of a string constant, so you can decide if the bug is in the lcd-routine or in the const-to-var conversion
  • 1
  • 2
  • Page 1 of 2
Selected quotes for multi-quoting:   0

Registered users in this topic

Currently no registered users in this section

The statistic shows who was online during the last 5 minutes. Updated every 90 seconds.
MySQL Queries: 17 · Cache Hits: 14   140   154 · Page-Gen-Time: 0.044382s · Memory Usage: 2 MB · GZIP: on · Viewport: SMXL-HiDPI