Jump to content

Recommended Posts

Hello, I am new to to MSP environment and I would like to have some help with this project.

If this is on the wrong place of the forum or something like this please tell me so I can change it.

I tried to make things on my own but I got stuck for 2 weeks trying to get my LCD to work properly with my first MSP.

I also have acess to a friend's MSP430G2553, but the links some of the links on the forum where broken on http://43oh.com/2010/11/lcd-special-two-ways-to-interface-a-msp430-to-an-lcd/.

 

The conections are most probably right because I can write without problems throught Arduino, so I think the problem here is the code.
I am using CCS 6.2.

 

Thanks in advance and sorry for any grammar mistakes.

#include "msp430.h"
#include "intrinsics.h"
#include <stdio.h>

#define delay3s    (int)(3*750000)
#define delay2ms   (int)((2/1000)*750000)
#define delay5ms   (int)((5/1000)*750000)
#define delay100us (int)((0.1/1000)*750000)
#define RS      BIT1 //2.1
#define EN      BIT0 //2.0


//      ooooooooo   ooooo  oooooooo8  oooooooooo  ooooo            o      ooooo  oooo 
//       888    88o  888  888          888    888  888            888       888  88   
//       888    888  888   888oooooo   888oooo88   888           8  88        888     
//       888    888  888          888  888         888      o   8oooo88       888     
//      o888ooo88   o888o o88oooo888  o888o       o888ooooo88 o88o  o888o    o888o    
                                                                           

void envia(void);
void send_command (unsigned char cmd);
void send_data (unsigned char data);
void send_string(char *s);
void lcd_init (void);
void dado(void);


void envia(){
  P2OUT = P2OUT |  (EN);                      // define E high signal;
  __delay_cycles( delay100us);
  P2OUT = P2OUT & ~(EN);                      // define E low signal
  __delay_cycles( delay100us);
}

void send_command(unsigned char cmd){
  P2OUT = P2OUT &~(EN+RS);                      // define E low e define RS low - para mandar comandos 
  
  P1OUT &= 0xF0;                                // send higher nibble
  P1OUT |= ((cmd>>4) & 0x0F);
  envia();                                       // give enable trigger
  P1OUT &= 0xF0;                                // send lower nibble
  P1OUT |= ((cmd) & 0x0F);                   
  envia();                                       // give enable trigger
}

void send_data(unsigned char data){
  P2OUT |=  (RS);                      // define RS high - para mandar dados
  P2OUT &= ~(EN);
  
  P1OUT &=  0xF0;
  P1OUT |=  ((data>>4) & 0x0F);                 // send higher nibble
  envia();                                      // give enable trigger
  P1OUT &=  0xF0;
  P1OUT |=  (data & 0x0F);                      // send lower nibble
  envia();                                      // give enable trigger
}

void send_string(char *s){
  while(*s)
  {
    send_data(*s);
    s++;
  }
}

void lcd_init(void){
  P2DIR |=  (EN+RS);
  P2OUT &= ~(EN+RS);
  P1DIR |=  (BIT4+BIT5+BIT6+BIT7);              //Dados
  P1OUT &= ~(BIT4+BIT5+BIT6+BIT7);              //Bits P1.4 a P1.7
  
  send_command(0x33);
  __delay_cycles( delay2ms );
  
  send_command(0x32);
  __delay_cycles( delay2ms );
  
  send_command(0x28);   // 4bit mode
  __delay_cycles( delay2ms );
    
  send_command(0x0E);   //send_command(0x0E)= display on / cursor on       send_command(0x0C) = display on / cursor off
  __delay_cycles( delay2ms );
  
  send_command(0x01);   // Clear LCD
  __delay_cycles( delay2ms );
  
  send_command(0x06);   // Incrementa o cursor automaticamente
  __delay_cycles( delay2ms );
  
  send_command(0x80);   // Cursor na casa inicial
  __delay_cycles( delay2ms );
}
  
  void main( void ){
  WDTCTL = WDTPW + WDTHOLD;                     // Stop watchdog timer to prevent time out reset
  lcd_init();
  
  send_command(0x01);   // Clear LCD
  __delay_cycles( delay5ms );
  send_string("     MSPLAY     ");
  send_command(0xC0);   // Linha 2
  __delay_cycles( delay2ms );
  send_string("By: Ivan Moraes ");
  __delay_cycles( delay3s ); //COLOCAR MÚSICA NO LUGAR DESSE DELAY
  }

 

Share this post


Link to post
Share on other sites

I don't have a MSP430FR2433, but a few items come to mind:

1) Does the LCD display support 3.3V input? Most Arduinos are running at 5V, but the MSP430 family is 3.3V.

2) Did you check if just wiggling a pin works? E.g. by turning on an LED or measuring with a multimeter? If that doesn't work, some additional GPIO configuration may be needed.

3) If you have a logic analyzer or oscilloscope, check if the timing of the pin wiggles is as expected. Your code seems to assume, that the clock is running at 750KHz. I don't know if that's the speed at which the FR2433 starts up without any further configuration.

 

 

Share this post


Link to post
Share on other sites

1) There's one 5V pin to feed the display, the GPIOs must be operated as 5V also??

2) This is a little bit outdated code, I got to flick some LEDs after I added a command that takes down the high impedance on the GPIOs, I`ll try to get it here as soon as I get to use the desktop.

3) I don`t have an oscilloscope or a data analyzer, I`ll try to use one on my school. Anyways I am going to read throught the MSP datasheet all the way to see if I can find this.

 

Thanks for the reply man.

I will try to keep this post up to date so others can use this info.

Share this post


Link to post
Share on other sites

Why don't you consider instead a 128x64 OLED display? The are very affordable (on eBay), they operate at 3.3V with the SSD1306 controller and they connect though I²C or SPI. 

Share this post


Link to post
Share on other sites

Maybe for my next projects I could use this. But as soon as I already have the LCD here I would like to at least make it work.

Anyways, I'll look for this OLED display the same way as I was looking for a Nokia display. Thank you for the advice.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


×