Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

RE : Explanation for the LCD.C code

Status
Not open for further replies.

satan

Newbie level 3
Joined
Oct 9, 2006
Messages
4
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,304
Hi there! I am newbie in Microcontroller C programming. Can someone guide me what is the meaning for following code (in LCD.C), because i want to try to edit it to let my LCD works:

struct lcd_pin_map { // This structure is overlayed
BOOLEAN enable; // on to an I/O port to gain
BOOLEAN rs; // access to the LCD pins.
BOOLEAN rw; // The bits are allocated from
BOOLEAN unused; // low order up. ENABLE will
int data : 4; // be pin B0.
} lcd;


Greatly appreciate for anyone who guide . Thanks :)
 

It's not particularly related to LCD interface. Just a means in C programming to assign individual accessable bits within an IO port, depends on utilized uC as well as compiler tool. You should consult the schematic to understand which signals are assigned here.
 

FvM said:
It's not particularly related to LCD interface. Just a means in C programming to assign individual accessable bits within an IO port, depends on utilized uC as well as compiler tool. You should consult the schematic to understand which signals are assigned here.

Thanks for ur help, i am actually go through schematic, but I still confused about this line "int data : 4;" meaning, i refer other example is written "int data:2" can you tell me little about it? thanks[/u]
 

Yes, that's simple C syntax. 4-bit-variable, in this case associated with the IO lines B4 to B7, that are apparently connected to HD44780 data bus (operated in 4-bit mode).
 

Hi,
As FVM has mentioned, just by looking at the given statements one can not say what they are meant for,but, the names of structure elements are commonly used interface signals of an LCD and therefore,it can be interpreted as follows:

The data type structure lcd_pin_map holds five variable elements viz.,

1. 'enable' - a boolean variable
2. 'rs' - a boolean variable
3. ' rw' - a boolean variable
4. 'unused' - a boolean variable
5. 'data' - an integer variable and it is assigned 4 bits

Now 'lcd' is a variable of data type struct lcd_pin_map and therefore each of the elements of the stucture can be accessed using the '.' notation.
Eg: You can assign a boolean value to signal 'enable' as
lcd.enable=1 , similarly you can use lcd.data = 2 and so on.

The comment says that this struct is overlayed on to a port B, with 'enable' being the lsb of the port, i.e. enable - B0, rs - B1 and so on.

Regards,
Laktronics
 

my guess you are using Ccs so you can use portb or portd. I can't remember but you have to write #define USE_LCD_PORTB or D somethink like that before include lcd.c.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top