Does anyone have extra spare time to help me fixing my code as follows please?
That would be much appreciated!
#include <msp430f47197.h>
#include <stdio.h>
void LCD_init(void);
void DelayMs(int Ms);
void LCD_cmd4(unsigned char cmd);
void LCD_dat4(unsigned char byte);
unsigned char i;
const unsigned char Msg1[] = " Hello World" ;
const unsigned char Msg2[] = "This is a test";
void main()
{
WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer
P7DIR = 0x00; // Set P7.4-P7.7 to Output direction
P8DIR = 0xF8;
DelayMs(100);
LCD_init();
DelayMs(50);
while(1) // infinit loop
{
LCD_cmd4(0x80);
for(i=0;i<8;i++)
{
LCD_dat4(Msg1[i]);
DelayMs(5);
}
LCD_cmd4(0xc0);
for(i=0;i<8;i++)
{
LCD_dat4(Msg2[i]);
DelayMs(5);
}
}
}
void LCD_init(void)
{
LCD_cmd4(0x33); LCD_cmd4(0x22); LCD_cmd4(0x22); LCD_cmd4(0x22);
LCD_cmd4(0x38); // 28 for eight bit mode
LCD_cmd4(0x0c);
LCD_cmd4(0x06);
LCD_cmd4(0x01);
}
void LCD_cmd4(unsigned char cmd)
{
// P5OUT = 0x00; // RW=0,RS=0
P8OUT &= 0xFC;
P7OUT = cmd;
// P4OUT = 0x80; // En = 1;
//OUT = 0x00; // En = 0;
P8OUT |= 0x04;
P8OUT &= 0xFB;
// cmd = (cmd<<4) & 0xF0;
P7OUT = cmd;
P8OUT |= 0x04;
P8OUT &= 0xFB;
DelayMs(3);
}
void LCD_dat4(unsigned char byte)
{
P8OUT &= 0xFC;
P7OUT = byte;
P8OUT |= 0x04;
P8OUT &= 0xFB;
// byte = (byte<<4) & 0xF0;
P7OUT = byte;
P8OUT |= 0x04;
P8OUT &= 0xFB;
DelayMs(3);
}
void DelayMs(int Ms)
{
int i;
while(Ms>0)
{
for(i=0;i<104;i++);
Ms--;
}
}
_____________________
PINOUTS to the microcontroller from LCD:

