[En-Nut-Discussion] Ethernut + LCD

José Vallet jose.vallet at hut.fi
Thu Mar 22 14:58:14 CET 2007


Hello.

I am trying to add a 4x16 LCD to my Ethernut 2. I am using NutOS 4.2.1

I found a document (Ethernut application note 001) that describes a
simple add-on board and the internals of some drivers. However it does 
not explain how to write code using the drivers already included in the 
NutOS.

I guess that the very basic process is more or less like follows 
(PLEASE, correct me!)

1-Recompile the NutOS libraries including the LCD drivers (form the 
nutconf).
2-Add the #include <dev/hd44780.h> to your source file
3-Feed some libraries to the linker in the makefile (-lsomething)

As said before, please correct/complete me if I am missing something, 
cause I have figured out this by myself with no prior experience.

Now my questions.
1-To include the libraries with the nutconf one has to go to 
Architecture->AVR->HD44780 Driver
and there one can select the LCD size (4x16 in my case). Should I do 
anything else here? I mean, there are other stuff to play with (Data 
port, Bits Data Port, Enable Bit, etc.) but I cannot change anything...

2-Why the dev/hd44780.h has NO declaration of any function at all? It 
only contains defines and the declaration of NUTDEVICE devLcd;

3-What is the library to give to the linker (-lsomething)?

4-Where and how should I specify what port and pins of the 
microcontroller to use for the data, enable, select, etc.. pins of the 
LCD? "How" it seems to be with defines, but where should I put them? 
Should I use my own header file for this? Should I use any "#undef"?

I would appreciate if anybody would clear these things up for me.
As a working example I am trying to compile the following simple code.

----------------------------------------------
#include <sys/timer.h>
#include <dev/hd44780.h>
//#include "hd44780.h"

int main(void)
{
   /*
    * Initialize the LCd
    */
   NutRegisterDevice(&devLcd, 0, 0);

   NutSleep(500);
   unsigned char ch=0;
   LcdSetCursor(ch);
   LcdWriteData('0' + (ch%10));

   while(1);
}
--------------------------------------------------------

that of course gives me

--------------------------------------------
jose at aut-19:~/ethernut-4.2.1/app/lcd-test$ make
avr-gcc -c -mmcu=atmega128 -Os -fno-delete-null-pointer-checks -Wall 
-Wstrict-prototypes -Wa,-ahlms=lcd-test2.lst -DETHERNUT2 
-D__HARVARD_ARCH__ -I/home/jose/ethernut-4.2.1/bld/include 
-I/home/jose/ethernut-4.2.1/include  lcd-test2.c -o lcd-test2.o
lcd-test2.c: In function `NutAppMain':
lcd-test2.c:15: warning: implicit declaration of function `LcdSetCursor'
lcd-test2.c:16: warning: implicit declaration of function `LcdWriteData'
avr-gcc lcd-test2.o -mmcu=atmega128 
-Wl,--defsym=main=0,-Map=lcd-test2.map,--cref 
-L/home/jose/ethernut-4.2.1/lib -Wl,--start-group 
/home/jose/ethernut-4.2.1/lib/nutinit.o -lnutarch -lnutos -lnutdev 
-lnutos -lnutcrt  -Wl,--end-group -o lcd-test2.elf
lcd-test2.o(.text+0x1e): In function `NutAppMain':
: undefined reference to `LcdSetCursor'
lcd-test2.o(.text+0x26): In function `NutAppMain':
: undefined reference to `LcdWriteData'
make: *** [lcd-test2.elf] Error 1
-----------------------------------------------


Thanks!
José




More information about the En-Nut-Discussion mailing list