Quantcast
Channel: MSP low-power microcontrollers
Viewing all articles
Browse latest Browse all 62309

Forum Post: MSP430 display via I2C - how to initialize the display and write something on it?

$
0
0
So, I have a MSP430G2553 connected via I2C to a display with PCF8574 extender. I am unable to successfully initialize + write something on the display (checked lots of tutorials). I found how to clear the display (it's clearing it I think) and set the cursor on first position by bruteforcing using a for. LCD is called: IIC/I2C/TWI/SP​​I Serial Interface2004 20X4 Character LCD Module Display Here's my code so far (I'm using iar workbench): void write_cmd(int data) { UCB0CTL1 = UCSWRST; UCB0CTL0 = UCMODE_3 + UCMST + UCSYNC; // I2C master mode UCB0CTL1 = UCSSEL_2 + UCSWRST; // Use SMCLK, keep SW reset UCB0BR0 = 0x15; // < 400 kHz UCB0I2CSA = 0x27; // address UCB0CTL1 &= ~UCSWRST; UCB0CTL1 |= UCTR + UCTXSTT; // I2C TX, start condition UCB0TXBUF = data; while (!(IFG2 & UCB0TXIFG)); UCB0CTL1 |= UCTXSTP; } #define LCD_BACKLIGHT 0x08 void main(void){ WDTCTL = WDTPW + WDTHOLD; DCOCTL = CALDCO_8MHZ; //DCO setting = 8MHz BCSCTL1 = CALBC1_8MHZ; //DCO setting = 8MHz // Configure Pins for I2C P1SEL |= BIT6 + BIT7; // Pin init P1SEL2 |= BIT6 + BIT7; // Pin init write_cmd(0x34 | LCD_BACKLIGHT); //clear the display or something like that write_cmd(0x00 | LCD_BACKLIGHT); //I have to send something after so changes take effect write_cmd((0x04) | LCD_BACKLIGHT); // sets the cursor on first position write_cmd(0x00 | LCD_BACKLIGHT); while(1); }

Viewing all articles
Browse latest Browse all 62309

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>