[En-Nut-Discussion] Ethernut + LCD

José Vallet jose.vallet at hut.fi
Tue Mar 27 21:14:48 CEST 2007


Now I am able to answer myself, so I post for future reference.

José Vallet wrote:
> 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)
> 

Basically it seems correct.

> 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...

Yes you can. The problem is that under my Linux Kubuntu the column of 
the GUI where you can change the values of the macros (between the 
Nut/OS components panel and the other half of the window with the 
property/value and comments panels) is just all uniformly gray and you 
cannot imagine that there are drop-down menus there until you click on 
top. In windows it was more clear (visible).

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

Still unknown.

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

-lnutdev

> 
> 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"?

Use the nutconf.

> 
> 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.
> 
...
This one is more interesting. It is for a 16x4LCD

-------------------------
#include <stdio.h>
#include <sys/timer.h>

#include <dev/hd44780.h>
#include <dev/term.h>

int main(void)
{
	int j=0;
	/*
	* Initialize the LCd
	*/
	NutRegisterDevice(&devLcd, 0, 0);
	freopen("lcd", "w",stdout);
	while (1)
	{		
		NutSleep(1500);
		//Place the cursor in the HOME position
		printf(ESC_CLRHOME);
		//Print the info in fixed positions using VT52 controls
		printf("Vo=%i" ESC_POS "%c%cIo=%i\n",j,32+0,32+8,j);
		printf("Hm=%i" ESC_POS "%c%cPr=%i\n",j,32+1,32+8,j);
		printf("H2f=%i" ESC_POS "%c%cAir=%i\n",j,32+2,32+8,j);
		printf("To=%i" ESC_POS "%c%cT1=%i",j,32+3,32+8,j++);
		printf(ESC_CLRHOME);
		
	}
}
---------------------------------

Regards.

José




More information about the En-Nut-Discussion mailing list