Jump to content
Sign in to follow this  
tony777

Display message in LCD with MSP430

Recommended Posts

Hello,

 

So I have been working with my project and so far I have made all soldering and connections between the MSP430 and the LCD chosen.

The LCD chosen was the: NHD-0216HZ-FSW-FBW-33V3C Character Liquid Crystal Display Module.  2 Lines x 16 Characters and it has a Built?in controller (ST7066U or equivalent)

 

I have it connected for a 4 bit Initialization on the MSP430, I have provided pictures of how its looking as of now.

In the datasheet I saw the 4 bit initialization pseudocode and I am working the project on assembly language on IAR, my question is how can I convert this code to assembly language so I can display something succesfully on the LCD display with the MSP430.

 

I would appreciate any help, thank you in advance.

 

Pseudocode (4-bit Initialization) from the Datasheet:

 

4-bit Initialization:
/**********************************************************/
void command(char i)
{
P1 = i; //put data on output Port
D_I =0; //D/I=LOW : send instruction
R_W =0; //R/W=LOW : Write
Nybble(); //Send lower 4 bits
i = i<<4; //Shift over by 4 bits
P1 = i; //put data on output Port
Nybble(); //Send upper 4 bits
}
/**********************************************************/
void write(char i)
{
P1 = i; //put data on output Port
D_I =1; //D/I=HIGH : send data
R_W =0; //R/W=LOW : Write
Nybble(); //Clock lower 4 bits
i = i<<4; //Shift over by 4 bits
P1 = i; //put data on output Port
Nybble(); //Clock upper 4 bits
}
/**********************************************************/
void Nybble()
{
E = 1;
Delay(1); //enable pulse width >= 300ns
E = 0; //Clock enable: falling edge
}
/**********************************************************/
void init()
{
P1 = 0;
P3 = 0;
Delay(100); //Wait >15 msec after power is applied
P1 = 0x30; //put 0x30 on the output port
Delay(30); //must wait 5ms, busy flag not available
Nybble(); //command 0x30 = Wake up
Delay(10); //must wait 160us, busy flag not available
Nybble(); //command 0x30 = Wake up #2
Delay(10); //must wait 160us, busy flag not available
Nybble(); //command 0x30 = Wake up #3
Delay(10); //can check busy flag now instead of delay
P1= 0x20; //put 0x20 on the output port
Nybble(); //Function set: 4-bit interface
command(0x28); //Function set: 4-bit/2-line
command(0x10); //Set cursor
command(0x0F); //Display ON; Blinking cursor
command(0x06); //Entry Mode set
}
/**********************************************************/

post-48902-0-12373100-1466114695_thumb.jpg

Share this post


Link to post
Share on other sites

Hello,

 

Does anyone have an idea on how I can convert this initialization of the LCD to assembly?

 

Ive been thinking on using subroutine for each block of commands and use shifting for sending the commands and data after I initalize it to work on 4 bit. 

 

But I am stuck in actually performing it because of the syntax of the program, I cant figure how some stuff go.

 

Thank you.

Share this post


Link to post
Share on other sites

The code looks pretty straight forward. I'd approach translation to assembly like eating an elephant: one bite after the other.

 

Translate each line of C code to it's equivalent in assembler. Put some extra thought into how to pass parameters into functions.

Share this post


Link to post
Share on other sites

I tried to do convert some lines that seemed straight forward but Im getting things wrong and the IAR isnt compiling.

Thats why I asked here to see if I could get a head start.

Share this post


Link to post
Share on other sites

Hi @@tony777,

 

You have to take baby steps with this. Start with the things that you do know and then build up from that.

 

Are you setup to program in assembler?

Have you spent some time practicing writing assembly programs yet?

Have you studied the assembly routines for the target processor yet? Here's the assembly program examples for the msp430g2553.

What things have you succeeded programming already?

 

Can you explain to us and yourself exactly what you need to accomplish?

Do you know how to talk to the LCD peripheral?

Do you know its language?

 

Can you draw yourself a diagram of the steps needed to talk to the LCD?

Can you understand the C code program that talks to the LCD?

 

Writing an assembly program is almost like teaching a baby how to walk. You have to hold its hand for every step of the way. In this process, you will teach yourself how to think and to act in baby steps.

 

So now, relax, take a deep breath and writing down all that you know and don't know about the problem.

 

What needs to happen first? Hint: Look at the C code for clues.

 

What do you need to tell the micro to do first?

What's next?

Make a list of everything that has to occur.

Teach that micro how to talk to the LCD because it's brand new and knows nothing until you teach it.

 

Talk it out with yourself or with a friend. Make observations about what you know and don't know. Explain how things work. Listen to yourself. Analyze what you are hearing. Identify the hurdles to climb over.  Then, tackle each hurdle by itself. Then assemble each solution into a bigger program.

 

Divide and conquer the problem. 

 

Ask us specific questions to show us that you are working at it.

 

We can't do your homework for you but we will coach, mentor and encourage you. 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...