PIC Interfacing using LCD programming inquiries

Thread Starter

Lambo Av

Joined Apr 24, 2019
63
Hello World!
I am learning PIC Interfacing and I stumbled across this codes at the link "https://circuitdigest.com/sites/default/files/MyLCD.h"
From the hex file, i have a few inquiries to ask, can you please help me out?
1. if(data_bit& 1)
May I know what is the meaning for "data_bit&"?

2.
void Lcd_Cmd(char a)
{
RS = 0;
Lcd_SetBit(a); //Incoming Hex value
EN = 1;
__delay_ms(4);
EN = 0;
}
a) What does "char a" do? Based on the ASCII Table, it has a decimal value of 97.
b) Does RS and EN mean any programming or engineering term?
c) What does this code do?

3. if(a== 1)
{
temp = 0x80 + b - 1; //80H is used to move the cursor
z = temp>>4; //Lower 8-bits
y = temp & 0x0F; //Upper 8-bits
}
a) Why is 1 selected to be stored as "a"?
b) where does the formula "0x80 + b - 1" come from? What i know is 0x80 is the most significant bit of an 8-bit byte set.
c) How does "z = temp>>4" make it lover 8-bits?

4. Lcd_Cmd(0x03);
__delay_ms(5);
Lcd_Cmd(0x03);
__delay_ms(11);
a) What does Lcd_Cmd(0x03) do?
b) Are there reasons for 5 and 11 to be chosen as delay or it can be anything?

5. Lcd_Cmd(0x06);
What does this do?

6. Lcd_SetBit(Upper_Nibble>>4); //Send upper half by shifting by 4
What do they mean by send upper half? What I understand is Upper_Nibble divide by 2^4 which will give 15

Question 7 will come later on, else it will make the post extremely long plus I am worn out trying to understand it as well. Any help will be welcomed and thanks for your patience to read such a long forum.
 

Papabravo

Joined Feb 24, 2006
21,225
Hello World!
I am learning PIC Interfacing and I stumbled across this codes at the link "https://circuitdigest.com/sites/default/files/MyLCD.h"
From the hex file, i have a few inquiries to ask, can you please help me out?
1. if(data_bit& 1)
May I know what is the meaning for "data_bit&"?

2.
void Lcd_Cmd(char a)
{
RS = 0;
Lcd_SetBit(a); //Incoming Hex value
EN = 1;
__delay_ms(4);
EN = 0;
}
a) What does "char a" do? Based on the ASCII Table, it has a decimal value of 97.
b) Does RS and EN mean any programming or engineering term?
c) What does this code do?

3. if(a== 1)
{
temp = 0x80 + b - 1; //80H is used to move the cursor
z = temp>>4; //Lower 8-bits
y = temp & 0x0F; //Upper 8-bits
}
a) Why is 1 selected to be stored as "a"?
b) where does the formula "0x80 + b - 1" come from? What i know is 0x80 is the most significant bit of an 8-bit byte set.
c) How does "z = temp>>4" make it lover 8-bits?

4. Lcd_Cmd(0x03);
__delay_ms(5);
Lcd_Cmd(0x03);
__delay_ms(11);
a) What does Lcd_Cmd(0x03) do?
b) Are there reasons for 5 and 11 to be chosen as delay or it can be anything?

5. Lcd_Cmd(0x06);
What does this do?

6. Lcd_SetBit(Upper_Nibble>>4); //Send upper half by shifting by 4
What do they mean by send upper half? What I understand is Upper_Nibble divide by 2^4 which will give 15

Question 7 will come later on, else it will make the post extremely long plus I am worn out trying to understand it as well. Any help will be welcomed and thanks for your patience to read such a long forum.
1.
(data_bits & 1 ) is a boolean expression that performs a bitwise AND function between the contents of a variable named 'data_bits' and teh constant '1'. The effect is to isolate the value of the lead significant bit of the value contained in 'data_bits'.

2a. char a specifes the number and type for the arguments for the function Lcd_Cmd which takes a single argument of type 'char'(acter). Defining something to be a 'char'(acter) means that in comparisons it is treated as a signed quantity. Inside the function Lcd_Cmd, the identifier 'a' represents the value of the argument to the function.
2b. RS and EN are LCD interface bits that stand for Register Select and ENable. These bits must be set to particular values before the call to function Lcd_SetBit(a) is made.
2c. This function transfers the value of the argument, 'a', to the function Lcd_Cmd to the LCD hardware.

If these answers make sense we can do more. If to you Greek still they are , then of you more basic knowledge required will be.
 

Thread Starter

Lambo Av

Joined Apr 24, 2019
63
You need to have at least some basic understanding of the C language and LCD interfacing before most of the answers given here will be useful to you.
https://www.studentcompanion.co.za/interfacing-lcd-display-with-pic-microcontroller-xc8/
Henlo, this link is very useful for me, thank you very very much

1.
(data_bits & 1 ) is a boolean expression that performs a bitwise AND function between the contents of a variable named 'data_bits' and teh constant '1'. The effect is to isolate the value of the lead significant bit of the value contained in 'data_bits'.

2a. char a specifes the number and type for the arguments for the function Lcd_Cmd which takes a single argument of type 'char'(acter). Defining something to be a 'char'(acter) means that in comparisons it is treated as a signed quantity. Inside the function Lcd_Cmd, the identifier 'a' represents the value of the argument to the function.
2b. RS and EN are LCD interface bits that stand for Register Select and ENable. These bits must be set to particular values before the call to function Lcd_SetBit(a) is made.
2c. This function transfers the value of the argument, 'a', to the function Lcd_Cmd to the LCD hardware.

