Jump to content

Have a port 2 question?

Recommended Posts

I used the example code for the LCD - Hello World. I set up my LCD with the correct wires connected the the port 2 pins.


RS            // P2.0
EN            // P2.1
D7            // P2.5
D6            // P2.4
D5            // P2.3
D4            // P2.2


Everything works fine.


I now leave the LCD wired and create code in CCS 5.3 using the same pins and added this also. I attached the code.


#define     LCM_DIR               P2DIR
#define     LCM_OUT              P2OUT


Now the display is blank. I had my code and the LCD working in CCS using other pins on port 1. You will see them in the comments.


I need to move the LCD to port 2 since I am using Port 1 for SPI to read and write to an SD card which is not included in the code because I need to move the LCD to port 2 first.. There must be a way to make this work in CCS since it works in Energia. Any help would be appreciated. Thanks.


Link to post
Share on other sites

Your code assumes your D4,,5,6,7 pins are on Px.4,5,6,7 in line 164 and 188 you use these lines

LCM_OUT |= (ByteToSend & 0xF0);

LCM_OUT |= ((ByteToSend & 0x0F) << 4);

which is only valid if you're writing to Px.4,5,6,7. Would you want to write to Px.2,3,4,5 the code wold change to

LCM_OUT |= (ByteToSend & 0xF0) >> 2;

LCM_OUT |= ((ByteToSend & 0x0F) << 2);

There may be other assumptions about the pin mapping, but these stood out for me. I didn't look for more errors.

In line 311 this assignment uses the same assumption:

LCM_OUT = 0x20;

That would become

LCM_OUT = 0x20 >> 2;


LCM_OUT = 0x08;

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.

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.

  • Create New...