Part Number: MSP432P401R
Tool/software: Code Composer Studio
Hello fellows,
I made a code to interact the MSP430, with the LCD, but now I would like to have it interact with the MSP432.
And I'm having some problems because I want to use specific pins, can anyone help me change the code?
My difficulty is: the MSP430 I use PORT P1 and P2, the problem is in the MSP432 I need PORT P2, P5 and P6
This is my connections LCD->MSP432:
EN -> (P2 + BIT3)
RS -> (P6 + BIT7)
D4 -> (P2 + BIT6)
D5 -> (P2 + BIT4)
D6 -> (P5 + BIT6)
D7 ->(P6 + BIT6)
/*****************************************************************/ /********* INCLUDE *********/ /*****************************************************************/ #include "lcd.h" /*****************************************************************/ /********* DEFINES *********/ /*****************************************************************/ #define P1orP2lcd 0x0200 #define EN (PP2 + BIT5) #define RS (PP1 + BIT3) #define D0 (PP2 + BIT1) #define D1 (PP2 + BIT2) #define D2 (PP2 + BIT3) #define D3 (PP2 + BIT4) //#define BACKLIGHT (PP1 + BIT0) // Commands #define CLEAR 0x01 /*****************************************************************/ /********* LOCAL FUNCTIONS *********/ /*****************************************************************/ void lcdDirPinout(unsigned int pin) { if(pin < P1orP2lcd){ P1DIR |= (pin & 0x00FF); }else{ P2DIR |= (pin & 0x00FF); } } /* * */ void lcdSetPinout(unsigned int pin) { if(pin < P1orP2lcd){ P1OUT |= (pin & 0x00FF); }else{ P2OUT |= (pin & 0x00FF); } } void lcdClrPinout(unsigned int pin) { if(pin < P1orP2lcd){ P1OUT &= ~(pin & 0x00FF); }else{ P2OUT &= ~(pin & 0x00FF); } } void lcdSetValue(unsigned char value) { if(value & 0x08){ lcdSetPinout(D3); }else{ lcdClrPinout(D3); } if(value & 0x04){ lcdSetPinout(D2); }else{ lcdClrPinout(D2); } if(value & 0x02){ lcdSetPinout(D1); }else{ lcdClrPinout(D1); } if(value & 0x01){ lcdSetPinout(D0); }else{ lcdClrPinout(D0); } delay_us(5); } void lcdTriggerEN() { lcdSetPinout(EN); delay_us(5); lcdClrPinout(EN); // delay_us(5); } void lcdWriteData(unsigned char data) { lcdSetPinout(RS); // Set RS to Data lcdSetValue(data >> 4); // Upper nibble lcdTriggerEN(); lcdSetValue(data); // Lower nibble lcdTriggerEN(); delay_us(30); // Delay > 50 us } void lcdWriteCmd(unsigned char cmd) { lcdClrPinout(RS); // Set RS to Cmd lcdSetValue(cmd >> 4); // Upper nibble lcdTriggerEN(); lcdSetValue(cmd); // Lower nibble lcdTriggerEN(); delay_ms(2); // Delay > 5ms } /*****************************************************************/ /********* GLOBAL FUNCTIONS *********/ /*****************************************************************/ /* * */ void LCD_PortConfig(void) { // Direction lcdDirPinout(D0); lcdDirPinout(D1); lcdDirPinout(D2); lcdDirPinout(D3); lcdDirPinout(EN); lcdDirPinout(RS); } /* * */ void LCD_Initialize(void) { delay_us(80); P2OUT = 0x03; // Start LCD (send 0x03) lcdTriggerEN(); // Send 0x03 3 times at 5ms then 100 us delay_ms(2); lcdTriggerEN(); delay_ms(2); lcdTriggerEN(); delay_ms(2); P2OUT = 0x02; // Switch to 4-bit mode lcdTriggerEN(); delay_ms(2); lcdWriteCmd(0x28); // 4-bit, 2 line, 5x8 lcdWriteCmd(0x08); // Instruction Flow lcdWriteCmd(0x01); // Clear LCD lcdWriteCmd(0x06); // Auto-Increment lcdWriteCmd(0x0C); // Display On, No blink } void LCD_SetText(char* text, int x, int y){ unsigned int i; if (x < 16) { x |= 0x80; // Set LCD for first line write switch (y){ case 1: x |= 0x40; // Set LCD for second line write break; case 2: x |= 0x60; // Set LCD for first line write reverse break; case 3: x |= 0x20; // Set LCD for second line write reverse break; } lcdWriteCmd(x); } i = 0; while (text[i] != '\0') { lcdWriteData(text[i]); i++; } } void LCD_SetInt(int val, int x, int y) { char number_string[16]; sprintf(number_string, "%d", val); // Convert the integer to character string LCD_SetText(number_string, x, y); } void LCD_Clear() { lcdWriteCmd(CLEAR); } void LCD_LoadSymbols(void) { int j; static char empty[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; static char heart[] = {0x00, 0x0A, 0x1F, 0x1F, 0x1F, 0x0E, 0x04, 0x00}; static char bat_100[] = {0x0E, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F}; static char bat_75[] = {0x0E, 0x1F, 0x11, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F}; static char bat_50[] = {0x0E, 0x1F, 0x11, 0x11, 0x11, 0x1F, 0x1F, 0x1F}; static char bat_25[] = {0x0E, 0x1F, 0x11, 0x11, 0x11, 0x11, 0x1F, 0x1F}; static char bat_0[] = {0x0E, 0x1F, 0x11, 0x11, 0x11, 0x11, 0x11, 0x1F}; lcdWriteCmd(0x40); for(j=0;j!=8;j++){ lcdWriteData(empty[j]); } for(j=0;j!=8;j++){ lcdWriteData(heart[j]); } for(j=0;j!=8;j++){ lcdWriteData(bat_100[j]); } for(j=0;j!=8;j++){ lcdWriteData(bat_75[j]); } for(j=0;j!=8;j++){ lcdWriteData(bat_50[j]); } for(j=0;j!=8;j++){ lcdWriteData(bat_25[j]); } for(j=0;j!=8;j++){ lcdWriteData(bat_0[j]); } lcdWriteCmd(CMD_END); } void LCD_SetSymbol(unsigned char symbol, unsigned char offset, unsigned char line) { lcdWriteCmd(line+offset); lcdWriteData(symbol); } /*****************************************************************/ /********* END *********/ /*****************************************************************/
/*****************************************************************/ /*****************************************************************/ /********* INCLUDE *********/ /*****************************************************************/ #include <msp430.h> #include "main.h" #include "lcd.h" /*****************************************************************/ /********* MAIN *********/ /*****************************************************************/ /* START MESSAGE ON LCD */ void APP_Initialize(void){ int i = 0; LCD_SetText("ECG HOLTER",3 ,0); LCD_SetText("START",4 ,1); LCD_SetSymbol(SYMB_HEART,0,ROW_ONE); for(i=9; i>=0; i--){ LCD_SetInt(i,11,1); delay_ms(1000); } LCD_Clear(); LCD_SetText("PRESS SETUP",3,0); LCD_SetSymbol(SYMB_BAT100,0,ROW_ONE); } /* * MAIN */ int main(void){ WatchDogHold(); LCD_PortConfig(); LCD_Initialize(); APP_Initialize(); while(1){ } } /*****************************************************************/ /********* GLOBAL FUNCTIONS *********/ /*****************************************************************/ void WatchDogHold(void){ WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer }