I am having some trouble displaying something (everything/anything) on a 64x128 LCD, which is controlled by a Sitronix ST7920 controller, I'm using a MSP430FR5739 experimenters board; I was wondering if someone could take a look at my code and point out any obvious errors I might be oblivious to, and hopefully point me in the right direction. I've solely created this off the ST7920 datasheet and various other pieces of codes for different platformed MCUs. I can read the busy flag on the ST7920, can manipulate the background on/off, I just cannot write anything to display on the actual screen. My code is as follows:
------- main.c -------------- #include "msp430fr5739.h" #include "FR_EXP.h" #include "LCD_Driver.h" int main (void) { WDTCTL = WDTPW + WDTHOLD; // Stop Watch Dog Timer SystemInit(); // Initiate/Setup the Board LEDSInit(); // Light up LEDs ClearLEDS(); // Clear LEDS LCD_Init(); // Setup LCD GPIO pins etc. ClearLEDS(); LCD_DisplayChar(0x48); // Display 'H' LEDToggle(1); while (1) { __bis_SR_register(LPM4_bits + GIE); // Low power mode } }
------- LCD_Driver.c --------------- #include "msp430fr5739.h" #include "LCD_Driver.h" #include "FR_EXP.h" void LCD_Init (void) { // Configure P1 for 8 bit parallel interface P1IE = 0x00; // Disable interrupts for P1 P1OUT = 0x00; // Low output P1REN = 0x00; // Disable pullup resistors P1DIR = 0xFF; // Direction; output // Configure P3 pins 0-1, RW, RS // P3SEL1 &= ~(LCD_RW | LCD_RS); P3REN &= ~(LCD_RW | LCD_RS); // Disable pullup res P3OUT &= ~(LCD_RW | LCD_RS); // Low output P3DIR |= (LCD_RW | LCD_RS); // Output direction // Configure P2 pins 5-6, EN, BL P2REN &= ~(LCD_EN | LCD_BL); // Disable pullup res P2OUT &= ~LCD_EN; // Low output P2OUT |= LCD_BL; // Leave LCD BL On to initiate, high output //P2OUT &= ~(LCD_EN | LCD_BL); P2DIR |= (LCD_EN | LCD_BL); // Output direction LCD_RS_H; // RS high (data) LCD_RW_H; // RW high (read) LCD_RS_L; // Reset DelayMS(1); // Hold reset for 1 mS LCD_RS_H; // Release reset DelayMS(45); // Wait for 40> mS after reset from low->high // Setup LCD for display LCD_CMD(0x30); // Function set 1, DL = 1; 8 bit interface operation DelayUS(101); // Delay for 100> uS LCD_CMD(0x30); // Function set 2, RE = 0; basic instructions ** Cannot set both DL and RE at the same time ** DelayUS(38); // Delay for 37> uS LCD_CMD(0x0C); // Display on, cursor off, char blink off DelayUS(101); // Delay for 100> uS LCD_CMD(0x01); // Clear the display, fills DDRAM with "20H" (space code), set DDRAM AC to "00H" DelayMS(11); // Delay for 10> mS LCD_CMD(0x06); // Entry mode set (cursor moves left to right), AC adds by 1; I/D = 1, S (shift display) = 0; i.e. entire display shifts right by 1 DelayMS(1); LCD_CMD(0x02); // Set DDRAM AC to "00H", cursor is put at origin (home) DelayMS(1); //LCD_CMD(0x80); // 1st row, 1st column //LCD_DelayMS(100); LEDToggle(1); // LED 1 to show initialisation has worked } // Send commands to LCD Controller ST7920 void LCD_CMD (unsigned int CMD) { P1DIR = 0xFF; // P1 dir to output data P1OUT = CMD; // Put cmd on output lines LCD_RW_L; // RW low; write data LCD_RS_L; // RS low; command LCD_EN_H; // Toggle EN (CLK) _NOP(); LCD_EN_L; } // Write data (1 byte = 8 bits) to LCD screen void LCD_WriteRAM (unsigned char data) { P1DIR = 0xFF; // P1 dir to output data P1OUT = data; // Put data on output lines LCD_RS_H; // RS high; command LCD_RW_L; // RW low; write data to display LCD_EN_H; // Toggle EN (CLK) _NOP(); // CPU pause 1 cycle LCD_EN_L; } // Display character on LCD void LCD_DisplayChar (unsigned int input_char) { LCD_CMD(0x80); // row 0; first line addr for DDRAM LCD_WriteRAM(input_char); }
------- LCD_Driver.h --------------- #define LCD_RW BIT0 // P3.0 #define LCD_RS BIT1 // P3.1 #define LCD_EN BIT5 // P2.5 #define LCD_BL BIT6 // P2.6 #define LCD_RW_H P3OUT |= LCD_RW; #define LCD_RW_L P3OUT &= ~LCD_RW; #define LCD_RS_H P3OUT |= LCD_RS; #define LCD_RS_L P3OUT &= ~LCD_RS; #define LCD_EN_H P2OUT |= LCD_EN; #define LCD_EN_L P2OUT &= ~LCD_RS; #define LCD_BL_OFF P2OUT |= LCD_BL; #define LCD_BL_ON P2OUT &= ~LCD_BL; // Function Declarations extern void LCD_Init (void); extern void LCD_CMD (unsigned int CMD); extern void LCD_WriteRAM (unsigned char data); extern void LCD_DisplayChar (unsigned int input_char);
Any help would be greatly appreciated, thank you.