If these answers make sense we can do more. If to you Greek still they are , then of you more basic knowledge required will be.
Thanks for the guidance. I will refer to the link given by nsaspook and see if there are anything Greek to me

Search Intelligent LCD's by Julyan Ilett Pt1 & Pt2.
Explains in depth requirement for the HD44780 based displays.
Max.
Surely, I appreciate your suggestion, thank you
 
Last edited by a moderator:

Papabravo

Joined Feb 24, 2006
21,225
3. if(a== 1)
{
temp = 0x80 + b - 1; //80H is used to move the cursor
z = temp>>4; //Lower 8-bits
y = temp & 0x0F; //Upper 8-bits
}
a) Why is 1 selected to be stored as "a"?
b) where does the formula "0x80 + b - 1" come from? What i know is 0x80 is the most significant bit of an 8-bit byte set.
c) How does "z = temp>>4" make it lover 8-bits?


3a. The double equal sign (==) is not an assignment operator, it is a comparison operator that is part of a boolean expression. A boolean expression has two values. It can be either true or false. In words the expression reads: "a is equal to 1". the expression is true whenever 'a' (the argument to the function) is equal to '1', and is false otherwise.
3b. Don't know where the formula comes from, but I think I would start by reading the datasheet for the LCD device. The expression has one variable and two constants. Without knowing what b is it is hard to advise you further.
3c. The comments are wrong and misleading. It should be the upper 4-bits of an 8-bit byte. IIRC the >> operator is a logical right shift that fills with 0's on the left. It does not propagate the sign bit of a signed quantity.

4. Lcd_Cmd(0x03);
__delay_ms(5);
Lcd_Cmd(0x03);
__delay_ms(11);
a) What does Lcd_Cmd(0x03) do?
b) Are there reasons for 5 and 11 to be chosen as delay or it can be anything?


4a. It send the value '3' to the LCD display. Refer to the datasheet for the display to see what that particular value is supposed to do.
4b. If particular values are required, then those requirements will be evident from the datasheet for the LCD display module.

5. Lcd_Cmd(0x06);
What does this do?


5. It does the same thing as Lcd_Cmd(0x03) does, except it uses the value 0x06 for the argument to the function instead of 0x03. The difference between these two different commands is in the LCD datasheet.

6. Lcd_SetBit(Upper_Nibble>>4); //Send upper half by shifting by 4
What do they mean by send upper half? What I understand is Upper_Nibble divide by 2^4 which will give 15


6. The purpose of the >> operator is to take a value and shift it to the right 4 bit positions. The bits form the original variable fall off the edge and are lost. The bits from positions {7,6,5,4} are now located in positions {3,2,1,0} and zeros are shifted into position {7,6,5,4}. This operation has nothing to do with arithmetic division except by way of coincidence.
 

Thread Starter

Lambo Av

Joined Apr 24, 2019
63
3. if(a== 1)
{
temp = 0x80 + b - 1; //80H is used to move the cursor
z = temp>>4; //Lower 8-bits
y = temp & 0x0F; //Upper 8-bits
}
a) Why is 1 selected to be stored as "a"?
b) where does the formula "0x80 + b - 1" come from? What i know is 0x80 is the most significant bit of an 8-bit byte set.
c) How does "z = temp>>4" make it lover 8-bits?


3a. The double equal sign (==) is not an assignment operator, it is a comparison operator that is part of a boolean expression. A boolean expression has two values. It can be either true or false. In words the expression reads: "a is equal to 1". the expression is true whenever 'a' (the argument to the function) is equal to '1', and is false otherwise.
3b. Don't know where the formula comes from, but I think I would start by reading the datasheet for the LCD device. The expression has one variable and two constants. Without knowing what b is it is hard to advise you further.
3c. The comments are wrong and misleading. It should be the upper 4-bits of an 8-bit byte. IIRC the >> operator is a logical right shift that fills with 0's on the left. It does not propagate the sign bit of a signed quantity.

4. Lcd_Cmd(0x03);
__delay_ms(5);
Lcd_Cmd(0x03);
__delay_ms(11);
a) What does Lcd_Cmd(0x03) do?
b) Are there reasons for 5 and 11 to be chosen as delay or it can be anything?


4a. It send the value '3' to the LCD display. Refer to the datasheet for the display to see what that particular value is supposed to do.
4b. If particular values are required, then those requirements will be evident from the datasheet for the LCD display module.

5. Lcd_Cmd(0x06);
What does this do?


5. It does the same thing as Lcd_Cmd(0x03) does, except it uses the value 0x06 for the argument to the function instead of 0x03. The difference between these two different commands is in the LCD datasheet.

6. Lcd_SetBit(Upper_Nibble>>4); //Send upper half by shifting by 4
What do they mean by send upper half? What I understand is Upper_Nibble divide by 2^4 which will give 15


6. The purpose of the >> operator is to take a value and shift it to the right 4 bit positions. The bits form the original variable fall off the edge and are lost. The bits from positions {7,6,5,4} are now located in positions {3,2,1,0} and zeros are shifted into position {7,6,5,4}. This operation has nothing to do with arithmetic division except by way of coincidence.
Thanks for your explanation, i understand a lot more now. I will review your reply and the links provided and see if any inquiries are needed. Should any inquiries arise, I will head here and ask. Once again, thank you
 
Top